I'm trying to create a program in Easy68K that is able to test if two numbers entered by the user are equal. I know roughly how to get the input from the user, and load it into a data register, and I think I need to use a while loop that will test whether the two numbers are equal.
I'm not asking for people to write the program for me, I just really need some advice.
This is the code I have so far:
*-----------------------------------------------------------
* Title : Number Comparison
* Written by : Robert Dudley
* Date : 23/04/2017
* Description: Compares two numbers and determines if they are equal
*-----------------------------------------------------------
ORG $1000
START: ; first instruction of program
* Put program code here
LEA enterFirst,A1 ; load message into adreg A1
MOVE.B #14,D0
TRAP #15
MOVE.B #4,D0 ; read number from keyboard into D1.L
TRAP #15
LEA enterSecond,A1
MOVE.B #14,D0
TRAP #15
MOVE.B #4,D0
TRAP #15
SIMHALT ; halt simulator
* Put variables and constants here
enterFirst DC.B 'Enter first number: ',0
enterSecond DC.B 'Enter second number: ',0
END START ; last line of source
NOTE: Also, how do I move the input from D1.L
to another register?
The keyboard input routine most probably leaves the entered number in some register, let's assume it's D1. Entering the second value will destroy the first one if not saved somewhere else. (I guess this is why you asked how to move a value from one register to the other)
Insert the following line after the second TRAP 15
:
MOVE.L d1,d7
Make sure none of the traps changes this register value - otherwise you will lose it.
After the second keyboard input, you will have the second number in d1, the first one (hopefully) still in d7. C
oMP
are the two registers, and use a conditional branch to whatever [non]equality output routine you might write