T1reviewSoln-3750-S06

T1reviewSoln-3750-S06 - 61-7AH) with the ASCII code for ?...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EE 3750 —Test 1 review solutions 1 EE 3750 — Test 1 review solutions Spring 2006 Write an 8086 instruction sequence to first find the value of the minimum element of a 30 word array PURPLE of unsigned integers and store it in word variable MIN. Next, subtract that minimum value from each of the 30 elements. MOV AX, PURPLE ; initialize current min MOV CX, 30 ; loop count MOV BX, 0 ; pointer for array PURPLE TOP: CMP AX, PURPLE[BX] JBE NEXT ; JBE because integers are unsigned MOV AX, PURPLE[BX] ; if PURPLE[BX] is smaller than current min, then replace current min NEXT: ADD BX, 2 ; update pointer (word array) LOOP TOP MOV MIN, AX ; store minimum value MOV CX, 30 ; reinitialize loop count MOV BX, 0 ; reinitialize pointer for array PURPLE TAG2: SUB PURPLE[BX], AX ; AX holds min ADD BX, 2 LOOP TAG2 Use string instructions to copy an array of 47 bytes from an array starting at variable GREEN to an array starting at variable PURPLE. (Both GREEN and PURPLE are in the segment to which DS points.) Next, replace each byte that is not an ASCII code for a lowercase letter (a-z:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 61-7AH) with the ASCII code for ? (3FH). MOV AX, DS MOV ES, AX LEA DI, PURPLE MOV SI, OFFSET GREEN MOV CX, 47 REP MOVSB MOV CX, 47 MOV DI, 0 TAG: CMP PURPLE[DI], 61H JB REPLACE CMP PURPLE[DI], 7AH JA REPLACE JMP NEXT REPLACE: MOV PURPLE[DI], 3FH NEXT: INC DI LOOP TAG EE 3750 Test 1 review solutions 2 Write an instruction sequence to implement the steps below. All variables are byte variables holding signed integers. green red + 88 if green > 101 then green yellow else green ( green * red ) / yellow blue green MOV AL, RED ADD AL, 88 MOV GREEN, AL ; green red + 88 CMP GREEN, 101 JG THENC ; jump to then case; JG because signed MOV AL, GREEN ; begin else case IMUL RED ; product in AX IDIV YELLOW ; dividend in AX, quotient goes to AL MOV GREEN, AL JMP EXIT ; skip over then case THENC: MOV AL, YELLOW MOV GREEN, AL ; green yellow EXIT: MOV AL, GREEN MOV BLUE, AL ; blue green...
View Full Document

This note was uploaded on 01/25/2012 for the course EE 3750 taught by Professor Desouza during the Fall '08 term at LSU.

Page1 / 2

T1reviewSoln-3750-S06 - 61-7AH) with the ASCII code for ?...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online