Calculator Community > ASM
ASM Optimized routines
DJ Omnimaga:
--- Quote from: calc84maniac on April 29, 2010, 06:31:16 pm ---Seems pretty impossible to me.
--- End quote ---
O.O
No way!
You're calc84god, you can do everything, even the impossible! (see TI-Boy SE/Project M/F-Zero)
j/k I can't wait to see what kind of optimizations there will be in the next versions of Axe
Quigibo:
It's nothing big. Mostly it just extend multiplication, modulus, and addition to higher powers of 2. The big optimizations won't come for a long time unfortunately. Functionality is more important right now.
By the way, is there a better way to display hl at the coordinates (xx,yy) than this?
--- Code: ---B_CALL(_SetXXXXOP2)
B_CALL(_Op2ToOP1)
ld hl,$yyxx
ld (PenCol),hl
ld a,5
B_CALL(_DispOP1A)
--- End code ---
Its seems really roundabout to me. Is there a bcall I don't know about that does this automatically?
calcdude84se:
yeah, there's _DispHL
so you're code would be:
--- Code: ---push hl
ld hl,$yyxx
ld (PenCol),hl
pop hl
B_CALL(_DispHL)
--- End code ---
Just be aware it's right-justified in 5 spaces. (Since $ffff is 5 decimal digits, 65535)
EDIT: oh, wait, that's pencol? so this code doesn't work then. Oops... :-[
calc84maniac:
He's talking about graph screen display.
Galandros:
--- Quote from: Quigibo on April 29, 2010, 05:59:58 pm ---Quigibo's Challenge!
Can any of the following be done in 6 or fewer bytes? The input and output must be HL.
* Multiply by 128?
* Signed division by any nontrivial constant, other than 2, including negative numbers?
* Modulus with any constant that is not a power of 2?
--- End quote ---
Challenge accepted.
Answer to the multiplication by 128 in 6 bytes:
I started coding a routine that multiply A by 128:
Spoiler For Spoiler: ; The old trick to multiply by 256, by moving the low byte to high byte
ld h,a
xor a ; resets carry
rr h ; divide h by 2
rra ; and pass bit 0 to a
ld l,a ; store to l
; hl is a*128
After that, I very easily modified to (hl*128)%((2^16)-1). Unsigned version:
Spoiler For Spoiler: ld h,l
xor a
rr h
rra
ld l,a
; 6 bytes and 24 clocks to multiply hl by 128, not bad O_o
I am very sure this routines works but I have not tested.
EDIT4: tested with a few values, it works.
EDIT3:
Multiply hl by 128, now signed. If I am right, to do signed, you only need to preserve the bit 7? If that's so:
Spoiler For Spoiler: ld h,l
xor a
sra h
rra
ld l,a
; 6 bytes, 24 clocks, too
Now I will think about the others when I have more free time. Fun, fun, fun.
Give me some time, please. :)
EDIT: I am thinking in putting some of this challenges in WikiTI when we end the challenge. And maybe Axe's routines. If you have other routines/challenges of optimization share to see what I can do.
EDIT2: fixed a bug/typo and commented even more the code
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version