1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-11-01 05:05:32 +00:00
millfork/include/m6502/stdlib_6502.mfk

55 lines
877 B
Plaintext
Raw Normal View History

// target-independent things
#if not(ARCH_6502)
#warn stdlib_6502 module should be only used on 6502-compatible targets
#endif
word nmi_routine_addr @$FFFA
word reset_routine_addr @$FFFC
word irq_routine_addr @$FFFE
macro asm void poke(word const addr, byte register(a) value) {
! STA addr
}
macro asm byte peek(word const addr) {
! LDA addr
}
macro asm void disable_irq() {
SEI
}
macro asm void enable_irq() {
CLI
}
asm byte hi_nibble_to_hex(byte register(a) value) {
LSR
LSR
LSR
LSR
2018-12-19 18:01:53 +00:00
? JMP lo_nibble_to_hex
}
asm byte lo_nibble_to_hex(byte register(a) value) {
! AND #$F
CLC
ADC #$30
CMP #$3A
BCC _lo_nibble_to_hex_lbl
ADC #$6 // carry is set
_lo_nibble_to_hex_lbl:
2018-12-19 18:01:53 +00:00
? RTS
}
macro asm void panic() {
? JSR _panic
}
2019-07-26 22:58:10 +00:00
const array __constant8 = [8]
#if ZPREG_SIZE < 4
const array call = [2]
#endif