Then I have to write the code so you can actually edit programs using the keyboard. At present the “program” is put in using Assembler Macros which works fine for testing but isn’t any good for the final thing.
I have also written a separate integer printing routine, so actually none of the math routines are now used that I wrote ages ago (well a few days ago anyway).
Part of the reason is this is a bit of a swine in SC/MP. You have four pointer registers. One is the program counter, one is used for subroutines (P3) and one for the stack (P2) – this is just convention.
This leaves you with one pointer register, P1. In this code it is normally pointing at the program code.
My original integer to ASCII routine (a 16 bit one) used this as a pointer to memory to store the result in. In the end I decided it was simpler just to write a simple byte only one that used subtraction not division – it only does decimal, and 0-255, but that doesn’t actually matter, and it is simpler to use – it just prints the number in ‘E’.