test2Review4 - ebx . You must test for null (0) to know...

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

View Full Document Right Arrow Icon
CSE 2240 TEST 2 REVIEW 1. Write a single instruction that will flip the highest three bits in register DX . The other bits will remain unchanged. 2. Write a single instruction that will force the highest 3 bits of register al to zero without changing the value of the remaining bits. 3. Write a single instruction that will force the highest 5 bits of register al to one without changing the value of the remaining bits. 4. Show two different ways to take the 2’s complement of the value in register DX . 5. Write the instructions necessary to implement the following high-level control structure. Assume only signed values are being used. if (eax <= -13 && edi == 0) ecx = -ecx; else if (edx != 33) ebx = ebx - 7; 6. Given the following data segment: .data string db “Can you count the number of Cs correctly?”, 0 Write a code segment that will count the total number of occurrences of all C s (both lower-case ‘c’ and an upper case ‘C’) in string and store the total in register
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: ebx . You must test for null (0) to know when the end of string has been reached. 7. Translate the following C code into assembly language: int count = 0; while( count < arraySize) { if( array[count] < 100 ) sum1 = sum1 + array[count]; else sum2 = sum2 + array[count]; count++; } .data count DWORD array DWORD 50,120,100,40,8912,1234,77 arraySize = ($-array) / (TYPE array) sum1 DWORD sum2 DWORD 8. Show what the stack will look like when the program reaches label L1 in procedure sub2. 1 offsets 00000000 main proc 00000000 mov eax, 00000000h 00000005 push eax 00000007 call sub1 0000000C pop eax exit main endp 0000001A sub1 proc 0000001A mov eax, 11111111h 0000001F push eax 00000021 call sub2 00000026 pop eax 00000028 ret sub1 endp STACK 0000002C sub2 proc 0000002C mov eax, 22222222h 00000031 push eax 00000033 push eax 00000035 L1: 00000035 pop ebx 00000037 pop ecx 00000039 ret sub2 endp 2...
View Full Document

This note was uploaded on 04/05/2010 for the course CSE 2240 taught by Professor Staff during the Fall '08 term at Southern Methodist.

Page1 / 2

test2Review4 - ebx . You must test for null (0) to know...

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