Tiny8 uses a byte-addressable memory model. The RAM size is configurable via the Memory(ram_size=...) parameter.
Default Configuration (2KB):
- Address range:
0x0000 to 0x07FF - Stack Pointer (SP) initialization:
0x07FF (the last address in RAM).
Memory Layout:
- Stack Area: Located at high memory; grows downward (towards
0x0000) as PUSH decrements the SP. - Data Area: Located at low memory; grows upward.
- Note: There are no fixed boundaries between stack and data; collisions can occur if they grow toward each other.
Memory Access Patterns:
Register-indirect addressing:
; Load from memory
ldi r26, 0x00 ; Set address low byte
ldi r27, 0x02 ; Set address high byte (address = 0x0200)
ld r16, r26 ; Load byte from address in R26 into R16
; Store to memory
ldi r26, 0x50 ; Address = 0x50
ldi r16, 42 ; Value to store
st r26, r16 ; Store R16 to memory[R26]
Stack Operations:
push r16 ; Push R16 onto stack (SP decrements)
pop r17 ; Pop from stack into R17 (SP increments)
call my_function ; Pushes return address, then jumps
ret ; Pops return address, then returns
I/O Operations:
in r16, 0x3F ; Read from I/O port 0x3F into R16
out 0x3F, r16 ; Write R16 to I/O port 0x3F