Test2soln-3750-F08

Test2soln-3750-F08 - EE 3750 Test 2 solutions 1 EE 3750...

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

View Full Document Right Arrow Icon
EE 3750 — Test 2 solutions 1 EE 3750 — Test 2 solutions Fall 2008 1. (20 pts) Write an 8086 instruction sequence to find the position of the second rightmost 1 bit in register DX. Store the position of this bit in word variable second . (Assume that the value in DX contains at least two 1’s.) MOV CX, 16 ; initialize loop counter TAG: TEST DX, 1 ; test whether LSB is a 1 JNZ FOUND1 ; if it is a 1, then jump to look for second 1 SHR DX, 1 ; shift next bit into LSB position LOOP TAG ; will not exit this loop with CX = 0 because of assumption that DX contains at least two 1’s FOUND1: SHR DX, 1 ; update to next bit position following first 1 DEC CX TAG2: TEST DX, 1 JNZ FOUND2 ; if bit is a 1, then this is the second 1 SHR DX, 1 LOOP TAG2 ; will not exit this loop with CX = 0 because of assumption that DX contains at least two 1’s FOUND2: MOV SECOND, 16 SUB SECOND, CX ; the second 1 is in position 16 CX
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE 3750 — Test 2 solutions 2 2. (30 pts) Write a complete 8086 procedure AVG to do the following. Given a byte
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the 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 / 3

Test2soln-3750-F08 - EE 3750 Test 2 solutions 1 EE 3750...

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

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