added memory manipulation constructs

This commit is contained in:
2025-09-09 13:04:32 +01:00
parent 16700541e6
commit b84f5f5e53
2 changed files with 25 additions and 4 deletions

View File

@@ -99,6 +99,25 @@ handleSymbol h (ZorthASTWord "dup") = do
\ push rax\n"
return ()
handleSymbol h (ZorthASTWord "mem") = do
liftIO $ hPutStr h
" push mem\n"
return ()
handleSymbol h (ZorthASTWord "!") = do
liftIO $ hPutStr h
" pop rbx\n\
\ pop rax\n\
\ mov qword[rax], rbx\n"
return ()
handleSymbol h (ZorthASTWord "@") = do
liftIO $ hPutStr h
" pop rax\n\
\ push qword[rax]\n"
return ()
handleSymbol h (ZorthASTWord "rot") = do
liftIO $ hPutStr h
" pop rax\n\
@@ -224,3 +243,5 @@ compileZorth h xs = do
hPutStr h " mov rax,60\n\
\ mov rdi,0\n\
\ syscall\n"
hPutStr h "section .bss\n\
\ mem: resq 640000\n"