Author Topic: Random Questions  (Read 15392 times)

0 Members and 1 Guest are viewing this topic.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Random Questions
« on: June 23, 2016, 02:51:13 pm »
Well... I have some random questions... I think I understand asm enough to take responses that way. (Write the code in mimas, decompile it to hex and insert it in my Axe program.)
 I use the on key frequently, but that seems to break the equation evaluator since it counts as basic. Is there any way to clear the ON break error? (I already used runprgm's error handler to no avail.)
What are the arguments for the Axe compile B_CALL? Is it the program name in op1?
Is there anyway to tell for sure if you have memory corruption? The program behaves normally except when it is asked to create a new program. (It behaves weirdly like saying the prgm took up x bytes but displaying many more in the editor.)
In order to find custom tokens in axioms the program reads the compiled axiom. Is there a better way to do that?

That is all I can think of now...
Thanks for any help! (Even if is a link)   ;D
I'm still around... kind of.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Random Questions
« Reply #1 on: June 23, 2016, 03:28:54 pm »
I use the on key frequently, but that seems to break the equation evaluator since it counts as basic. Is there any way to clear the ON break error? (I already used runprgm's error handler to no avail.)

Perhaps res onInterrupt,(iy+onFlags)? Otherwise, I don't really know myself.


What are the arguments for the Axe compile B_CALL? Is it the program name in op1?

Developers\API.txt in the Axe download says:
Quote
####################
#  api_CompileOP1  #
####################
Inputs: OP1 = Name of program to compile
          a = Compile Mode
            bit 0-2:
              0 = No shell
              1 = Ion
              2 = MirageOS
              3 = DoorsCS
              4 = Application
            bit 3
              0 = Regular compile
              1 = Zoom compile
Outputs: none

Compiles the program and then returns



Is there anyway to tell for sure if you have memory corruption? The program behaves normally except when it is asked to create a new program. (It behaves weirdly like saying the prgm took up x bytes but displaying many more in the editor.)

If the memory management menu shows weird values, then your memory is probably corrupted and the calculator will likely crash soon. Should be fixed by a RAM clear (or crash), though.


In order to find custom tokens in axioms the program reads the compiled axiom. Is there a better way to do that?

No, unfortunately you do have to scan through the whole Axiom. Sticking them at the end was the most reasonable way Quigibo/I could think to add them while retaining backwards compatibility.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #2 on: June 30, 2016, 07:08:35 pm »
res onInterrupt works!
I guess before I start programming as too much I need to choose a compiler. Which compiler do you use/recommend?
I'm still around... kind of.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Random Questions
« Reply #3 on: June 30, 2016, 07:51:48 pm »
You mean an assembler? I use SPASM-ng, which has the nice bonus of being able to assemble eZ80. It's basically just a non-dead version of SPASM.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #4 on: July 01, 2016, 03:19:31 pm »
As I'm writing some test programs I found an error I can't figure out how to fix.
I am using SPASM-ng and when trying to compile it errors saying "unregistered opticode hl"
I am using it as "pop hl" Am I missing something?
It may just be the includes file, as I have already had to change bcall to b_call in the includes file.

The axiom readme says that the last argument is in hl. After that they are in the stack in descending order. That means if hl holds the nth argument, after pop-ing to hl, hl would hold the n-1th argument. Right?

Is there any way to compare 2  two byte numbers (without comparing each byte separately) My idea was to subtract them, but it doesn't seem to work...

Thanks for any help!
I'm still around... kind of.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Random Questions
« Reply #5 on: July 01, 2016, 04:09:22 pm »
As I'm writing some test programs I found an error I can't figure out how to fix.
I am using SPASM-ng and when trying to compile it errors saying "unregistered opticode hl"
I am using it as "pop hl" Am I missing something?
It may just be the includes file, as I have already had to change bcall to b_call in the includes file.

Without context, I don't have much of an idea of what could cause this... is the line not indented with at least one space or tab? That would be my only guess. Otherwise, could you post the snippet, or ideally the full program that is producing this error?


The axiom readme says that the last argument is in hl. After that they are in the stack in descending order. That means if hl holds the nth argument, after pop-ing to hl, hl would hold the n-1th argument. Right?

Correct. Commas in function calls are essentially just compiled to push hl.


Is there any way to compare 2  two byte numbers (without comparing each byte separately) My idea was to subtract them, but it doesn't seem to work...

Subtracting should work. But keep in mind that there's no 16-bit subtract instruction, only 16-bit subtract with carry, sbc hl,rr. To get the correct result, the carry flag must be unset. If you're sure that the code leading up to this will always unset the carry flag, you're all set. If not, you need to explicitly unset the carry flag with an instruction like or a.

If you want to restore the original value of hl after the comparison, follow the subtraction with add hl,rr. Note that this doesn't affect the zero or sign flag and will set carry only if sbc hl,rr set it as well, so all useful flags for comparisons should be unaffected.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #6 on: July 05, 2016, 03:39:15 pm »
Yes... I needed to indent...
*rage* no one can force me to organize my code!
I must write code in wall-of-text format! That is the only way!
*snif...* E37 goes to hide behind his wall-of-text Axe programs...
I'm still around... kind of.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #7 on: July 07, 2016, 02:33:41 pm »
I't trying to write a simple axiom that functions in a similar way to the pop and push instructions in SPASM.
Its arguments will be Pop(<start of stack>,<pointer to var location>) and example would be Pop(L1,oA) (the o is the angle character)
Push has the same arguments.
The structure will be: first 2 bytes: current end   3rd and 4th: 1st var 5th and 6th 2nd var.... and so on.
I'm having trouble getting the code to work, as Axe throws error:undocumented
Here is my asm code:

Code: [Select]
#include "includes\ti83plus.inc"
#include "includes\Axe.inc"
#include "includes\tokenhook.inc"
.dw $C0DE

.dw PushEnd
.db %00011111
.dw tFMin
.db %00000000
.db 2
.org 0
ld de,(hl)
pop hl
push de
inc (hl)
inc (hl)
ld de,(hl)
add hl,de
pop de
ld (hl),d
inc hl
ld (hl),e
ret
; {ctr}r,{var1}r,{var2}r,{var3}r
PushEnd:

.dw PopEnd
.db %00011111
.dw tFMax
.db %00000000
.db 2
.org 0
ld de,hl
pop hl
push de
dec (hl)
dec (hl)
ld de,(hl)
add hl,de
pop de
ld a,h
ld (de),a
inc de
ld a,l
ld (de),a
ret
PopEnd:

.dw 0
.dw hFMin
.db 4
.db "Pop("
.dw hFMax
.db 5
.db "Push("
« Last Edit: July 07, 2016, 03:26:59 pm by Runer112 »
I'm still around... kind of.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Random Questions
« Reply #8 on: July 07, 2016, 03:30:28 pm »
You're not assembling that in eZ80 mode, are you? Because I think the seemingly cryptic "Undocumented" error message actually means it encountered an undocumented instruction in the Axiom, which Axe considers an error. The ld de,(hl) instruction you've used a couple of times was added for the eZ80 and is undocumented (does nothing, really) on the z80. If assembling in z80 mode, this instruction should have failed to assemble.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #9 on: July 07, 2016, 07:41:53 pm »
You're not assembling that in eZ80 mode, are you? Because I think the seemingly cryptic "Undocumented" error message actually means it encountered an undocumented instruction in the Axiom, which Axe considers an error. The ld de,(hl) instruction you've used a couple of times was added for the eZ80 and is undocumented (does nothing, really) on the z80. If assembling in z80 mode, this instruction should have failed to assemble.
Thanks I probably never would have found that!
would the replacement be:
ld d,(hl)
inc hl
ld e,(hl)
dec hl
I'm still around... kind of.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Random Questions
« Reply #10 on: July 08, 2016, 02:00:42 pm »
would the replacement be:
Code: [Select]
ld d,(hl)
inc hl
ld e,(hl)
dec hl
That looks like it would work to me.
/e

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #11 on: July 09, 2016, 04:42:39 pm »
What's the best way to store data in an axiom?
I don't want to use free ram...
Is there a way to include data in an axiom? My attempts so far have been unsuccessful.
Do I need to use relative offsets?
I'm still around... kind of.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Random Questions
« Reply #12 on: July 09, 2016, 05:03:02 pm »
What's the best way to store data in an axiom?
I don't want to use free ram...
Is there a way to include data in an axiom? My attempts so far have been unsuccessful.
Do I need to use relative offsets?

You can do this by adding the data as another "command." AxiomSDK.txt explains how to do this:

Quote
;____FIELD 4____
;Description:     Command type
;Size:            1 byte
;Bits:            bit 0 ==> Subroutine instead of inline routine
;                 bit 1 ==> Command requires the r modifier
;                 bit 2 ==> Command requires the rr modifier
;                 bit 3 ==> Additional argument comes before a store token
;                 bit 4 ==> Puts the data pointer in hl (disables auto-replacements)


That may not be worded especially well, but it basically means that using the "command" in an Axe program would simply load a pointer to the data in hl rather than call it as code. Also, you can reference it from other commands in the Axiom using the usual replacement scheme, REP_NEXT \ ld hl,sub_AxiomXX. And if you don't want the user to be able to access the data themselves:

Quote
;____FIELD 3____
;Description:     Token to match
;Size:            2 bytes
;Explanation:     If its only a 1 byte token, make the second byte 0.
;                 If its a 2 byte token, the prefix token should come first.
;                 Leave $0000 if this can only be called from other commands.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Random Questions
« Reply #13 on: July 28, 2016, 02:34:51 pm »
I'm kinda embarrassed but I can't figure out how to reset z
I've tried:
res  z
res  z,0
res  f,(somenumber)

And Spasm errored each time.
What am I doing wrong?

Is there a list of commands and BCALLs with what they affect? That would be really nice when programming.
I'm still around... kind of.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Random Questions
« Reply #14 on: July 28, 2016, 03:47:58 pm »
if you know that a is non-zero then you can do
or a

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!