Re: Fun with 6502 Assembler
The BASIC on the commodore PET (and probably most others with Microsofts 6502 BASIC) has a small routine copied into zero page RAM that gets the next byte of the program code:
. Code:
C:00c2 E6 C9 INC $C9 |
Re: Fun with 6502 Assembler
Spot the schoolgirl error:
Code:
.dotest |
Re: Fun with 6502 Assembler
Move the INX before the CMP?
Other comments: Could use offsets+1 in the second LDY Could split offsets table in to a low byte and hi byte table then only one inx needed. I've been doing a lot of 6502 assembler recently. Mainly to allow me to load operating system and basic rom images into my frankenstein bbc micro with an optional 6809, z80 or 68008 main processor. I prefer 6809 coding usually but the limitations of the 6502 often force the use of cunning to get the job done. I had a fun few hours yesterday squeezing the flash rom programming routines down to a single page.. |
Re: Fun with 6502 Assembler
Ding, ding, we have a winner! This is 2 bytes shorter and 7 cycles faster:
Code:
.dotest Splitting the table of offsets would be a slap in the face for anybody trying to reverse-engineer the code in future. (I do plan to publish the Source Code, but you never know .....) So I'm holding off that technique unless and until the code ever gets one byte the wrong side of running on a model B! |
Re: Fun with 6502 Assembler
If you have a number of pointers stored in Zero Page, each representing the base address of a fixed-size record up to 256 bytes, you probably use something like
Code:
LDA (pcb),Y Now to move on to the next vertex, we need to add 3 to value stored at pcb and pcb+1; and we need to add 4 to the value stored at acb and acb+1. Naïvely, we might write Code:
.next_vertex Code:
.next_vertex Note that we don't need to increase X to deal with the high byte; we just offset from 1 instead. Other pointers at different addresses in ZP probably will have different record sizes; so we just need a construct like Code:
.next_shape |
Re: Fun with 6502 Assembler
shave another couple of bytes and speed up with an early exit
Code:
ADC #xx |
All times are GMT +1. The time now is 10:48 am. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright ©2002 - 2023, Paul Stenning.