added memory manipulation constructs
This commit is contained in:
@@ -99,6 +99,25 @@ handleSymbol h (ZorthASTWord "dup") = do
|
|||||||
\ push rax\n"
|
\ push rax\n"
|
||||||
return ()
|
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
|
handleSymbol h (ZorthASTWord "rot") = do
|
||||||
liftIO $ hPutStr h
|
liftIO $ hPutStr h
|
||||||
" pop rax\n\
|
" pop rax\n\
|
||||||
@@ -221,6 +240,8 @@ compileZorth _ [] = return ()
|
|||||||
compileZorth h xs = do
|
compileZorth h xs = do
|
||||||
forthPrelude h
|
forthPrelude h
|
||||||
compileZorthAST h xs $ Environment 0 M.empty
|
compileZorthAST h xs $ Environment 0 M.empty
|
||||||
hPutStr h " mov rax,60\n\
|
hPutStr h " mov rax,60\n\
|
||||||
\ mov rdi,0\n\
|
\ mov rdi,0\n\
|
||||||
\ syscall\n"
|
\ syscall\n"
|
||||||
|
hPutStr h "section .bss\n\
|
||||||
|
\ mem: resq 640000\n"
|
||||||
Reference in New Issue
Block a user