Q. A system is designed to monitor the temperature of a furnace. Ten temperature readings
are recorded in 16 bits and stored in memory locations starting at D050H. The higher
order byte is stored first and the low order byte is stored in the next consecutive memory
location. The high-order byte of all the temperature readings is constant. Write a program
to transfer the low-order readings to the consecutive memory locations starting at E060H
and discard the high-order bytes.
Solution:
LXI H, D051H ; the lower reading is at higher address as per the question
LXI D, E060H ; new location for lower reading
MVI C, 0AH ; count for ten readings
LABEL1: MOV A, M
STAX D
INX H ; skip the higher reading by increasing the address twice
INX H
INX D
DCR C
JNZ LABEL1
HLT
are recorded in 16 bits and stored in memory locations starting at D050H. The higher
order byte is stored first and the low order byte is stored in the next consecutive memory
location. The high-order byte of all the temperature readings is constant. Write a program
to transfer the low-order readings to the consecutive memory locations starting at E060H
and discard the high-order bytes.
Solution:
LXI H, D051H ; the lower reading is at higher address as per the question
LXI D, E060H ; new location for lower reading
MVI C, 0AH ; count for ten readings
LABEL1: MOV A, M
STAX D
INX H ; skip the higher reading by increasing the address twice
INX H
INX D
DCR C
JNZ LABEL1
HLT
Comments
Post a Comment