Thought i'd post a little on what I've been up to to try solve this without BCD.
Every time I tried to watch the video you have on BCD it turned out to be very late and I couldn't concentrate.
However, after sleeping on my issue I came up with another solution (I thought).
This was to do some >= statements (JP NC) then run another loop.
As we know, to print a character from 0 to 9 (&30 to &39) on the cpc we can call the print char routine with the characters hex code in 'a'.
If I start with &30 (bear with me on why its in bc just now) in 'bc' so that I can print a 0 if the compares show the number is below 10
Load the number from memory into 'a' and do a compare to see if its >= 10
If it is, then we run a routine to decrement 'a' by 10 and increment 'bc' by 1 (so it will now print a one if the print char is called with what is stored in memory via the a register).
This continues till we are < 10.
Then 'bc' is loaded into its memory location, then into 'a'.
Once thats in 'a', we can then run the print char routine.
My issue is that, I get the character to show on screen, it then goes to the next line which is WaitChar (for user input). If I press a key, I seem to get a loop of printing of memory instead of the next line which is to end the program. I'm no where near done with the program so that is why it'd going straight to an end.
Anyway, here is an extract of the code i'm talking about.
Code: Select all
;set constant PrinChar to firmware routine for printing characters. a contains character to be printer (in hex obviously)
PrintChar equ &bb5a
;set constant WaitChar to firmware routine for waiting on a keypress
WaitChar equ &bb06
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Hex to decimal printing routine
;print day number tens
ld a,(dayDate) ;load &0b into a
ld bc,&30 ;load character 0 into bc
tensCompare:
cp 10 ;compare a with 10
jp nc,decTens ;if >= jump to decTens
ld (dayDate),a ;loads remainder of date back into memoy location to be used at next stage
ld (dayTens),bc ;load contents of bc into 1st byte of dayTens memory location
ld a,(dayTens) ;loads 1st byte of dayTens into a
call PrintChar ;calls print character routine.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call WaitChar
;End program
End:
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Items to load on request then return
; Program end before reaching here.
; only loaded when called
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
decTens:
sub a,10 ;subtract 10 from a
inc bc ;incriment bc by 1
call tensCompare
;date variables
dayDate: dw &000b
dayTens: dw &0000
dayOnes: dw &0000
If anyone has any ideas on what is going on it'd be appreciated.