Compare commits

..

No commits in common. "321759f70da9369ebe57cdcce1885d2a3fb8a2b2" and "e295c5549a430cfabf833499ad3ab92d85815f14" have entirely different histories.

12 changed files with 98 additions and 628 deletions

View File

@ -20,7 +20,6 @@ $(BUILD_DIR):
mkdir $@ mkdir $@
.PHONY: default test clean .PHONY: default test clean
.DEFAULT_GOAL = default
default: $(ROM) default: $(ROM)
test: ../test.bin test: ../test.bin

View File

@ -1,19 +1,13 @@
# Project details # Project details
## Address Space ## Address Space
|Name|From|To|r/w| ### RAM: $0-$7fff
|---|---:|---:|:---:| ### (EEP)ROM: $8000-$ffff
|ZEROPAGE |$00 |$ff |`rw`|
|STACK |$100 |$1ff |`rw`|
|RAM |$200 |$4fff |`rw`|
|SPI |$5000 |$5fff |`rw`|
|VIA1 |$6000 |$600f |`rw`|
|VIA2 |$7000 |$700f |`rw`|
|ROM |$8000 |$ffff |`r `|
## Naming conventions ## Naming conventions
leading underscors `_` indicate a "private" label/variable, that is meant for internal use within the module only. leading underscors `_` indicate a "private" label/variable, that is meant for internal use within the module only.
### Labels ### Labels
- **scopes**: snake case - `namespace_fname` for exported subroutines
- **subroutines** and **variables**: snake case (`scope::(_)fname_snake_case` or `scope::(_)varname_2`) - `_namespace_fname` or `_namespace_fname_sub` for internal labels
- **macros**: camel case (`(_)GoodMacroname`) - `(_)namespace_Macroname`
- **constants** (eg. in ROM): upper case (`scope::(_)NICE_SYMBOLNAME`) - `(_)NAMESPACE_SYMBOLNAME` for constant symbols
- `(_)NAMESPACE_symbolname` for variables

View File

