Jump to content


Omegamatrix's Blog

Embedded Tables, Divide by 40, Mod 40

Posted by Omegamatrix, in Assembly Tricks, 6502 Math Routines 21 June 2014 · 1,145 views
Divide by 40, Mod 40
While posting my Unsigned Integer Division Routines on NesDev, a new member there said he was looking for a divide by 40 and mod 40. I wrote a few routines, but this one really sticks out as a neat idea.;Divide by and Mod 40 combined;38 bytes, 45 cycles;Y = value to be dividedInterlacedMultiplyByFortyTable: lda #0 ; dummy load, #0 used in LUT l...

Interlacing Tables, Table Reduction

Posted by Omegamatrix, in Assembly Tricks 21 June 2014 · 909 views

Sometimes you end up with routines that use a lot of tables. While writing my (0-65535) Hex to Decimal routine I ended up with a lot of 16 byte tables (6 of them actually). I realized that an optimization could be made by interlacing the tables. Normally I would do something like this: lda hexValue ;3 @3 lsr...

The Magic of EOR

Posted by Omegamatrix, in Assembly Tricks 21 June 2014 · 1,205 views
EOR is a useful function. I often use it in a situation where I already have "myNumber" in the accumulator, and I want to do a subtraction. Instead of doing this: sta temp ; myNumber (0 to 255) lda #$FF ; 255 sec sbc temp ; 255 - myNumber
You can just do this: eor #$FF ; 255 - myNumber
You save a lot of...

January 2019

1314 15 16171819

Recent Comments

Latest Visitors

0 user(s) viewing

0 members, 0 guests, 0 anonymous users