Sections


Main-Menu

header image

Statement translation


The assignment, if, while, read and write statements are translated as follows:

Assignment

x := expr

code for expr
STORE X

Conditional

if C then
S1
else
S2
end

L1:
L2:

code for C
BR_FALSE L1
code for S1
BR L2
code for S2

While-do

while C do S

L1:

L2:

code for C
BR_FALSE L2
code for S
BR L1

Input

read X

IN_INT X

Output

write expr

code for expr
OUT_INT

If the code is placed in an array, then the label addresses must be back-patched into the code when they become available.


Related Articles :



Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Shaadi.com Matrimony - Register for FREE