@ -2,7 +2,6 @@
.code .code
.macro DEBUG_LED_OFF nr .macro DEBUG_LED_OFF nr
pha
lda IO1 + IO::RA lda IO1 + IO::RA
.if nr = 0 .if nr = 0
and #%11111110 and #%11111110
@ -10,11 +9,9 @@
and #%11111101 and #%11111101
.endif .endif
sta IO1 + IO::RA sta IO1 + IO::RA
pla
.endmacro .endmacro
.macro DEBUG_LED_ON nr .macro DEBUG_LED_ON nr
pha
lda IO1 + IO::RA lda IO1 + IO::RA
.if nr = 0 .if nr = 0
ora #%00000001 ora #%00000001
@ -22,7 +19,6 @@
ora #%00000010 ora #%00000010
.endif .endif
sta IO1 + IO::RA sta IO1 + IO::RA
pla
.endmacro .endmacro
;******************************************************************************** ;********************************************************************************
@ -41,7 +37,6 @@ SPI_IO = IO2
; Printer ; Printer
.include "programs/printer.s65" .include "programs/printer.s65"
.include "programs/print_slow.s65" .include "programs/print_slow.s65"
.include "programs/spi-menu.s65"
; Digital Humidity and Temerature Sensor ; Digital Humidity and Temerature Sensor
; .include "dht.s65" ; .include "dht.s65"
@ -66,8 +61,8 @@ irq:
lda IO2+IO::IFR lda IO2+IO::IFR
sta IRQ_VAR sta IRQ_VAR
bbr7 IRQ_VAR,@irq_return bbr7 IRQ_VAR,@irq_return
bbs1 IRQ_VAR,@irq_keypad ; check CB1
bbs2 IRQ_VAR,@irq_spi_p ; check SR bbs2 IRQ_VAR,@irq_spi_p ; check SR
bbs1 IRQ_VAR,@irq_keypad ; check CA1
; this should never be reached ; this should never be reached
jsr lcd_clear jsr lcd_clear
Print str_irq_unknown Print str_irq_unknown
@ -80,7 +75,7 @@ irq:
jsr kp_read_on_irq jsr kp_read_on_irq
bra @irq_return bra @irq_return
@irq_spi_p: @irq_spi_p:
jsr spi_p::read jsr spi_p_read
bra @irq_return bra @irq_return
; @irq_dht: ; @irq_dht:
; lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag ; lda IO1 + IO::T1CL ;T1L2 ; clear interrupt flag
@ -94,16 +89,15 @@ irq:
reset: reset:
jsr lcd_init jsr lcd_init
; TODO debug stuff
stz IO2 + IO::DDRB
lda #$ff lda #$ff
sta IO1 + IO::DDRA sta IO1 + IO::DDRA
DEBUG_LED_OFF 0 DEBUG_LED_OFF 0
DEBUG_LED_OFF 1 DEBUG_LED_OFF 1
jsr kp_init jsr kp_init
jsr spi_p_init
; ; INIT DHT ; ; INIT DHT
; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2 ; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
@ -118,61 +112,48 @@ reset:
; enable interrupts ; enable interrupts
cli cli
bra home
.proc return_home
Print message_menu
.endproc
.proc home .proc home
Print message_menu jsr rb_keypad_read
; jsr rb_keypad_read beq home
@loop:
lda _KP_DEBUG_VAL
beq @loop
; TODO debug
sta 0
stz _KP_DEBUG_VAL
lda 0
; beq home ; beq home
cmp #'A' cmp #'A'
jeq printer jeq printer
cmp #'B' cmp #'B'
jeq spi_menu::spi_menu jeq SPI_CODE_START
; jeq dht_request
cmp #'C' cmp #'C'
jeq print_1 jeq print_1
cmp #'D' cmp #'D'
jeq print_2 jeq print_2
cmp #'1' cmp #'0'
beq @debug0_on bne @l1
cmp #'2'
beq @debug0_off
cmp #'4'
beq @debug1_on
cmp #'5'
beq @debug1_off
cmp #'7'
beq @print_rb
cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
beq home
jmp @loop
@debug0_off:
DEBUG_LED_OFF 0 DEBUG_LED_OFF 0
jmp @loop jmp home
@debug0_on: @l1:
cmp #'#'
bne @l2
DEBUG_LED_ON 0 DEBUG_LED_ON 0
jmp @loop jmp home
@debug1_off: @l2:
cmp #'8'
bne @l3
DEBUG_LED_OFF 1 DEBUG_LED_OFF 1
jmp @loop jmp home
@debug1_on: @l3:
cmp #'9'
bne @l4
DEBUG_LED_ON 1 DEBUG_LED_ON 1
jmp @loop jmp home
@print_rb: @l4:
jsr lcd_clear cmp #'*' ; print home menu again if not visible (message 1 and 2 jmp to home)
Print str_io2 jeq return_home
lda IO2 + IO::RB
jsr lcd_char jmp home
lda #'''
jsr lcd_char
jmp @loop
.endproc .endproc
@ -200,19 +181,13 @@ message_2:
message_menu: message_menu:
.byte "<A> Printer " .byte "<A> Printer "
; .byte "<B> Temperatur " ; .byte "<B> Temperatur "
.byte "<B> SPI-Menu " .byte "<B> Run from SPI"
.byte "<C> Text 1 " .byte "<C> Text 1 "
.asciiz "<D> Text 2 " .asciiz "<D> Text 2 "
str_spi_begin:
.asciiz "---BEGIN SPI---"
str_spi_start:
.asciiz "---START SPI---"
str_irq: str_irq:
.asciiz "IRQ detected! " .asciiz "IRQ detected! "
str_irq_unknown: str_irq_unknown:
.asciiz "Unknown IRQ src!" .asciiz "Unknown IRQ src!"
str_io2:
.asciiz "IO2::RB='"
;******************************************************************************** ;********************************************************************************
; reset vector ; reset vector

View File

@ -12,8 +12,8 @@ INCLUDE_MEMCOPY = 1
cpy cpy
loop: loop:
beq @loop_end beq @loop_end
lda (ARG0),y lda (ARG0,y)
sta (ARG2),y sta (ARG2,y)
dey dey
bra @loop bra @loop
loop_end: loop_end:

View File

@ -33,9 +33,9 @@ INCLUDE_PRINT_SLOW = 1
;******************************************************************************** ;********************************************************************************
.macro PrintSlow message,time_cs .macro PrintSlow message,time_cs
jsr lcd_clear jsr lcd_clear
lda #<message lda #.LOBYTE(message)
sta ARG0 sta ARG0
lda #>message lda #.HIBYTE(message)
sta ARG1 sta ARG1
phx phx
ldx #time_cs ldx #time_cs

