Copying Pointers in Program 4

Copying Pointers in Program 4 - Copying Pointers in Program...

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

View Full Document Right Arrow Icon
Copying Pointers in Program 4 The Problem In program 4 you have to copy the value of a pointer from on memory location to another in several places in your code: In the push function you need to copy the current stack end and top frame pointers into the middle of the new stack frame being built. In the pop function you need to copy those same pointers in the reverse direction, i.e., retrieve them from the middle of the frame being popped and copy them back to the process memory stack en and top frame pointers. In the print function you need to be able to retrieve them from the frame so that you can print them. All of the pointers specified in the problem statement are pointers to the defined type byte . This makes copying pointers into and out of the stack frames complicated because the objects you want to copy are pointers (i.e., 4-byte objects) while the pointers themselves are pointers to byte (i.e., pointers to 1-byte objects). For example, suppose your push function had a local variable of type pointer to byte in which you calculate the address in the new stack frame where the back pointers are supposed to go. For example, byte *clerical_area; clerical_area = stack_end + 4*number_of_parameters; Your first thought might be to use a statement like the following to copy the current stack
Background image of page 1

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

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

This note was uploaded on 10/14/2009 for the course EECS 346 taught by Professor Henchen during the Winter '09 term at Northwestern.

Page1 / 3

Copying Pointers in Program 4 - Copying Pointers in Program...

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