Write HCl2 code that will do the following Put your code in
Write HCl2 code that will do the following Put your code in the blank lines following the comments. ORG $2000;Initialize the stack pointer to $2000;Initialize the X register to point to $1000;Exchange bytes in locations $1000: $1001 with bytes in $1004:$1005 (the 16 bit value is exchanged with the 16 bit value)
Solution
org $2000 ; Initialize the stack pointer to $2000
org $1000 ; Initialize the X register to point to $1000
ldd $802 ; place the lowest two bytes of the minuend in D
subd $806 ; subtract the lowest two bytes of the subtrahend from D
std $902 ; save the lowest two bytes of the difference
ldaa $801 ; put the second-to-most-significant byte of the minuend in A
sbca $805 ; subtract the second-to-most-significant byte of the
; subtrahend and the borrow from A
staa $901 ; save the second-to-most-significant byte of the difference
ldaa $800 ; put the most significant byte of the minuend in A
sbca $804 ; subtract the most significant byte of the subtrahend
; and the borrow from A
staa $900 ; save the most significant byte of the difference
end
