""" 
Video Tutorial
https://www.youtube.com/watch?v=Rfq8MK6kUL0
"""
print('''--- section 1 ---''')
### Section 1: ###

# number bases 

# base 10, day to day operations, 0 - 9 

 # base 2, 0 - 1, 0 == False 1 == True, boolean 

# 5 --> binary = (101)
# use the powers of 2^
# work right to left 
# start top sequence with 0, represents 2^

'''
5-(4) = 1 # 4 = 2^2, biggest power of 2 of the number 
1 - (1) = 0 # 1 = 2^0

101 binary 
'''
 # baase 3, 
 # base 4, 
# hexidecimal, 16 characters 
## 0123456789ABCDEF
## A = 1010 = 1010'10'
## 0 = 0000 = '0'

# octaldecimal, 8 characters 
## 

''' what is the stack of a CPU'''
# what is the stack of a cpu? 

## stacks need: ##
# push, pop 
# stack data is stored in RAM 
# Stack Pointer: keeps track of the address of the top of the stack.

# typically the stack grows down from the higher memnory addresses.

## a minimal stack ##
# stack needs to store data: RAM 
# stack needs to keep track of the top of the stack: Stack Pointer 
# stack needs fucntionality to push and pop: PUSH and POP

# push, push value decrement pointer 
# pop, copy value increment pointer

## most common use cases ##
# temporarily store variables 
# return address from a subroutine 
# storage of registers and CPU state while handling an interrupt
# allocation of local variables for a subroutine

''' CPU interrupts''' 
# what is an interrupt? 

# interrupts are commonly generated by perihperals 'keyboard' who needs to alert the CPU that some work needs to be done, e.g. a key has been pressed and needs to be handled
# when an interrupt occurs, the current state of the processor is saved on the stack, and execution continues at the address of the interrupt handler
# after the handler completes, the procesor state is popped off the stack and execution and resumes like nothign ever happened

# most CPU's have a lookup table: interrupt vector table, array of pointers to interrupts
# when, interrupt #2 occurs, the address of the handler is looked up in the interrupt vector table
# trypically stored in different types of RAM

