Byte Disassembly
Purpose:
To divide the 8-bit (i.e. 1 byte) variable value at location 6000 into two 4-bit nybbles (a nybble is a half byte i.e. 4 bits) and store one nybble in each byte of a 16-bit variable result at location 6002. The low-order four bits of the byte will be stored in the low-order four bits of the least significant byte of result. The high-order four bits of the byte will be stored in the low-order four bits of the most significant byte of result.
Sample Test Data:
input: value: (6000) = 5f
output result: (6002) = 050f
Source Code:
data | equ | $6000 | |||
program | equ | $4000 | |||
org | data | ||||
mask | equ | $000f | ;mask for lower nybble | ||
value | ds.b | 1 | ;byte to be disassembled | ||
ds.b | 1 | ;align result on word boundary | |||
result | ds.w | 1 | ;storage for disassembled byte | ||
org | program | ||||
move.b | value, d0 | ;get byte to be disassembled | |||
and.b | #mask,d0 | ;isolate lower nybble of byte | |||
move.b | do, result + 1 | ;save lower order nybble | |||
move.b | value, d0 | ;get byte to be disassembled | |||
lsr.b | #4, d0 | ;isolate high nybble | |||
move.b | d0, result | ;save high order nybble | |||