I hope my introductory article in EUG #18 has encouraged some experimentation with the assembler. How have you been getting on? Have you been able to find out how to give the commands to change MODE and the colours and clear the screen? These are all quite simple if you think of the VDU codes:
MODE <num> .mode LDA #22:JSR &FFEE:LDA #<num>:JSR &FFEE \VDU 22,<num> COLOUR <col> .colour LDA #17:JSR &FFEE:LDA #<col>:JSR &FFEE \VDU 17,<col> GCOL 0,<col> .gcol LDA #18:JSR &FFEE:LDA #0:JSR &FFEE:LDA #<col>:JSR &FFEE \VDU18,0,<col> CLS .cls LDA #12:JSR&FFEE \VDU12 CLG .clg LDA #16:JSR&FFEE \VDU16
These could all be entered as subroutines and called with JSR <label>. If a variable is to be entered, it can be done by: LDX #<num>...TXA...as in the 'tab' routine. Though, as they are short, it is best to enter them in the main loop as required.
However, if you are entering a series of commands, a simpler method is to use a loop - you will find loops used a lot in m/code; they are rather like REPEAT/UNTIL loops in BASIC. As I said last time, the VDU codes can be used with the 'print' routine and instead of using 'tab', enter in the data:
.text EQUB 31:EQUB<x>:EQUB<y>:EQUS"<..TEXT.."+CHR$&FF \VDU31,x,y:PRINT"..TEXT.."
If you think of MODE 5:COLOUR2:COLOUR129 as:
VDU 22,5,17,2,17,129
Then enter the data:
.mode_col EQUB 22:EQUB 5:EQUB 17:EQUB 2:EQUB 17:EQUB 129:EQUB &FF
and use the 'print' routine as before.
While you can use the print routine in this way, it cannot be used if you need the value 255 in the code. This can occur with PLOT routines which I hope to cover in the next article. It is then necessary to use a different form of loop. You need to return from the routine after the number of values have been printed and this can be done by comparing the value of the Y register:
.comms STX &70 STY &71 LDY #0 .cloop LDA(&70),Y JSR &FFEE INY CPY #<num>\ num=no. of values BNE cloop RTS
The disadvantage of this method is that the value of 'num' needs to be altered if the number of values is changed. It is easier to do this if it's done before the routine is called as in previous routines.
It is also better to load Y register with the number of values and to decrement Y. The routine is then stopped when Y reaches zero. Alter the routine to:
.comms STX &70 STY &71 TAY .cloop LDA(&70),Y JSR &FFEE DEY BNE cloop RTS
This will need the values entered in reverse order as the addresses are read in reverse. This routine is used by:
LDA #num LDX #Electron_Data_Log MOD256 LDY #Electron_Data_Log DIV256 JMP comms
The cursor can be switched by using the BASIC values in this routine:
Cursor off=23,1,0,0,0,0,0,0,0,0 Cursor on =23,1,1,0,0,0,0,0,0,0
Entered as EQUB 0:EQUB 0:etc....(reverse order)..EQUB 1:EQUB 23
If the cursor is to be turned on and off in the program, it is better to use a subroutine:
.cur LDA #23 JSR &FFEE LDA #1 JSR &FFEE TXA JSR &FFEE LDX #7 .lp LDA #0 JSR &FFEE DEX BNE lp RTS
Then LDX #0 for cursor off or LDX #1 for cursor on before calling the routine. If you add these lines at the beginning of this routine:
.curoff LDA #1:BNE c:.curon LDA #0:TAX:.c
you may simply use JSR curoff or JSR curon.
I hope that I have given you something more to think about and try out. I learnt through trying out lots of things like this (and my mistakes!) Next time I hope to give routines for PLOT, DRAW and VDU23 characters.
Richard Dimond, EUG #19