Time to fail for another hour at assembly language… Yesterday I think the routines for writing to the console were tripping me up, so I’m going to start a new file with none of that and just write to port 0 for starters.
So that ‘worked’ and is predictable in terms of the # of shifts. Note though that CP/M call 0 ends up wiping what’s on the output (or maybe only port 0 ?)
For now, I’m not going to worry about getting input – I’m just going to hard code some EQU’s that would eventually be values passed to the routine by something else.
HOORAY. it works.
BITNM EQU 5 ;THE BIT WERE GOING TO SET (PRESCALER)
WORD EQU 0 ;EMPTY WORD
TIMER0 EQU 40H ;WHERE TO SEND THE WORD
; REAL SIMPLE NOW - FOR STARTERS, WE PASS THE WORD & THE BIT TO THE
; ROUTINE, AND IT WILL SET THAT SPECIFIED BIT, AND PUT IT ON PORT 0
; REGISTER C WILL BE THE COUNTER
START: LD SP,STACK ;SETUP STACK POINTER
LD C,BITNM
LD B,WORD
CALL SETBIT
LD C,0
OUT (C),A
HALT
SETBIT: PUSH BC ;SAVE REGISTERS
PUSH DE
PUSH HL
LD A,1
RTAT: RLCA
DEC C
JR NZ,RTAT
OR B
POP HL
POP DE
POP BC
RET
Code language: PHP (php)