Optimizations

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
mcoder
Private
Posts: 6
Joined: Sat Oct 13, 2007 7:53 pm

Optimizations

Post by mcoder »

If several people are interested, I can provide a list of optimizations.

The best code I disassembled while I was on Oric was the game Painter (I remember I was very happy to find a small optimization in the code).
I also spent a lot of time disassembling the Basic ROM (from Microsoft), and optimized it.

On the Apple 2, the best code I found was the ROM, with the impressive debugger (which was shamelessly stolen in OricMon).

On the C64, I didn't disassemble a lot of code, but I think demos had very good code.

Ok, the first optimisation:

suppose you have to unconditionally skip 2 bytes, like:
ldx #1
bne skip
ldx #2
skip:

the trick is to use byte $2C (opcode of BIT $xxxx):
ldx #1
byte $2C
ldx #2

If you have one byte to skip, you can use byte $24 (BIT $xx)

JC
mmu_man
Flight Lieutenant
Posts: 322
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man »

I'm not sure all those opcodes apply to the 6502A in the ORIC, do they ?
There is a list of those around.
Btw, I started a da65 info file to disasm the atmos rom:
http://revolf.free.fr/oric/atmosrom.zip
mmu_man
Flight Lieutenant
Posts: 322
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man »

mcoder
Private
Posts: 6
Joined: Sat Oct 13, 2007 7:53 pm

Post by mcoder »

mmu_man wrote:cf. http://www.6502.org/source/ for optimized code.
and http://www.6502.org/tutorials/
Yes, I know these links.

2 algorithms exist for multiplying two 16 bits numbers.
One shifts to the right, and the other one shifts to the left.
The interesting fact is that one of these 2 methods allow a multiplication by 40 with fewer instructions than the other (of course, it's slower than a table).

BTW, I also worked on optimizing the Basic ROM, and submitted some of my optimizations to this Basic:

http://members.lycos.co.uk/leeedavison/6502/ehbasic/

If you are interested, I have Fabrice Broche's book about the Oric and Atmos ROMs. I also was one of the first to disassemble the ROM of the disk drive (I intended to publish a book with other people). I may have some documentations about it.

JC
User avatar
carlsson
Pilot Officer
Posts: 127
Joined: Thu Jan 12, 2006 11:26 pm
Location: Västerås, Sweden

Post by carlsson »

BIT can also be useful in applications where timing is critical, and you need to spend a certain number of cycles. Regular NOP takes two cycles. BIT $XX takes three cycles, while BIT $XXXX takes four cycles. Often the results of the operation are not important.
Anders Carlsson
mmu_man
Flight Lieutenant
Posts: 322
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man »

Yes, I've seen it used elsewhere...
Lunix uses it to pass addresses to functions IIRC.
Post Reply