IA-32 Assembly: Instruction Analysis and Macro Development, Exams of Computer Architecture and Organization

Assembly code examples and exercises for ia-32 architecture, focusing on instruction analysis, macro development, and floating-point operations. Topics include stack pointer manipulation, procedure calls, local variables, and floating-point coprocessor instructions.

Typology: Exams

2011/2012

Uploaded on 05/18/2012

koofers-user-u8h
koofers-user-u8h 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ã
2003 University of Illinois at Chicago ECE 267 V. Goncharoff
ECE 267 ME2 Practice Problems
1. Which of the following instructions does not change the stack pointer register contents?
(one correct answer)
a) push ebx
b) ret
c) mov [ebx],al
d) call Procedure1
2. Which of the following is false?
(one correct answer)
a) LOCAL directive used in procedures creates stack frames
b) LOCAL directive used in macros generates unique label names
c) USES directive causes push/pop instructions to be inserted in the procedure code
d) USES directive specifies which registers are being accessed within the procedure
e) none of the above
3. Assume that register EAX stores a value in REAL4 binary code. Write one or more
instructions that replace this value with its absolute value, also in REAL4 code:
4. EAX stores some bit pattern. We then execute instruction "sar eax,1". Write a single
instruction that restores EAX to its original state:
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download IA-32 Assembly: Instruction Analysis and Macro Development and more Exams Computer Architecture and Organization in PDF only on Docsity!

ECE 267 ME2 Practice Problems

  1. Which of the following instructions does not change the stack pointer register contents? (one correct answer)

a) push ebx b) ret c) mov [ebx],al d) call Procedure

  1. Which of the following is false? (one correct answer)

a) LOCAL directive used in procedures creates stack frames b) LOCAL directive used in macros generates unique label names c) USES directive causes push/pop instructions to be inserted in the procedure code d) USES directive specifies which registers are being accessed within the procedure e) none of the above

  1. Assume that register EAX stores a value in REAL4 binary code. Write one or more instructions that replace this value with its absolute value, also in REAL4 code:
  2. EAX stores some bit pattern. We then execute instruction "sar eax,1". Write a single instruction that restores EAX to its original state:
  1. Without using mul or imul instructions, write some code that replaces the signed integer N in EAX with - 7 ¥ N :
  2. Write at most three lines of code that multiply the REAL4 code in EAX by 0.25, without using any floating point coprocessor instructions:
  3. Given: a value is stored at address X in REAL4 format. Write some instructions using the

FPU that replace this value with X -^3 :

  1. Rewrite the following procedure code without using the "LOCAL" directive:

Procedure1 PROC LOCAL Array[16]:DWORD mov Array[12],- mov Array[60],ebx call Procedure ret Procedure1 ENDP

  1. Write a macro named "mShow_ESP" that displays the contents of the ESP register in hex. You may call the author's WriteHex and Crlf procedures. (No registers should be changed as a result of invoking this macro.)
  1. Rewrite the code below without using the .IF directive:

.IF (AL >= -1) && (AL < 100) mov AL, .ENDIF

  1. Assuming that X has been previously defined and initialized as REAL4, write lines of IA- code that perform the following calculation using FPU instructions:

X

X

X

  1. Write IA-32 assembly language instructions that define macro "mShow_Carry" that displays the carry bit using either character '0' or character '1'. The flags register is not to be changed as a result of invoking this macro.
  2. Write IA-32 assembly language instructions that define macro "mFloat_Div", which divides fnum by fden and places the result in fresult (all three parameters are labels to memory locations that store 32-bit floating point codes). Here is an example of how the macro is invoked:

mFloat_Div fnum, fden, fresult

  1. Translate the following into regular lines of assembly language code, without using the "LOCAL" directive:

Procedure1 PROC LOCAL Array[256]:DWORD . . . mov eax,Array[10] . . . ret Procedure1 ENDP

  1. Translate the following into regular lines of assembly language code, without including the "USES" directive:

Procedure2 PROC USES eax ecx . . . . ret Procedure2 ENDP

  1. What do the following IA-32 floating-point coprocessor instructions accomplish?

finit fld X fld X fld X fld X fmul fdiv fadd fstp X

a) X3 ¨ X2 + 1/X b) X3 ¨ 2.0X c) X3 ¨ X1 + 1/X d) X3 ¨ 2.0X

  1. Given: register EAX initially stores a 32-bit floating-point code. Which of the following blocks of code multiplies the number by 4.0? Assume that no overflow occurs.

a) shl eax,2^ b) mov ebx, mul ebx

c) ror eax, add eax, rol eax,

d) mov X,eax fmul 4. mov eax,X

  1. Rewrite the following procedure code without using the "LOCAL" directive:

Procedure1 PROC LOCAL Array[16]:DWORD mov eax,Array[0] mov ebx,Array[7] call Procedure ret Procedure1 ENDP