View File

@ -10,7 +10,7 @@ printer:
jsr rb_keypad_read jsr rb_keypad_read
beq @printer_loop beq @printer_loop
cmp #'*' cmp #'*'
jeq home jeq return_home
jsr lcd_char jsr lcd_char
bra @printer_loop bra @printer_loop
.endif ; guard .endif ; guard

View File

@ -1,92 +0,0 @@
.include "system/spi.s65"
.include "util/string.s65"
.ifndef INCLUDE_SPI_MENU
INCLUDE_SPI_MENU = 1
.scope spi_menu
.bss
trans_bytes: .res 1
trans_pages: .res 1
status: .res 1
status_str: .res 17 ; 16 + null
.code
.proc spi_menu
stz trans_bytes
stz trans_pages
lda #'X'
sta status
@print_menu:
jsr lcd_clear
Print MENU
@print_status:
Strf FMT_STATUS,status_str,trans_pages,trans_bytes,status
lda #(LCD_CMD_SET_ADDRESS | LCD_LINE4)
jsr _lcd_cmd
Print status_str
@loop:
; check if a byte has been transferred
@check_byte:
lda spi_p::bytes_written
cmp trans_bytes
bne @byte_written
@check_page:
lda spi_p::pages_written
cmp trans_pages
bne @page_written
bra @read_keypad
@byte_written:
sta trans_bytes
bra @print_status
@page_written:
sta trans_pages
bra @print_status
@read_keypad:
lda _KP_DEBUG_VAL
beq @loop
; TODO debug
sta 0
stz _KP_DEBUG_VAL
lda 0
cmp #'*'
beq @return_home
cmp #'A'
beq @spi_begin
cmp #'B'
beq @spi_end
cmp #'C'
beq @spi_jump
bra @loop
@spi_begin:
lda #'@'
sta status
jsr spi_p::begin
jmp @print_menu
@spi_end:
lda #'X'
sta status
jsr spi_p::end
jmp @print_menu
@spi_jump:
jsr spi_p::end
jsr lcd_clear
Print START
jmp spi_p::SPI_CODE_START
@return_home:
jsr spi_p::end
jmp home
.endproc
.rodata
MENU:
.byte "A> Beg. Transfer"
.byte "B> Stop Transfer"
.asciiz "C> Jump Home <*"
; .asciiz "0b0p Status: X"
FMT_STATUS: .asciiz "%x%xb Status:%x"
BEGIN: .asciiz "---BEGIN SPI---"
START: .asciiz "---START SPI---"
.endscope
.endif ; guard

View File

@ -102,5 +102,25 @@ INCLUDE_IOW65C22 = 1
IRQ = %10000000 IRQ = %10000000
.endenum .endenum
.endscope ; IO ; TODO: leave?
.endif ; guard ; .struct VIA_Pins
; RB .byte ; $0
; RA .byte ; $1
; DDRB .byte ; $2
; DDRA .byte ; $3
; T1CL .byte ; $4
; T1CH .byte ; $5
; T1LL .byte ; $6
; T1LH .byte ; $7
; T2CL .byte ; $8
; T2CH .byte ; $9
; SR .byte ; $a
; ACR .byte ; $b
; PCR .byte ; $c
; IFR .byte ; $d
; IER .byte ; $e
; RANH .byte ; $f ; no handshake
; .endstruct
.endif
.endscope

View File

@ -18,7 +18,6 @@ INCLUDE_KEYPAD = 1
.zeropage .zeropage
_KP_COLUMN: .res 1 ; for storing stuff _KP_COLUMN: .res 1 ; for storing stuff
_KP_DEBUG_VAL: .res 1 ; for storing the last char DEBUG
.bss ; reserve space or ringbuffer .bss ; reserve space or ringbuffer
KP_BUF_SIZE = 10 KP_BUF_SIZE = 10
@ -91,8 +90,6 @@ RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
rts rts
@kp_write: @kp_write:
lda _KP_VALUES,x lda _KP_VALUES,x
; TODO use ringbuffer
sta _KP_DEBUG_VAL
jsr rb_keypad_write jsr rb_keypad_write
rts rts
.endproc .endproc
@ -100,9 +97,9 @@ RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
.rodata .rodata
_KP_VALUES: _KP_VALUES:
.byte "174*" .byte "174*"
.byte "2850"
.byte "396#" .byte "396#"
.byte "ACBD" .byte "2850"
.byte "ABCD"
; keypad conencted so that ; keypad conencted so that
; row 1 = PA0 ; row 1 = PA0
; row 2 = PA2 ; row 2 = PA2

