Use the information given in the last section, in order to write a piece of code that when executed puts the current values of ap, fp and pc in memory (say, write ap into [ap], fp into [ap + 1] and pc into [ap + 2]).
Continue reading “Cairo’s Function Exercise II”Tag: function
Cairo’s Function Exercise I
Compile and run (with at least 10 steps) the following code. Use the –print_memory and –relocate_prints flags for cairo-run.
func main():
call foo
call foo
call foo
ret
end
func foo():
[ap] = 1000; ap++
ret
end
Try to think what happens when the cpu gets to the ret instruction (which of the registers ap, fp, pc should change when ret is executed and to what values?).
Continue reading “Cairo’s Function Exercise I”