How can i do this if statement in 68k

143 views Asked by At

In my program i take input of a option and if input is equal to 1 I want do d+1. I have looked at the EQ condition syntax but cant get my head around it. Pseudo code:

if choice=1 do d+1

What i have done:

 INPUT_FUNCTION:    
     MOVE.B #4,D0
     TRAP #15
1

There are 1 answers

0
Erik Eidt On

All structured statements translate into assembly using the style of if-goto-label.

For an if-statement, a conditional goto (if-goto) is used to skip what you don't want to do when you don't want to do it, and otherwise execute the then-part.

    if choice != 1 goto endif1;
    d+1
endif1:

This if-goto is easily translated into assembly:

    CMP.L #1,D1      is D1.L == 1 ?  (set flags with compare result)
    BNE endif1       no? then skip ahead to label endif1 (test flags)
    ...
    d+1
    ...
endif1