Structured programming Flashcards

1
Q

How is a program started

A

pc starts at 0 and mem[0 contains a jump instuction to start of program in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is stored between 0 and the start of a program

A

constants globals and strinsg

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what does the stack store

A

local variables and support subroutine calls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what si the stack pointer

A

stores the memory location to the top of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how are subroutine calls performed using the stack

A

caller local variables and subroutine parameters pushed to the stack
(caller -> function which makes the call)
push the return address -> the address to go to after the subroutine
(ldap 1)
update the stack pointer
once returnvalue is calculated add it to the stack frame

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a subroutine end using the stack

A

stack pointer is updated (often incremented because the stack is often from high to low)

return address is oppped and used for a jump instruction
rest of the data is popped off

How well did you know this?
1
Not at all
2
3
4
5
Perfectly