View File

@ -10,148 +10,30 @@
.ifndef INCLUDE_SPI .ifndef INCLUDE_SPI
INCLUDE_SPI = 1 INCLUDE_SPI = 1
.scope spi_p
.zeropage
code_page: .res 2 ; SPI_CODE_START + pages_written * 256
.bss .bss
bytes_written: .res 1 SPI_PAGES_WRITTEN: .res 1
pages_written: .res 1 SPI_BYTES_WRITTEN: .res 1
.include "util/math.s65"
; spi-transferred code will be placed here
.segment "SPI" .segment "SPI"
SPI_CODE_START: SPI_CODE_START: ; .res $1000
lda '$' lda $1000
jsr lcd_char sta $1000
lda #<TEST_FMT lda $1000
sta ARG0 sta $1000
lda #>TEST_FMT lda $1000
sta ARG1 sta $1000
lda #<TEST_OUT
sta ARG2
lda #>TEST_OUT
sta ARG3
lda #$a9
sta ARG4
lda #$3c
sta ARG5
lda #$10
sta ARG6
jsr strf
Print TEST_OUT
@spiloop:
lda IO1 + IO::RA lda IO1 + IO::RA
lda IO2 + IO::RA lda IO1 + IO::RA
nop bra SPI_CODE_START
bra @spiloop ; jsr lcd_clear
jmp home ; PrintSlow msg,20
; jmp home
; TODO allocate zp memory ; msg:
fmt_idx = $30 ; .asciiz "YO DAS WAR SPI"
out_idx = $31
;********************************************************************************
; @function Format a string
; @details
; If there is no value to be read, the Pz will be set
; Formats:
; - u: unsigned decimal integer (1 byte)
; - U: unsigned decimal integer (2 bytes)
; @param ARG0-1: Format string address
; @param ARG2-3: Output string address
; @param ARG4+: Additional parameters
; @returns
; @modifies: A, Y
;********************************************************************************
.proc strf
stz out_idx
stz fmt_idx
ldy #0 ; position in string
ldx #0 ; index of format args
@loop:
ldy fmt_idx
lda (ARG0),y
beq @null
cmp #'%'
beq @percent
@normal_char: ; store A in output string
ldy out_idx
sta (ARG2),y
inc fmt_idx
inc out_idx
beq @out_overflow
bra @loop
@percent: ; check for format in next position
iny
sty fmt_idx
lda (ARG0),y
beq @null
; formats
cmp #'x'
beq @format_hex1
bra @normal_char
@format_hex1: ; 1 byte hex -> 2 chars
lda ARG4,x
phx
jsr int8_to_hex_str
ldy out_idx
sta (ARG2),y ; most sig digit
iny
beq @out_overflow
txa
sta (ARG2),y ; least sig digit
iny
beq @out_overflow
sty out_idx
plx
inx ; 1 byte of args handeled
; bra @format_return
@format_return: ; increment fmt_idx to swallow the formating char
inc fmt_idx
bra @loop
@out_overflow: ; store 0 in last position
ldy #$ff
sty out_idx
@store_null:
lda #0
@null: ; store and return
ldy out_idx
sta (ARG2),y
@rts:
rts
.endproc
;********************************************************************************
; @function Convert a 1 byte number into two hex characters
; @param A: Number to convert
; @returns A: Most significant digit
; @returns X: Least significant digit
; @modifies X,Y,A
;********************************************************************************
.proc int8_to_hex_str
pha
and #%00001111
tay
ldx HEX_CHARS,y
pla
div A,16
and #%00001111
tay
lda HEX_CHARS,y
rts
.endproc
HEX_CHARS: .byte "0123456789ABCDEF"
TEST_FMT: .asciiz "%x -> %x -> %x:)"
TEST_OUT: .asciiz "TESTOUT"
; SPI_P = as peripheral
.code .code
.struct SPI_P_Pins .struct SPI_P_Pins
; VIA addresses ; VIA addresses
@ -168,20 +50,12 @@ TEST_OUT: .asciiz "TESTOUT"
.endstruct .endstruct
;******************************************************************************** ;********************************************************************************
; @function Begin listening for SPI transfers ; @function Initialize the IO Adapter for SPI
; @details ; @param ARG0-1 Address of the SPI_Pins struct
; - initialize variables
; - configure shift register to shift in under external clock
; - enable shift register interrupts
;******************************************************************************** ;********************************************************************************
.proc begin .proc spi_p_init
stz pages_written stz SPI_PAGES_WRITTEN
stz bytes_written stz SPI_BYTES_WRITTEN
; store address in zp
lda #<SPI_CODE_START
sta code_page
lda #>SPI_CODE_START
sta code_page + 1
; todo USE MASKS ; todo USE MASKS
; set Shift register to shift in under external clock on CB1 ; set Shift register to shift in under external clock on CB1
lda #IO::ACR::SR_SIN_PHIE lda #IO::ACR::SR_SIN_PHIE
@ -190,49 +64,21 @@ TEST_OUT: .asciiz "TESTOUT"
; enable SR interrupts ; enable SR interrupts
lda #(IO::IRQ::IRQ | IO::IRQ::SR) lda #(IO::IRQ::IRQ | IO::IRQ::SR)
sta SPI_IO + IO::IER sta SPI_IO + IO::IER
DEBUG_LED_ON 1
; load SR to reset
lda SPI_IO + IO::SR
rts rts
.endproc .endproc
;******************************************************************************** .proc spi_p_read
; @function Stop listening for SPI transfers DEBUG_LED_ON 0
; @details ; print received byte
; Disables shift register interrupts
;********************************************************************************
.proc end
; disable SR interrupts
lda #IO::IRQ::SR
sta SPI_IO + IO::IER
rts
.endproc
;********************************************************************************
; @function Read a byte from SPI
; @details
; Reads a byte from the shift register and stores it in the SPI code buffer
;********************************************************************************
.proc read
ldx bytes_written
lda SPI_IO + IO::SR lda SPI_IO + IO::SR
sta SPI_CODE_START,x sta SPI_CODE_START,x
inc bytes_written inc SPI_BYTES_WRITTEN
beq @new_page jsr lcd_char
rts
@new_page:
inc pages_written
inc code_page + 1
rts rts
.endproc .endproc
;********************************************************************************
; @function Initialize the IO Adapter for SPI
; @param ARG0-1 Address of the SPI_Pins struct
;********************************************************************************
;******************************************************************************** ;********************************************************************************
; @function Read bytes ; @function Read bytes
; @param X Number of bytes to send ; @param X Number of bytes to send
@ -250,8 +96,8 @@ TEST_OUT: .asciiz "TESTOUT"
.proc send_data .proc send_data
.endproc .endproc
.endscope
_send_byte:
.endif .endif

