Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Part3 where
- import TAMCode
- import TAMInterpreter
- test = [LOADL 1, LOADL 2, ADD, PUTINT, LABEL "end", STORE (SB (-0))]
- part1 = [ GETINT, -- Read integer n onto stack
- LOADL 1, -- Load integer 1 onto stack
- LOAD (SB 0), -- Duplicate top of stack
- LSS, -- Check if n < 1
- JUMPIFZ "end",
- LOADL 1,
- LABEL "loop",
- LOAD (SB 1), -- Load current number to top of stack
- PUTINT, -- Print the current number
- LOADL 1, -- Load 1 (ready to add)
- ADD, -- Add 1 to the current number
- LOAD (SB 0),
- LOAD (SB 1),
- LSS,
- JUMPIFNZ "end",
- JUMP "loop",
- LABEL "end" -- End block]
Add Comment
Please, Sign In to add comment