2020-04-27 10:40:49 +00:00
|
|
|
// target-independent things
|
|
|
|
|
|
|
|
#if not(ARCH_6809)
|
|
|
|
#warn stdlib_6809 module should be only used on 6809-compatible targets
|
|
|
|
#endif
|
|
|
|
|
2020-06-04 15:07:19 +00:00
|
|
|
import m6809/m6809_math
|
|
|
|
|
2020-04-27 10:40:49 +00:00
|
|
|
word nmi_routine_addr @$FFFC
|
|
|
|
word reset_routine_addr @$FFFE
|
|
|
|
word irq_routine_addr @$FFF8
|
|
|
|
word swi_routine_addr @$FFFA
|
|
|
|
word firq_routine_addr @$FFF6
|
|
|
|
word swi2_routine_addr @$FFF4
|
|
|
|
word swi3_routine_addr @$FFF2
|
|
|
|
|
|
|
|
macro asm void poke(word const addr, byte register(b) value) {
|
|
|
|
! STB addr
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm byte peek(word const addr) {
|
|
|
|
! LDB addr
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void disable_irq() {
|
|
|
|
ORCC #$30
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void enable_irq() {
|
|
|
|
ANDCC #$CF
|
|
|
|
}
|
|
|
|
|
2020-07-31 11:27:17 +00:00
|
|
|
asm byte hi_nibble_to_hex(byte register(b) value) {
|
2020-04-27 10:40:49 +00:00
|
|
|
LSRB
|
|
|
|
LSRB
|
|
|
|
LSRB
|
|
|
|
LSRB
|
|
|
|
? JMP lo_nibble_to_hex
|
|
|
|
}
|
|
|
|
|
2020-07-31 11:27:17 +00:00
|
|
|
asm byte lo_nibble_to_hex(byte register(b) value) {
|
2020-04-27 10:40:49 +00:00
|
|
|
! ANDB #$F
|
|
|
|
ADDB #$30
|
|
|
|
CMPB #$3A
|
2020-07-31 11:27:17 +00:00
|
|
|
BCS _lo_nibble_to_hex_lbl
|
2020-04-27 10:40:49 +00:00
|
|
|
ADDB #$7 // carry is set
|
|
|
|
_lo_nibble_to_hex_lbl:
|
|
|
|
? RTS
|
|
|
|
}
|
|
|
|
|
|
|
|
macro asm void panic() {
|
|
|
|
? JSR _panic
|
2020-07-31 14:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
noinline asm word call(word register(x) routine) {
|
|
|
|
JMP ,X
|
|
|
|
}
|