View File

@ -1,106 +0,0 @@
;********************************************************************************
; @module math
; @type utility
; @details
; Math library
;********************************************************************************
.ifndef INCLUDE_MATH
INCLUDE_MATH = 1
.scope math
;********************************************************************************
; @macro Divide a num (or A) by a factor
; @param num: Memory or A
; @param divider: must be power of 2
;********************************************************************************
.macro div num,divider
.if divider = 2
lsr num
.elseif divider = 4
lsr num
lsr num
.elseif divider = 8
lsr num
lsr num
lsr num
.elseif divider = 16
.repeat 4
lsr num
.endrepeat
.elseif divider = 32
.repeat 5
lsr num
.endrepeat
.elseif divider = 64
.repeat 6
lsr num
.endrepeat
.elseif divider = 128
.repeat 7
lsr num
.endrepeat
.else
.error "div macro: divider % 2 != 0"
.endif
.endmacro
; .macro Amult1 factor
; phx
; ldx factor
; AmultX
; plx
; .endmacro
; https://www.llx.com/Neil/a2/mult.html
; .macro mult num1,num2,result
; lda #0
; ldx #8
; L1:
; lsr num2
; bcc L2
; clc
; adc num1
; L2:
; ror
; ror result
; dex
; bne L1
; sta result+1
; .endmacro
; 00110101
; 10010011
; -------^
; =00110101
; 00110101
; 01001001
; -------^
; =00110101
; 00110101
; 00100100
; -------^
; =00000000
; 00110101
; 00010010
; -------^
; =00000000
; 00110101
; 00001001
; -------^
; 00110101
; 00110101
; 00000100
; -------^
; =00000000
; 00110101
; 00000010
; -------^
; =00000000
; 00110101
; 00000001
; 00110101
.endscope
.endif ; guard

