How to sign extend a group of 8 bit numbers into 16 bits and store them in little endian format. For example I have following data in my memory location.
Address = Value
0001 = 03 [counter]
0002 = 05
0003 = 43
0004 = 8C
Results:
Address = Value
0005 = 05 \ 05 => 00 05
0006 = 00 /
0007 = 43 \ 43 => 00 43
0008 = 00 /
0009 = 8C \ 8C => FF 8C
000A = FF /
I'm currently stuck on the following code:
LXI D,0005H [memory location to store little endian]
LXI H,0001H
MOV C,M [initialize counter]
INX H [increment 1 and point to first data]
MOV A,M
CALL EXPAND
HLT
Expand: PUSH B
PUSH H
checkMSB: ANI 80H [Check the MSB to determine expand number whether is 00 or FF]
JZ SKIP
..... [still on process]
SKIP: STAX D [stuck at here]
INX H
MOV A,M
DCR C
JNZ checkMSB
POP H
POP B
HLT