instruction unlabeled_instruction
labeled_instruction
labeled_instruction label : unlabeled_instruction
label identifier
unlabeled_instruction lhs = rhs
push(pushargument)
if lhs goto label
unlabeled_instruction goto label
pop()
procname()
return
putint(putintargument)
pushargument lhs
smallterm
lhs stack[term]
term
register
term stack[smallterm]
smallterm register + const
register - const
register
register R
BP
SP
const integer
rhs const
lhs
register op lhs
register op const
pop()
getint()
putintargument rhs
smallterm
op
+
-
*
%
/
<
=<
>
>=
==
!=
There is a restriction that if the rhs is register op lhs or register op const, then lhs must be the same register name as in regsiter.
func
for
each function func in the source program. Note that this function cannot
return any value.
void push(int element) { stack[++SP]=element; return; } int pop() { return(stack[SP--]); } int getint() { int a; scanf("%d",&a); return a; } void putint(int a) { printf("%d",a); return; }