Define and call are done
This commit is contained in:
parent
2618e5c87f
commit
df5418432e
|
@ -72,6 +72,8 @@ genericTwoByteOp op arg = do
|
||||||
insState <- get
|
insState <- get
|
||||||
return $ appendBytesThenWord [op] arg insState
|
return $ appendBytesThenWord [op] arg insState
|
||||||
|
|
||||||
|
-- This allows you to define functions which can be called later using `call`.
|
||||||
|
-- Note: your function must end with an `rts`, I don't add that automatically
|
||||||
define :: String -> Instruction -> Instruction
|
define :: String -> Instruction -> Instruction
|
||||||
define name definition = do
|
define name definition = do
|
||||||
insState <- get
|
insState <- get
|
||||||
|
@ -79,6 +81,13 @@ define name definition = do
|
||||||
-- TODO: COMBINE THE FUNCTION DEFINITIONS HERE TOO NOT JUST BYTESTRINGS
|
-- TODO: COMBINE THE FUNCTION DEFINITIONS HERE TOO NOT JUST BYTESTRINGS
|
||||||
return $ execState definition insState'
|
return $ execState definition insState'
|
||||||
|
|
||||||
|
call :: String -> Instruction
|
||||||
|
call name = do
|
||||||
|
insState <- get
|
||||||
|
let pointer = case (M.lookup name (insState ^. functionTable)) of
|
||||||
|
Just ptr -> ptr
|
||||||
|
Nothing -> error ("Couldn't find function " ++ name ++ ". Perhaps it wasn't `define`d?")
|
||||||
|
jsr (Absolute $ fromIntegral pointer)
|
||||||
|
|
||||||
-- THE FOLLOWING WAS GENERATED BY
|
-- THE FOLLOWING WAS GENERATED BY
|
||||||
-- https://github.com/aearnus/assemblicom
|
-- https://github.com/aearnus/assemblicom
|
||||||
|
|
Loading…
Reference in New Issue