My two Forth words have the same name as Tursi's TMS9900 Assembler code: INIT01 to start the timer and READ01 to get its current value. My TurboForth Assembler code follows:
ASM: INIT01 ( --- ) R12 R2 MOV, \ Save return address R12 CLR, \ CRU base of the TMS9901 0 SBO, \ Enter timer mode R1 $3FFF LI, \ Maximum value R12 INCT, \ Address of bit 1 R1 14 LDCR, \ Load value R12 DECT, 0 SBZ, \ Exit clock mode, start decrementer R2 R12 MOV, \ Restore return address ;ASM ASM: READ01 ( --- n ) R12 R2 MOV, \ Save return address R12 CLR, \ CRU base of the TMS9901 0 SBO, \ Enter timer mode SP INCT, \ Make space on stack to leave timer value *SP 15 STCR, \ Read current value (plus mode bit) and put on stack *SP 1 SRL, \ Get rid of mode bit 0 SBZ, \ Exit clock mode, decrementer continues R2 R12 MOV, \ Restore return address ;ASM
Both words seem to compile OK. INIT01 appears to work, but I cannot tell for sure because executing READ01 causes a stack underflow, which baffles me. Any ideas as to what is wrong?
...lee
Edited by Lee Stewart, Mon May 21, 2012 9:06 AM.














