Question
Show how to add the following two 64 bits of data using 8088/8086 assembly programming . The final answer must be located at CX-DX combination. Then show the final value of CF,PF,ZF,SF and AF flags.
X=4322FFFFh
Y=43210001h
Answer:
CX DX
+ AX BX
------------
CX DX
------------
DX+BX can be done using the normal ADD DX,BX. However DX + BX might have a carry result that should be added to the following CX+AX. Therefore to ensure the carry bit (if there is a carry) is added to the following segment ADC (ADD with Carry) must be used.
So the code for this program will be
ADD DX,BX
ADC CX,AX
4322FFFF16= 0100 0011 0010 0010 1111 1111 1111 11112
4321000116 = 0100 0011 0010 0001 0000 0000 0000 00012
0100 0011 0010 0010 1111 1111 1111 1111
+0100 0011 0010 0001 0000 0000 0000 0001
-------------------------------------------------
1000 0110 0100 0100 0000 0000 0000 0000 = 8644000016
-------------------------------------------------
Therefore (check the second set/second command/ADC only)
SF=1 (the sign bit is number 1)
CF=0 (no carry)
PF=0 (number of 1 is odd)
ZF=0 (result not zero)
AF = 0 (there is carry from bit 3 to bit 4)
Bila dunia didagangkan
-
Alangkah indahnya... jika dunia dapat diperdagangkan untuk akhirat... bila
setiap rezeki diletakkan kembali kepada jalan yang hak.. bila setiap rezeki
yg h...
11 years ago
No comments:
Post a Comment