Docsity

4 Solved Questions in Assignment 2 on Microprocessor System | EE 3750, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EE 3750 โ€” HW 2 solutions 1
EE 3750 โ€” Homework 2 solutions
Fall 2009
1. Write an 8086 instruction sequence to subtract BX and DX from SI and then divide
the result by CH. Assume that all numbers are signed binary integers. The final quotient must
be an 8-bit number stored in the AL register, and all registers other than AX (that is, AH and AL)
should hold the same contents at the end of the sequence as they held at the beginning of the
sequence.
MOV AX, SI ; only AX can change, so manipulate in AX
SUB AX, BX
SUB AX, DX
IDIV CH ; quotient of AX/CH is in AH
2. Given the register and memory contents listed below, list the changed registers and
memory locations and their contents after each instruction below executed in sequence.
Contents: All integers in this problem are written in hexadecimal. Let AX = 2204, BX =
1230, CX = 1E36, DX = 7A95, SI = 4488, DI = 8B14, SP = 386, SS = A000, ES = 5000, and DS
= 8000. Let DF = 0, contents of the word pointed to by DS:[SI] = 45A6, contents of the word
pointed to by DS:[SI+8] = 8086, and let each other byte in memory hold 3C.
SUB CX, AX
SBB DX, BX
LEA BX, [SI+8]
MOVSB
PUSH AX
POP DI
SUB CX, AX : CX โ† FC32
SBB DX, BX : DX โ† 6864 (note that CF was 1 because of the borrow during
the SUB instruction)
LEA BX, [SI+8] : BX โ† 4490
MOVSB : byte in memory at physical address 58B14 (5000:8B14) โ† A6;
DI โ† 8B15; SI โ† 4489
PUSH AX : SP โ† 384;
top of stack at physical address A0384 (A000:384) โ† 2204
POP DI : DI โ† 2204; SP โ† 386
pf3

Partial preview of the text

Download 4 Solved Questions in Assignment 2 on Microprocessor System | EE 3750 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EE 3750 โ€” Homework 2 solutions

Fall 2009

  1. Write an 8086 instruction sequence to subtract BX and DX from SI and then divide the result by CH. Assume that all numbers are signed binary integers. The final quotient must be an 8-bit number stored in the AL register, and all registers other than AX (that is, AH and AL) should hold the same contents at the end of the sequence as they held at the beginning of the sequence. MOV AX, SI ; only AX can change, so manipulate in AX SUB AX, BX SUB AX, DX IDIV CH ; quotient of AX/CH is in AH
  2. Given the register and memory contents listed below, list the changed registers and memory locations and their contents after each instruction below executed in sequence. Contents: All integers in this problem are written in hexadecimal. Let AX = 2204, BX = 1230, CX = 1E36, DX = 7A95, SI = 4488, DI = 8B14, SP = 386, SS = A000, ES = 5000, and DS = 8000. Let DF = 0, contents of the word pointed to by DS:[SI] = 45A6, contents of the word pointed to by DS:[SI+8] = 8086, and let each other byte in memory hold 3C. SUB CX, AX SBB DX, BX LEA BX, [SI+8] MOVSB PUSH AX POP DI SUB CX, AX : CX โ† FC SBB DX, BX : DX โ† 6864 (note that CF was 1 because of the borrow during the SUB instruction) LEA BX, [SI+8] : BX โ† 4490 MOVSB : byte in memory at physical address 58B14 (5000:8B14) โ† A6; DI โ† 8B15; SI โ† 4489 PUSH AX : SP โ† 384; top of stack at physical address A0384 (A000:384) โ† 2204 POP DI : DI โ† 2204; SP โ† 386
  1. In 2006, K. Roy developed an algorithm to use a reconfigurable mesh to route packets in a switch connecting input ports to output ports. Part of this algorithm checks for each input port if a high load at the input port matches a low load at the corresponding output port. If so, then the corresponding reconfigurable mesh processor sets itself in Configuration 1 (connect north to south); if not, then the processor sets itself in Configuration 2 (connect east to west). The pseudocode below describes a portion of the simulator of this reconfigurable mesh. Write an assembly language instruction sequence to implement this pseudocode. Assume that all variables are word variables. if stage = 1 then for i โ† 0 to numprocs โˆ’ 1 if inputloadi > 0 and outputloadi < 3 then configi โ† 1 else configi โ† 2 CMP STAGE, 1 JNE AFTER MOV SI, 0 ; use SI as pointer into arrays MOV DX, NUMPROCS ADD DX, DX ; DX holds 2* numprocs ; this is the value that SI will reach after being increased at the end of the last iteration of the for loop TOP: CMP INPUTLOAD[SI], 0 JNA ELSE ; condition not satisfied ; I am treating these numbers as unsigned, since they were unsigned in the original algorithm. Because the problem does not specify whether they are signed or unsigned, you may also treat them as signed CMP OUTPUTLOAD[SI], 3 JNB ELSE ; condition not satisfied MOV CONFIG[SI], 1 ; then case; both conditions satisfied JMP NEXT ; skip over the else case ELSE: MOV CONFIG[SI], 2 NEXT: ADD SI, 2 ; update pointer CMP SI, DX ; decide whether to continue iterating in the for loop JB TOP AFTER: