I use a couple of /10 and %10 in my code (to display numbers), which import fairly big portions of runtime.lib I'd like to leave out. Anybody knows of any compat ubyte/10 and ubyte%10 functions in assembly?
I found this ubyte/10 by Omegamatrix https://forums.nesdev.com/viewtopic.php?f=2&t=11336
Anybody knows something for ubyte%10? I could multiply by 10 (adding N<<3 and N<<1) the above results and substract, but is there a better method?
Thanks in advance.
I found this ubyte/10 by Omegamatrix https://forums.nesdev.com/viewtopic.php?f=2&t=11336
Code:
;Divide by 10
;17 bytes, 30 cycles
lsr
sta temp
lsr
adc temp
ror
lsr
lsr
adc temp
ror
adc temp
ror
lsr
lsr
;17 bytes, 30 cycles
lsr
sta temp
lsr
adc temp
ror
lsr
lsr
adc temp
ror
adc temp
ror
lsr
lsr
Anybody knows something for ubyte%10? I could multiply by 10 (adding N<<3 and N<<1) the above results and substract, but is there a better method?
Thanks in advance.