1. |
You want to branch if R0 is less than R1 after the following
instruction. Which branch instruction do you use? It
is assumed, however, that unsigned data are stored in R0 and R1.
Answer: BHI
|
The
destination operand plays the main role in comparison using the CMP
instruction.
In this question, R1 is used as the destination
operand.
Assuming that R1 is greater than R0, you should use BHI. |
|
|
BNE LOOP
In the R1L register, "9" is entered as the counter to repeat the loop
nine times.
The counter is decremented by 1 per processing, which is repeated until
the counter becomes zero. The BNE (branch if not zero) instruction is
used to loop unless zero.
MOV.B R0L,@RESULT
Since the minimum data is stored in the R0L register after being compared
9 times, it is written to the RESULT address.
MIN: CMP.B R0H,R0L
In the first instruction of a subroutine, specify its name.
MIN is the name of the subroutine and:
JSR @MIN
is used to jump to it.
BLE RETURN
This subroutine compares the contents of the R0H and R0L registers assuming
them to be signed and puts the smaller in the R0L register.
If the contents of R0L are equal to or smaller than as a result of comparison,
processing is returned from the subroutine without any operation. As a
conditional test instruction, use the one assuming data to be signed.
RTS
Instruction to return from a subroutine.
DATA.B 99,0,-5,39,-2,68,-16,5,20
Defines 8-bit data. DATA.B is mainly used to represent data in the ROM.
|