2018-07-12 16:30:35 +00:00
|
|
|
// 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
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
macro asm void poke(word const addr, byte register(a) value) {
|
2018-12-16 20:07:04 +00:00
|
|
|
! STA addr
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro asm byte peek(word const addr) {
|
2018-12-16 20:07:04 +00:00
|
|
|
! LDA addr
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void disable_irq() {
|
|
|
|
SEI
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void enable_irq() {
|
|
|
|
CLI
|
|
|
|
}
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
asm byte hi_nibble_to_hex(byte register(a) value) {
|
2018-07-12 16:30:35 +00:00
|
|
|
LSR
|
|
|
|
LSR
|
|
|
|
LSR
|
|
|
|
LSR
|
2018-12-19 18:01:53 +00:00
|
|
|
? JMP lo_nibble_to_hex
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 17:23:48 +00:00
|
|
|
asm byte lo_nibble_to_hex(byte register(a) value) {
|
2018-12-16 20:07:04 +00:00
|
|
|
! AND #$F
|
2018-07-12 16:30:35 +00:00
|
|
|
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
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void panic() {
|
2018-12-16 20:07:04 +00:00
|
|
|
? JSR _panic
|
2018-07-12 16:30:35 +00:00
|
|
|
}
|
|
|
|
|
2019-07-26 22:58:10 +00:00
|
|
|
const array __constant8 = [8]
|
|
|
|
|
|
|
|
#if ZPREG_SIZE < 4
|
|
|
|
const array call = [2]
|
|
|
|
#endif
|