mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
vault backup: 2022-08-01 11:30:26
This commit is contained in:
parent
3928774584
commit
5c974b1fa6
@ -6,7 +6,7 @@ tags:
|
|||||||
- cosc204
|
- cosc204
|
||||||
---
|
---
|
||||||
|
|
||||||
10 addressing modes
|
# addressing modes
|
||||||
- implied `inca`
|
- implied `inca`
|
||||||
- immediate `lda #$00`
|
- immediate `lda #$00`
|
||||||
- extended `LDA $31FE`
|
- extended `LDA $31FE`
|
||||||
@ -25,6 +25,50 @@ tags:
|
|||||||
- program counter relative `LDA TABLE,PCR ; A = the value stored at TABLE`
|
- program counter relative `LDA TABLE,PCR ; A = the value stored at TABLE`
|
||||||
- if all memory references are relative, then the program cna be loaded anywhere is memory, and will still work. It is said to be **relocatable**
|
- if all memory references are relative, then the program cna be loaded anywhere is memory, and will still work. It is said to be **relocatable**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# Calling conventions
|
||||||
|
all global vars. this is discouraged in high level languages
|
||||||
|
|
||||||
|
The calling convention is the set of rules that describe
|
||||||
|
- How to pass parameters
|
||||||
|
- How to return a result
|
||||||
|
- Which registers a routine may alter
|
||||||
|
|
||||||
|
## CMOC
|
||||||
|
a 6809 C compiler
|
||||||
|
|
||||||
|
callling conventions
|
||||||
|
- A routine must preserve Y, U, S and DP
|
||||||
|
- A routine may change A, B, X and CC
|
||||||
|
|
||||||
|
- Parameters are pushed on the stack in the reverse order
|
||||||
|
- The caller pops them off the stack after the call
|
||||||
|
|
||||||
|
- char parameters are promoted to int
|
||||||
|
- unsigned char are promoted to unsigned int
|
||||||
|
|
||||||
|
- Return 8-but values in B
|
||||||
|
- Return 16-bit values in D
|
||||||
|
|
||||||
|
- We’re not going to talk about passing a struct by value
|
||||||
|
|
||||||
|
### example in C
|
||||||
|
|
||||||
|
``` c
|
||||||
|
uint16_t two_params(uint8_t first, uint16_t second) {
|
||||||
|
return first + second;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t call_one(void) {
|
||||||
|
return two_params(204, 431);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
LDD #$01AF ;
|
||||||
|
decimal 431 PSHS B,A ;
|
||||||
|
argument 2, int CLRA LDB #$CC ;
|
||||||
|
decimal 204 PSHS B,A ;
|
||||||
|
argument 1, int LBSR _two_params
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue
Block a user