Author Topic: Flagged! Axiom  (Read 5776 times)

0 Members and 1 Guest are viewing this topic.

Offline ISSOtm

  • LV3 Member (Next: 100)
  • ***
  • Posts: 56
  • Rating: +4/-0
  • Programming or playing games I've programmed
    • View Profile
Flagged! Axiom
« on: May 10, 2015, 12:39:39 pm »
Hello everyone, ISSOtm here !

After working a lot on TI-BASIC, I came back to play with Axe.
However, I also learnt much thanks to Eeems' Learn Assembly in 28 Days (Kudos to him !)

I'm currently porting a big project from BASIC to Axe, and I needed to store flags (for account managing). That's when I realized that Axe lacks bit support ({A}e0 works fine, but there's nothing like 1->{A}e0 to set / reset flags)
So I finally wrote an Axe library (which turned to be composed of assembly code by 99%), then an Axiom.

It allows to write to and read from 3 groups of 8 flags each using hl. (asm programmers : these are asm_flags1 to 3, as you must have guessed)

The code almost works, but there are two problems : one is that one function behaves incorrectly, the other is that the token hook doesn't work... And I don't know why.
Before posting here the final version, I ask help, mainly for the second problem. I don't understand why the token hook doesn't work at all.

Here is a copy of the source code : http://pastebin.com/VJNdRxMh
Programmer ("always start, never finish")

Currently owning :
 - TI 84+SE (crashed by zStart :P )
 - Computer for life



Voir aussi la version française.

Puzzle Master (if you hate mathemathics...)

Also on codewalr.us !

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Flagged! Axiom
« Reply #1 on: May 10, 2015, 02:20:13 pm »
Quote
I'm currently porting a big project from BASIC to Axe, and I needed to store flags (for account managing). That's when I realized that Axe lacks bit support ({A}e0 works fine, but there's nothing like 1->{A}e0 to set / reset flags)

Or you can do {A} or value -> {A}  and {A} xor value -> {A} to set/reset a bit (with value from [1-2-4...-128]  :P

As for token hook doesn't working, quickly looking at the source didn't give me apparent errors, but since you use a lot of SMC, it is kinda hard to see  :-\ Maybe a more experimented axiom coders could tell, or me taking more time to look/test, but time is precious for me these days  ;D
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Flagged! Axiom
« Reply #2 on: May 10, 2015, 02:52:51 pm »
The token hook works for me:




As for functions behaving incorrectly, I see two issues in a first look:
  • The code you use to signal that the next address should be replaced actually signals not to replace the next address. The correct signal is $7F. I'd also advise using the REP_NEXT macro provided by Axe.inc instead of producing the signals manually, although some tweaking may need to be done for it to work properly in some assemblers.
  • All arguments are passed as 16-bit values, but you pop some off the stack into af. This puts the low byte (the one you want) into f, not a. You should pop these arguments into a 16-bit register pair and then move them into a.

Offline ISSOtm

  • LV3 Member (Next: 100)
  • ***
  • Posts: 56
  • Rating: +4/-0
  • Programming or playing games I've programmed
    • View Profile
Re: Flagged! Axiom
« Reply #3 on: May 10, 2015, 03:25:00 pm »
Quote
I'm currently porting a big project from BASIC to Axe, and I needed to store flags (for account managing). That's when I realized that Axe lacks bit support ({A}e0 works fine, but there's nothing like 1->{A}e0 to set / reset flags)

Or you can do {A} or value -> {A}  and {A} xor value -> {A} to set/reset a bit (with value from [1-2-4...-128]  :P

As for token hook doesn't working, quickly looking at the source didn't give me apparent errors, but since you use a lot of SMC, it is kinda hard to see  :/ Maybe a more experimented axiom coders could tell, or me taking more time to look/test, but time is precious for me these days  ;D
If time is precious, go along then.

There only is one instruction modified per function, the last one (with all the .db s). It is a bit / set / res n, (iy+nn).
The goal is to write the offest first, then the correct opcode (for ReadFlag( and WriteFlag( only)

The token hook works for me:


The token hook doesn't work on my TiLeM, nor on my TI 84+.
-> Info : I'm using Axe 1.2.2a. Which one do you use Runer ?

As for functions behaving incorrectly, I see two issues in a first look:
  • The code you use to signal that the next address should be replaced actually signals not to replace the next address. The correct signal is $7F. I'd also advise using the REP_NEXT macro provided by Axe.inc instead of producing the signals manually, although some tweaking may need to be done for it to work properly in some assemblers.
  • All arguments are passed as 16-bit values, but you pop some off the stack into af. This puts the low byte (the one you want) into f, not a. You should pop these arguments into a 16-bit register pair and then move them into a.
pop af places the high byte into a ? Strange, ReadFlag( and WriteFlag( work fine for me, but they use some pop af. I'll check that.
I compile using ClrHome's online assembler (DEVPAC8X doesn't work on my computer for unknown reasons), and when using REP_NEXT it pulls an error.
Quote from: AxiomSDK.txt
;    The following prefixes will change the replacement policy:
;
; $7F         Next instruction is a relative address.
; $40,$Offs   Next instruction is a relative address with an unsigned byte offset.
; $49         Next instruction is an absolute address.
I use ld s on absolute addresses, not relative ones... Did I misunderstand ?
Programmer ("always start, never finish")

Currently owning :
 - TI 84+SE (crashed by zStart :P )
 - Computer for life



Voir aussi la version française.

Puzzle Master (if you hate mathemathics...)

Also on codewalr.us !

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Flagged! Axiom
« Reply #4 on: May 10, 2015, 04:12:31 pm »
-> Info : I'm using Axe 1.2.2a. Which one do you use Runer ?

Same.

I use ld s on absolute addresses, not relative ones... Did I misunderstand ?

Notice each command's code starts with .org 0. This means that all the labels in your code are offsets relative to the start of the code, and the REP_NEXT macro signals that the next 16-bit immediate value is such a relative value to which the actual base address of the code should be added when compiled.

The ABS_NEXT macro signals that the next 16-bit immediate value is an absolute (fixed) value that is not relative to anything and should not be offset.

Offline ISSOtm

  • LV3 Member (Next: 100)
  • ***
  • Posts: 56
  • Rating: +4/-0
  • Programming or playing games I've programmed
    • View Profile
Re: Flagged! Axiom
« Reply #5 on: May 11, 2015, 04:02:56 am »
I use ld s on absolute addresses, not relative ones... Did I misunderstand ?

Notice each command's code starts with .org 0. This means that all the labels in your code are offsets relative to the start of the code, and the REP_NEXT macro signals that the next 16-bit immediate value is such a relative value to which the actual base address of the code should be added when compiled.

The ABS_NEXT macro signals that the next 16-bit immediate value is an absolute (fixed) value that is not relative to anything and should not be offset.
Oh. Okay :P
I knew about the ".org 0" and its pupose, but didn't understand how the prefixes were supposed to be used.

-> Info : I'm using Axe 1.2.2a. Which one do you use Runer ?

Same.
Still, the token hook doesn't work on my setups (both real and emulated). Could you transfer me your compiled program file to see if the problem comes from my calc or the compilator ? Thanks.
Programmer ("always start, never finish")

Currently owning :
 - TI 84+SE (crashed by zStart :P )
 - Computer for life



Voir aussi la version française.

Puzzle Master (if you hate mathemathics...)

Also on codewalr.us !

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Flagged! Axiom
« Reply #6 on: May 11, 2015, 12:59:39 pm »
Still, the token hook doesn't work on my setups (both real and emulated). Could you transfer me your compiled program file to see if the problem comes from my calc or the compilator ? Thanks.

Here it is.

Offline ISSOtm

  • LV3 Member (Next: 100)
  • ***
  • Posts: 56
  • Rating: +4/-0
  • Programming or playing games I've programmed
    • View Profile
Re: Flagged! Axiom
« Reply #7 on: May 11, 2015, 04:03:11 pm »
Your file worked for me. It looks like the problem came from the assembler I was, using (ClrHome's online assembler)

I found an alternative to DevPac8x for my Windows x64, so SPASM gave me a working file (I mean, that correctly replaced tokens on TileM).

I have written a fixed code on paper, it should patch both problems Runer shown up.
It's kinda late right now, I'll compile the code tomorrw.
Programmer ("always start, never finish")

Currently owning :
 - TI 84+SE (crashed by zStart :P )
 - Computer for life



Voir aussi la version française.

Puzzle Master (if you hate mathemathics...)

Also on codewalr.us !

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Flagged! Axiom
« Reply #8 on: May 28, 2015, 05:47:12 am »
Your file worked for me. It looks like the problem came from the assembler I was, using (ClrHome's online assembler)
Sounds like a problem I should look into >.>

Do you know what the issue is? Any info would be really useful.

Meanwhile I'll see what differences ORG and SPASM lead to :)