Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Encode the instructions in the following assembly language program fragment into

ID: 3851747 • Letter: E

Question

Encode the instructions in the following assembly language program fragment into 8086-family machine code. Assume first instruction is placed starting at an offset address of 0000h. Show the methodology of converting each instruction. Checking your work with a listing file is permissible. Mov bh, 0 Sub si, 6a Mov di, 23 cdh Add cx, 16f Label1: Mov al, [si] Or al, 30h Cmp bh, 1 Jz Label3 Test al, 36h Jnz Label2 Mov al, ' ' Jmp Label3 Label2: Mov bh, 1 Label3: Mov [di], al Dec si Dec byte ptr [di] Cmp cx, 3d Jle Label4 Mul di Label4: Loop Label1

Explanation / Answer

000h: b7 00 mov bh,0x0
002h: 66 83 ee 6a sub si,0x6a
006h: 66 8b 3d 00 00 00 00 mov di,WORD PTR ds:0x0
00dh: 66 81 c1 6f 01 add cx,0x16f
00000012 <Label1>:
012h: 67 8a 04 mov al,BYTE PTR [si]
015h: 0a 05 00 00 00 00 or al,BYTE PTR ds:0x0
01bh: 80 ff 01 cmp bh,0x1
01eh: 74 0a je 2a <Label3>
020h: a8 36 test al,0x36
022h: 75 04 jne 28 <Label2>
024h: b0 20 mov al,0x20
026h: eb 02 jmp 2a <Label3>
00000028 <Label2>:
028h: b7 01 mov bh,0x1
0000002a <Label3>:
02ah: 67 88 05 mov BYTE PTR [di],al
02dh: 66 4e dec si
02fh: 67 fe 0d dec BYTE PTR [di]
032h: 66 83 f9 3d cmp cx,0x3d
036h: 7e 03 jle 3b <Label4>
038h: 66 f7 e7 mul di
0000003b <Label4>:
03bh: e2 d5 loop 12 <Label1>