My Sweet Home

Tugas 2

14.Find the memory address of the next instruction executed by the microprocessor, when operated in the real mode, for the following CS:IP combination:
(a) CS : 1000H and IP : 2000H
(b) CS : 2000H and IP : 1000H
(c) CS : 2300H and IP : 1A00H
(d) CS : 1A00H and IP : B000H
(e) CS : 3456H and IP : ABCDH
Answer :
(a) CS = 1000H → 10000H
IP = 2000H → 2000H +
Memory address = 12000H
(b) CS = 2000H → 20000H
IP = 1000H → 1000H +
Memory address = 21000H
(c) CS = 2300H → 23000H
IP = 1A00H → 1A00H +
Memory address = 24A00H
(d) CS = 1A00H → 1A000H
IP = B000H → B000H +
Memory address = 25000H
(e) CS = 3456H → 34560H
IP = ABCDH → ABCDH +
Memory address = 3F12DH
24.What is the purpose of the segment register in protected mode memory addressing?
Answer :
The purpose of the segment register in protected mode memory addressing is :
(a) to access the memory segment.
(b) the segment register contains a selector that selects a descriptor from a local or global descriptor table. The descriptor describes the memory segment’s location, length, and access rights. The segment register contains requested privilege level field too.
28.For a Pentium 4 descriptor that contains a base address of 00280000H, a limit of 00010H and G = 1, what starting and ending locations are addressed by this descriptor?
Answer :
Base = Start = 00280000H
G = 1
End = Base + Limit = 00280000H + 00010FFFH = 00290FFFH
32.What is the maximum length of the global descriptor table in Pentium 4 microprocessor?
Answer :
The maximum length of the global descriptor table in Pentium 4 microprocessor is 64K bytes.
36.How is the local descriptor table addressed in the memory system?
Answer :
- The local descriptor table is addressed into LDTR (Local Descriptor Table Register). To access the local descriptor table, the LDTR is loaded with a selector, just as a segment registers is loaded with a selector.
- In order to access and specify the address of these tables, the 80286-Pentium 4 contain program invisible registers. The program invisible registers are not directly addressed by software so they are given this name (although some of these registers are accessed by the system software).


8.Select an instruction for each of the following tasks :
(a) copy EBX into EDX
(b) copy BL into CL
(c) copy SI into BX
(d) copy DS into AX
(e) copy AL into AH
Answer :
Operation Assembly Language
(a) copy EBX into EDX MOV EDX,EBX
(b) copy BL into CL MOV CL,BL
(c) copy SI into BX MOV BX,SI
(d) copy DS into AX MOV AX,DS
(e) copy AL into AH MOV AH,AL

9.Select an instruction for each of the following tasks :
(a) move 12H into AL
(b) move 123AH into AX
(c) move 0CDH into CL
(d) move 1200A2H into EBX
Answer :
Operation Assembly Language
(a) move 12H into AL MOV AL,12H
(b) move 123AH into AX MOV AX,123AH
(c) move 0CDH into CL MOV CL,0CDH
(d) move 1200A2H into EBX MOV EBX,1200A2H

21.Suppose that DS = 0200H, BX = 0300H, and DI = 400H. Determine the memory address accessed by each of the following instruction, assuming real mode operations :
(a) MOV AL,[1234H]
(b) MOV EAX,[BX]
(c) MOV [DI],AL
Answer :
(a) Address Generation = DS x 10H + 1234H
= 200H x 10 + 1234H
= 2000H + 1234H
Memory Address = 3234H
(b) Address Generation = DS x 10H + BX
= 200H x 10 + 0300H
= 2000H + 0300H
Memory Address = 2300H
(c) Address Generation = DS x 10H + DI
= 200H x 10 + 400H
= 2000H + 400H
Memory Address = 2400H
33.Suppose that EAX = 00001000H, EBX = 00002000H, and DS = 0010H. Determine the addresses accessed by the following instruction, assuming real mode operation :
(a) MOV ECX,[EAX+EBX]
(b) MOV [EAX+2*EBX],CL
(c) MOV DH,[EBX+4*EAX+1000H]
Answer :
(a) Address Generation = DS x 10H + EAX + EBX
= 00000100H + 00001000H + 00002000H
Memory Address = 00003100H
(b) Address Generation = DS x 10H + EAX + 2 x EBX
= 00000100H + 00001000H + 00004000H
Memory Address = 00005100H
(c) Address Generation = DS x 10H + EBX + 4 x EAX + 1000H
= 00000100H + 00002000H + 00004000H + 00001000H
Memory Address = 00007100H
43.Show which JMP instruction assembles (short, near, or far) if the JMP THERE instruction is stored at s address 10000H and the address of THERE is :
(a) 10020H
(b) 11000H
(c) 0FFFEH
(d) 30000H
Answer :
(a) 10020H
10000H
00020H → 0000 0000 0000 0010 0000
1 byte
1 byte displacement → short jump

(b) 11000H
10000H
01000H → 0000 0001 0000 0000 0000
2 byte
2 byte displacement → near jump

(c) 0FFFEH
10000H
2H→ 0000 0010
1 byte
1 byte displacement → short jump

(d) 30000H
10000H
20000H → 0000 0010 0000 0000 0000 0000
3 byte
3 byte displacement → far jump


18.Describe the operation of each of the following instructions:
(a) PUSH AX
(b) POP ESI
(c) PUSH [BX]
(d) PUSHFD
(e) POP DS
(f) PUSHD 4
Answers:
(a) The PUSH AX instruction pushes the contents of AX onto the stack or AX is copied to the stack
(b) The POP ESI instruction removes a 32-bit number from the stack and places it into ESI or A 32-bit number is retrieved from the stack and placed into ESI.
(c) The PUSH [BX] instruction pushes the 16-bit contents of the data segment memory location addressed by BX onto the stack or the word contents of the data segment memory location addressed by BX is pushed into the stack.
(d) The PUSHFD instruction pushes the EFLAGS register onto the stack
(e) The POP DS instruction removes a 16-bit number from the stack and places it into the DS register or A word is retrievied from the stack and placed into DS.
(f) The PUSHD 4 instruction places a 32-bit number 4 onto the stack.

60.Develop a near procedure that stores AL in four consecutive memory locations, within the data segment, as addressed by the DI register.
Answers:
STORE PROC NEAR
MOV [DI],AL
MOV [DI+1],AL
MOV [DI+2],AL
MOV [DI+3],AL
STORE ENDP


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


12.Contrast the operation of a JMP [DI] with a JMP FAR PTR [DI].
Anwer:
The JMP [DI] instruction jumps to the memory location addressed by the offset addresse stored in the data segment memory location addressed by DI. The JMP PTR [DI] instruction jumps to the new offset address stored in the data segment memory location addressed by DI and the new segment addressed by data segment memory location address by DI+2. JMP [DI] is a near jump and JMP FAR PTR [DI] is a far jump.

26.Show the assembly language instructions generated by the following sequence:
Anwer:
.IF AL= =3
ADD AL,2
.ENDIF
Answer:
CMP AL,3
JNE @C0001
ADD AL,2
@C0001:

28.Develop a short sequence of instructions that uses the REPEAT-UNTIL construct to copy the contents of byte-sized memory BLOCKA into byte-sized memory BLOCKB until 00H is moved.
Answer :
MOV SI,OFFSET BLOCKA
MOV SI,OFFSET BLOCKB
CLD
.REPEAT
LODSB
STOSB
.UNTIL AL = = 0
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.