*
* Check printer ready, return with sign flag set if ready
*
PChk
psha ; Save A
ldaa ACIA ; Get status register
rora ; Get TDRE bit into MSB
rora
rora
pula ; Recover A
rts
How would you write this for the NMOS 6502?
I can see juggling bytes on the stack or using a temporary variable, but no direct translation.
The interface was originally used for a parallel printer. Space was extremely limited, so they just read the port and the ready line was bit 7. I would rather not change the interface as that would make the parallel driver even bigger.
PChk
pha ; Save A
lda ACIA ; Get status register
ror A ; Get TDRE bit into MSB
ror A
ror A
sta Temp
pla ; Recover A
bit Temp ; Set S flag accordingly
rts
The interface was originally used for a parallel printer. Space was extremely limited, so they just read the port and the ready line was bit 7. I would rather not change the interface as that would make the parallel driver even bigger.
PChk
pha ; Save A
lda ACIA ; Get status register
ror A ; Get TDRE bit into MSB
ror A
ror A
sta Temp
pla ; Recover A
bit Temp ; Set S flag accordingly
rts
If the ready line is bit 7 what's wrong with BIT ACIA followed by BPL or BMI?
George's code looks good to me. Yes, you'd have to make a minor change in every place from which this routine is called (to test Carry rather than the Sign). But that seems tolerable if you're replacing all the 6800 code with 6502 code anyway...
It looks like the 6800 version is nine bytes. If you have space for ten bytes and you have a "junk" zp location, you can just add an ROR zp to George's code:
Yes, you'd have to make a minor change in every place from which this routine is called (to test Carry rather than the Sign). But that seems tolerable if you're replacing all the 6800 code with 6502 code anyway...
teamtempest wrote:
Is there any reason you can't trash X or Y?
One of the goals of the project is to make it as easy as possible to port 6800 code over. Changing this interface would be yet another thing to forget to check.
The serial driver is under no space pressure.
The parallel driver is. The 6800 version uses 55 of the 56 bytes allotted. I've allocated 64 bytes for the 6502 version and barely managed to code golf it to fit.
I posted that subroutine from the serial driver to see whether I overlooked any coding tricks.
It looks like the 6800 version is nine bytes. If you have space for ten bytes and you have a "junk" zp location, you can just add an ROR zp to George's code:
I do not have a spare zp location, but there are bytes to spare within the driver, that temporary variable I used, for instance.
I should have known that you would come up with something.