0

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
    Did you read the [Assembly Demo](http://www.easy68k.com/QuickStart/TwoFrames.htm) where it says _A compare is added to test if the input is a 0 or not_? – Armali Apr 23 '21 at 21:04

1 Answers1

1

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
Erik Eidt
  • 23,049
  • 2
  • 29
  • 53