[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Assembly



Simon Biber writes ...
> 
> I'm just starting to learn Apple II assembly using the mini-assembler on my
> platinum //e. I'm using the instruction listing, Appendix A of the "Apple II
> Reference Manual".
> 
> I've written this program which clears the HGR screen to a colour (white by
> default). It works! Can someone help me to see if this is an optimal way of
> doing this?
> 
> 300:    LDA #FF
> 302:    LDX #3F
> 304:    LDY #00
> 306:    STX $030E
> 309:    STY $030D
> 30C:    STA $0100
> 30F:    DEY
> 310:    BNE $0306
> 312:    DEX
> 313:    CPX #19
> 315:    BNE $0304
> 
> You can change to a different colour by putting the bit-pattern into $0301.
> 
> thanks,
> Simon.


     You could speed things a bit by ...

310:     BNE $0309

X is not changed and the value at $030E is still valid. There is no need to
STX to $030E.
 

Similarly, you can change 315 to ...

315:     BNE $0306

Since Y will be $00 anyway, there is no need to set it to $00 in 304.


     For even better speed, you can eliminate the Y write to $030D and do a
Y-indexed STA at 30C-- i.e. the machine instruction could be 99 00 01. Then
rearrange things a little ...

300:    LDA #FF
302:    LDX #3F
304:    LDY #00
306:    STY $030D
309:    STX $030E
30C:    STA $0100,Y
30F:    DEY
310:    BNE $030C
312:    DEX
313:    CPX #19
315:    BNE $0309
317:    RTS



Rubywand