





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The instruction cycle in computer processing, which involves fetching instructions from memory, decoding them, executing them, and handling interrupts. It also covers Python control structures, such as FOR and WHILE loops, and the concept of a call stack in function calls. call types, including call by value and call by reference, and recursive functions.
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!
stored in the program counter (PC) and is stored in theinstruction register (IR). The PC is incremented.
the PC is reset and the cycle ends. Otherwise, anyrequired data is fetched from main memory and isplaced in data registers.
from registers, performing arithmetic or logicalfunctions on them, and writing the result into a register.
output device.
Function calls are coordinated using a
call stack
Each function call generates a
stack frame
that stores
its arguments, local variables, space for return values,and a return address. When
f
calls
g
, a
g
-frame is initialized and control is
transferred to the first instruction of
g
When
g^
returns, execution of
f
resumes at the
g
return
address. Nested function calls are handled by processing stackframes in first-in first-out order (FIFO).
drawline
arguments local variables^ return value return address
drawbox
arguments local variables^ return value return address
recursive
function contains calls to itself in its body.
These calls are regular function calls. The programmer must ensure that the calls terminate. Example: compute
1 + 2 +
· · ·
n
def sum (n):
if
n == 1:
return
return
n +
sum(n - 1)
Base case
of
n
= 1
has no recursion.
Recursive calls terminate because
n
decreases.
sum(1)
local variable:
n
= 1
return value: 1
return address:
<
sum(2)
sum(2)
local variable:
n
= 2
return value:
2 + sum(1)
return address:
<
sum(3)
sum(3)
local variable:
n
= 3
return value:
3 + sum(2)
return address:
<
sum(4)
sum(4)
local variable:
n
= 4
return value:
4 + sum(3)
return address:
<
main