View File

@ -1,163 +0,0 @@
;********************************************************************************
; @module string
; @type utility
; @details
; String utility
;********************************************************************************
.ifndef INCLUDE_STRING
INCLUDE_STRING = 1
.scope str
.code
.macro _StrfStoreArg arg
.if (.not .blank(arg))
.if .match(arg, x)
stx ARG4 + @N_ARGS
.elseif .match(arg, y)
sty ARG4 + @N_ARGS
.else
lda arg
sta ARG4 + @N_ARGS
.endif
@N_ARGS .set (@N_ARGS + 1)
.endif
.endmacro
;********************************************************************************
; @function Macro for passing arguments to strf
; @param fmt: Format string address
; @param out: Output string address
; @param x0-x9: Additional parameters
; @warning Addresses as additional paramteres must be passed like this `#<addr,#>addr`
; @modifies: A, X, Y
; @see strf
;********************************************************************************
.macro Strf fmt,out,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
@N_ARGS .set 0 ; @ so that it doesnt break cheap labels
lda #<fmt
sta ARG0
lda #>fmt
sta ARG1
lda #<out
sta ARG2
lda #>out
sta ARG3
_StrfStoreArg x0
_StrfStoreArg x1
_StrfStoreArg x2
_StrfStoreArg x3
_StrfStoreArg x4
_StrfStoreArg x5
_StrfStoreArg x6
_StrfStoreArg x7
jsr strf
.out .sprintf("info: Strf: called with %d arguments", @N_ARGS)
.endmacro
; TODO allocate zp memory
fmt_idx = $30
out_idx = $31
;********************************************************************************
; @function Format a string
; @details
; If there is no value to be read, the Pz will be set
; Formats:
; - x: unsigned hex integer (1 byte) -> 2 chars
; - X: unsigned hex integer (2 byte) -> 4 chars TODO
; - u: unsigned decimal integer (1 byte) TODO
; - U: unsigned decimal integer (2 bytes) TODO
; @param ARG0-1: Format string address
; @param ARG2-3: Output string address
; @param ARG4+: Additional parameters
; @returns
; @modifies: A, X, Y
;********************************************************************************
.proc strf
stz out_idx
stz fmt_idx
ldy #0 ; position in string
ldx #0 ; index of format args
@loop:
ldy fmt_idx
lda (ARG0),y
beq @null
cmp #'%'
beq @percent
@normal_char: ; store A in output string
ldy out_idx
sta (ARG2),y
inc fmt_idx
inc out_idx
beq @out_overflow
bra @loop
@percent: ; check for format in next position
iny
sty fmt_idx
lda (ARG0),y
beq @null
; formats
cmp #'x'
beq @format_hex1
bra @normal_char
@format_hex1: ; 1 byte hex -> 2 chars
lda ARG4,x
phx
jsr int8_to_hex_str
ldy out_idx
sta (ARG2),y ; most sig digit
iny
beq @out_overflow
txa
sta (ARG2),y ; least sig digit
iny
beq @out_overflow
sty out_idx
plx
inx ; 1 byte of args handeled
; bra @format_return
@format_return: ; increment fmt_idx to swallow the formating char
inc fmt_idx
bra @loop
@out_overflow: ; store 0 in last position
ldy #$ff
sty out_idx
@store_null:
lda #0
@null: ; store and return
ldy out_idx
sta (ARG2),y
@rts:
rts
.endproc
;********************************************************************************
; @function Convert a 1 byte number into two hex characters
; @param A: Number to convert
; @returns A: Most significant digit
; @returns X: Least significant digit
; @modifies A,X,Y
;********************************************************************************
.proc int8_to_hex_str
pha
and #%00001111
tay
ldx HEX_CHARS_UPPER,y
pla
div A,16
and #%00001111
tay
lda HEX_CHARS_UPPER,y
rts
.endproc
.rodata
HEX_CHARS_UPPER: .byte "0123456789ABCDEF"
HEX_CHARS_LOWER: .byte "0123456789abcdef"
.export strf
.endscope
.endif ; guard