In: Computer Science
Hand assemble the following unconditional BRA instruction: HERE BRA HERE. Remember to show your work including the branch calculation. (Motorolla 68k)
Greetings!!
BRA instruction is an unconditional branch instruction which stands for Branch Always.
HERE BRA HERE instruction is equivalent to NOP since it loops on the same label itself.
Assume that a given set of instructions are givenL
ORG $2000
LDAB #5
ABA
STAA $0000
LDAA #2
STAA $0001
HERE BRA HERE
After loading to memory it looks like:
ORG $2000
$2000 LDAB #5
$2002 ABA
$2003 STAA $0000
$2005 LDAA #2
$2007 STAA $0001
$2009 HERE BRA HERE
Opcode for this instruction is 20 and it loops to PC+offset and in this case, PC is 200B at the time of executing this instruction and hence to loop back to the address 2009, the offset should be -2 and which is represented as FE. Hence the machine code of this instruction would be 20 FE.
Hope this helps