* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Axiom LUT Troubles  (Read 1923 times)

0 Members and 1 Guest are viewing this topic.

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Axiom LUT Troubles
« on: January 09, 2015, 05:41:10 pm »
So im trying to do a fast square in an Axiom.
im using a LUT i generated but it keeps outputting the wrong values.
Code: [Select]
.dw ShdDraw_
.db AXM_ALL
.dw $00F3
.db AXM_SUB
.db AXM_1ARG
.org 0
ld l, 0
call squareL
bcall(_DispHL)
bcall(_getKey)
ret

; square l, return in hl
squareL:
ld hl, (SqLUT)
ret

SqLUT:
.dw $0000, $0001, $0004, $0009, $0010, $0019...
ShdDraw_:
This is the code for the Command, and obviously the LUT is way bigger so i stripped it a bit down.
For debugging purposes i print the first byte at hl, which should be 0 but isn't...
Anyone got an idea of what im doing wrong? q.q

EDIT: Looks like it's something with a 16-bit load command
EDIT2: I have the 0! now for the rest of the values...
EDIT3: Okay so i did some data analysing...
Seems like verything up until 22 goes OK... then
23^2 is 39598... then the values are offset 1 for a few numbers (eg 25^2 displays as 26^2)
after a while its just random values...
also my code now looks like this:

Code: [Select]
squareL:
ld h, 0
sla l
rl h ;l*2 in hl
REP_NEXT
ld de, SqLUT
add hl, de ; address in hl
dec hl
ld d, (hl)
inc hl
ld e, (hl)
ex de, hl
ret

SqLUT:
.dw $0000, $0001, $0004, $0009, $0010, $0019, $0024, $0031... etc
EDIT4: Ok so ive narrowed the problem down to the loading the address into hl part...
Code: [Select]
ld hl, SqLUT + 96  ; for debugging purposes, this is one of the faulty numbers (48)
dec hl
ld d, (hl)
inc hl
ld e, (hl)
ex de, hl
EDIT5: My god... it finally works... don't have any dea of how i fixed it though...
EDIT6: Oh nvm, it worked in my test program... not in the axiom (im getting tired of this)
EDIT7: I finally got it working! :D
If someone wants to know what the correct way is:
Axe uses a few bytes for special things (like loading into 16bit registers). If those bytes are in your data,
axe will replace them and everything will fail :(.'
The solution is to make another Axiom command, but with AXM_DATA as type.
The special bytes will not be applied to commands with this byte set.

Code: [Select]
.dw some_command_
.db AXM_ALL
.dw token
.db AXM_SUB
.db AXM_1ARG
.org $0000
REP_NEXT ; don't forget
ld hl, sub_Axiom2 ; replace the 2 with whatever # command your data block is at
; start of the data address is now in hl
some_command_:

.dw data_block_
.db AXM_ALL
.dw $0000   ; it can only be called from other commands
.db AXM_DATA
.db AXM_1ARG
.org $0000
; data here
data_block_:
« Last Edit: January 10, 2015, 12:32:42 pm by Cumred_Snektron »


  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Online xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18739
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #1 on: January 10, 2015, 05:32:24 am »
Sorry to hear that it doesn't work still. Hopefully someone can help soon (although I think only one or two CodeWalrus members know ASM >.<). If you don't get any help, you might need to ask Runer112 on Omnimaga since he's the current maintainer of Axe.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #2 on: January 10, 2015, 11:16:48 am »
Yeah i think ill probably have to do that
EDIT: IT WORKS! :D
« Last Edit: January 10, 2015, 12:18:07 pm by Cumred_Snektron »
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Online xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18739
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #3 on: January 10, 2015, 12:30:23 pm »
Awesome to hear :D. Could you tell us what caused the problem?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #4 on: January 10, 2015, 12:33:32 pm »
I've already updated the post :P
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Online xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18739
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #5 on: January 10, 2015, 07:08:52 pm »
Not sure if I understand. Was it some sort of data usage conflict?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Thecoder1998

  • New User
  • Join Date: Dec 2014
  • Location: Not sure
  • Posts: 15
  • Post Rating Ratio: +0/-0
Re: Axiom LUT Troubles
« Reply #6 on: January 10, 2015, 10:00:48 pm »
Nice work!

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3165
  • Post Rating Ratio: +32/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • quantuminfinity
  • Gender: Male
Re: Axiom LUT Troubles
« Reply #7 on: January 10, 2015, 11:28:49 pm »
Not sure if I understand. Was it some sort of data usage conflict?
Sort of...
Since axioms are not always in the same ram area (eg if theres code before the command), axe updates it when it compiles the program.
This means the addresses of each call, jump etc needs to be  changed as well, However, it does not change 16-bit loading (like labels).
To make this manually happen is to place a special byte 7F, 40 or 49 before the command. If the data contains one of these characters, it gets removed.
In order to keep the data intact, it needs to be placed in a special "command" with as type AXM_DATA. Then, one can load the starting address of this command
with ld rr, sub_Axiom# (where # the #'th command in the axiom is), prefixed with 7F.
Since the byte gets removed during compilation, we need to tell the assembler that it's "not there". Axe included a small define for this in it's include file, "REP_NEXT".
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games