Optimizations

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

Optimizations

Post by mcoder » Mon Oct 15, 2007 11:06 am

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
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man » Mon Oct 15, 2007 11:36 am

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
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man » Mon Oct 15, 2007 11:45 am


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

Post by mcoder » Wed Oct 17, 2007 4:04 pm

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 » Tue Oct 23, 2007 1:14 pm

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
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man » Tue Oct 23, 2007 1:31 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests