My Sweet Home

Tugas 5

4. If AX = 1001H and DX = 20FFH, list the sum and the contents of each flag register bit (C, A, S. Z,and O) after the ADD AX,DX instruction executes.
Answer:
AX = 1001H
BX = 20FFH
+
3100H
C = 0, A = 1, S = 0, Z = 0, O = 0

5. Develop a short sequence of instructions that adds AL, BL, CL, DL, and AH. Save the sum in the DH register.
Answer:
ADD BL,AL
ADD CL,BL
ADD DL,CL
ADD AH,DL
MOV DH,AH

11. Select a SUB instruction that will:
(a) substract BX from CX
(b) substract 0EEH from DH
(c) substract DI from SI
(d) substract 3322H from EBP
(e) substract the data address by SI from CH
(f) substract the data stored 10 words after the location addressed by SI from DX
(g) substract AL from memory location FROG


Answer:
(a) SUB CX,BX
(b) SUB DH,0EEH
(c) SUB SI,DI
(d) SUB EBP,3322H
(e) SUB CH,[SI]
(f) SUB DX,[SI+10]
(g) SUB FROG,AL

33. Develop a sequence of instructions that converts the unsigned number in AX (values of 0-65535) into a 5-digit BCD number stored in memory, beginning at the location addressed by the BX register in data segment. Note that the most-significant character is stored first and no attempt is made to blank leading zeros.
Answer:
XOR DX,DX
MOV CX,1000H
DIV CX
AAM
MOV [BX],CX
MOV AX,DX
XOR DX,DX
MOV CX,100H
DIV CX
AAM
MOV [BX+2],AX
XCHG AX,DX
AAM
MOV [BX+4],AX
author

a wife, a mom, a blogger, a survivor of ITP & Lupus, a writer, author, a counselor of ITP & Lupus autoimmune, a mompreuneur, a motivator, a lecturer.