maybe someone else sees what I am doing wrong here.
I have some working code, reading a char from RX and returning the char
plus a carriage-return via TX.
as soon as I put in a subroutine, things stop working.
any feedback appreciated.
the working code is :
- Code: Select all
// SPOC program for reading out a flash chip
// this works
initialize:
// set stack pointer, grows to 0x0FFF
do #0x0C00 -> SP
Begin:
GetChar:
do #0x3000 -> RA0
do.bit @
jmp.Z=0 #GetChar
// read the inchar on address 2000hex into accumulator
do #0x2000 -> RA1
do.byte @ -> A
//
do #0x1000 -> WA0
do.byte A -> @ // transmit one byte out of RS-232 TX
// check the RS-232 TX busy bit
Loop1TxD_busy:
do #0x1000 -> RA0
do.bit @
jmp.Z=1 #Loop1TxD_busy
//
do.byte #0x0D -> A // cr char
do.word #0x1000 -> WA0
do.byte A -> @ // transmit one byte out of RS-232 TX
// check the RS-232 TX busy bit
Loop2TxD_busy:
do #0x1000 -> RA0
do.bit @
jmp.Z=1 #Loop2TxD_busy
//
//
final:
// once string completely sent, delay before sending again
Delay:
do.dw #200000 -> A
DelayLoop:
dec.dw A
jmp.z=1 #DelayLoop
jmp #Begin
// that's all folks
and the broken code is :
- Code: Select all
// SPOC program for reading out a flash chip
// THIS DOES NOT WORK
initialize:
// set stack pointer, grows to 0x0FFF
do #0x0C00 -> SP
Begin:
jsr #GetChar // uses RA0,RA1,A.byte
//
do #0x1000 -> WA0
do.byte A -> @ // transmit one byte out of RS-232 TX
// check the RS-232 TX busy bit
Loop1TxD_busy:
do #0x1000 -> RA0
do.bit @
jmp.Z=1 #Loop1TxD_busy
//
do.byte #0x0D -> A // cr char
do.word #0x1000 -> WA0
do.byte A -> @ // transmit one byte out of RS-232 TX
// check the RS-232 TX busy bit
Loop2TxD_busy:
do #0x1000 -> RA0
do.bit @
jmp.Z=1 #Loop2TxD_busy
//
//
final:
// once string completely sent, delay before sending again
Delay:
do.dw #200000 -> A
DelayLoop:
dec.dw A
jmp.z=1 #DelayLoop
jmp #Begin
//subroutine getchar
// uses RA0, RA1, output into A.byte
GetChar:
do #0x3000 -> RA0
do.bit @
jmp.Z=0 #GetChar
// read the inchar on address 2000hex into accumulator
do #0x2000 -> RA1
do.byte @ -> A
//
// that's all folks