Sample Exercises for Quiz 4

Data Structures, Subroutines, IEEE Floating Point

Describe how arrays and structs and unions are laid out internally.
Take into consideration overall size and alignment.
How can you reduce padding do to alignment restrictions in structs?

Describe how multi-dimensional arrays are laid out in memory in C/C++.
What advantage does using a traversal pointer to traverse an array have
especially in multi-dimensional arrays vs. using loops and array [] notation?

Describe the differences between open, closed, and leaf subroutines.  What
are the advantages and disadvantages of each?

What is recursion?

Describe the general calling convention of general CISC architectures with
regards to building and breaking down the Stack Frame, passing parameters,
etc.  Who (the calling function or the called function) is responsible for
building and breaking down the various parts of the Stack Frame? Caller
Pre-Call, Call instr, Callee Prologue, Callee Epilogue, Caller Post-Return

Describe the calling convention of the ARM architecture, in particular,
and how the ARM architecture does something similar.

Describe each of the following ARM instructions (what do they do?
what registers do they access/modify?).

	push  {register list}
	pop   {register list}
	bl    name
	sub   fp, sp, (# regs saved - 1) * 4
	add   sp, fp, (# regs saved - 1) * 4

Describe how you would pass more than 4 arguments to a function in the
ARM architecture.  How are they accessed from both the calling and the
called functions?

How do you allocate local variables on the Stack?
How are they accessed?

Why is it "a bad thing" to return a pointer to a local Stack variable? Why
are you "unlucky" if you do this and your program seems to work?

Describe the internal format for single- and double-precision IEEE floating
point values.

What is normalization?  Hidden bit operation?

Why is the stored binary exponent in biased/excess notation vs. the
real binary exponent?

Convert the following decimal values to single-precision IEEE floating
point representation (expressed in hex) showing the binary fixed-point
intermediate value __________ x 20.

13.75				0x415C0000
-99.125				0xC2C64000
-1.5				0xBFC00000
0.5				0x3F000000

Convert the following single-precision IEEE floating point representations
to fixed-point decimal values.

0x42060000			33.5
0xC22E8000			-43.625
0xBF400000			-0.75
0x42F68000			123.25

Rt-Lt Rule!