You are on page 1of 1

GREATER.

X68
GOAL:
This program finds the greater of two numbers and places the result into
D3 and the defined space R.
OPERATION:
The programs defines the two numbers as NUM1 and NUM2. They are first copied
to D0 and D1 respectively.
A CMP instruction subtracts D0 from D1 and updates the status registers.
The BEQ statement brances to LAB1 if both numbers are the same. This
instruction is not really needed.
The BGT instruction is a Branch on Greater Than, and branches to LAB1 only
if D1 (i.e NUM2) is the greater number.
If NUM1 is the greater number then there is no branch, and NUM1 is copied
into D3. An unconditional branch is then used to exit the program by
branching to XT.
If NUM2 is the greater, or the numbers are equal, then LAB1 is branched to
as described earlier. This then moves the value of NUM2 into D3. The program
then continues through XT.
XT is executed before exiting the program, whatever path has been taken.
XT's only purpose is to take the value of the greater number from D3 and
place it in the reserved memory, labelled R.

You might also like