So the division works by loading the register b with 16 (because hex is base 16), subtracting the "main" number with it, and then adding a "tally" by increasing the c register until the register B gets to zero.
That I understood. However, now I am rather curious as to how this works:
Code: Select all
PrintHexChar: cp 10 ;If we're less then 10, add Ascii '0' to it (48) to print a Digit jr c,PrintHexCharNotAtoF ;Our digit is 10 or above so we need to print an Ascii letter add 7 ;A-F, so add another 7 PrintHexCharNotAtoF: add 48 ;Add 48 (character '0') jp PrintChar ;print it
Also, why add 48? I know it's the character for "0" in ASCII, but I'm still rather confused.