How do i implement a Java function in Hack Assembly? I know that instructions to change variables is easily made, but how does HACK call a function? For Example:
function(int a, int b) {
if (a-b > 0)
return a;
else
return b;
}
My (i think wrong) result is :
@a
D=M
@b
D=D-M
@JUMPMARK1
D;JGT
@Jumpmark2
0;JMP
(JUMPMARK1)
@a
D=M
@function
M=D
(Jumpmark2)
@b
D=M
@function
M=D
So the issue is that i dont know where to store the result(return)..should i create a variable like i did in this example for the function and store it there?