added examples (fib,69420/fizzbuzz)

This commit is contained in:
2025-09-07 18:36:59 +01:00
parent ab2cba643d
commit c323e84a00
3 changed files with 70 additions and 0 deletions

View File

@@ -73,6 +73,23 @@ handleSymbol h (ZorthASTWord "-") = do
\ push rax\n"
return ()
handleSymbol h (ZorthASTWord "*") = do
liftIO $ hPutStr h
" pop rbx\n\
\ pop rax\n\
\ imul rax, rbx\n\
\ push rax\n"
return ()
handleSymbol h (ZorthASTWord "/") = do
liftIO $ hPutStr h
" pop rbx\n\
\ pop rax\n\
\ cqo\n\
\ idiv rbx\n\
\ imul rax, rbx\n"
return ()
handleSymbol h (ZorthASTWord "ret") = do
liftIO $ hPutStr h
" mov rax,60\n\
@@ -87,6 +104,16 @@ handleSymbol h (ZorthASTWord "dup") = do
\ push rax\n"
return ()
handleSymbol h (ZorthASTWord "rot") = do
liftIO $ hPutStr h
" pop rax\n\
\ pop rbx\n\
\ pop rcx\n\
\ push rbx\n\
\ push rax\n\
\ push rcx\n"
return ()
handleSymbol h (ZorthASTWord "swap") = do
liftIO $ hPutStr h
" pop rax\n\