Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: E37 on June 23, 2016, 02:51:13 pm

Title: Random Questions
Post by: E37 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
Title: Re: Random Questions
Post by: Runer112 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.
Title: Re: Random Questions
Post by: E37 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?
Title: Re: Random Questions
Post by: Runer112 on June 30, 2016, 07:51:48 pm
You mean an assembler? I use SPASM-ng (https://github.com/alberthdev/spasm-ng/releases), which has the nice bonus of being able to assemble eZ80. It's basically just a non-dead version of SPASM.
Title: Re: Random Questions
Post by: E37 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!
Title: Re: Random Questions
Post by: Runer112 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.
Title: Re: Random Questions
Post by: E37 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...
Title: Re: Random Questions
Post by: E37 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("
Title: Re: Random Questions
Post by: Runer112 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.
Title: Re: Random Questions
Post by: E37 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
Title: Re: Random Questions
Post by: Eeems 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.
Title: Re: Random Questions
Post by: E37 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?
Title: Re: Random Questions
Post by: Runer112 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.
Title: Re: Random Questions
Post by: E37 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.
Title: Re: Random Questions
Post by: Sorunome on July 28, 2016, 03:47:58 pm
if you know that a is non-zero then you can do
or a
Title: Re: Random Questions
Post by: Iambian on July 28, 2016, 05:11:31 pm
If you don't particularly care about the state of regis
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.

Flags don't (re)set that way. They're often used to indicate additional effects of a prior operation (such as the particulars of an ADD or SUB operation, or a rotate/shift) but only the carry flag gets special treatment with "scf" and "ccf" instructions.

So in short, no there's no way to directly (and efficiently!) manipulate any flag other than the carry flag. To answer your question, however...

If you don't particularly care about efficiency, you can set the flags register to whatever you want by directly "loading" to it. This destroys all flags, register A, and whatever high byte of a pair you want to push. This uses 21+7 ccs at minimum on a z80:
Code: [Select]
ld c,%01000000 ;sets bits to load to the flags register
push bc
pop af
You can take a look at this page (http://www.z80.info/z80sflag.htm) to learn the bit positions of the other flags in case you want to modify them too.

Now... if you don't particularly care about the contents of register A or the other flags you can do this to reset z:
Code: [Select]
SCF      ;Set carry flag
SBC A,A  ;A-A-1 = $FF. NZ.
Or the following code to set it:
Code: [Select]
OR A     ;Reset carry flag
SBC A,A  ;A-A-0 = $00. Z
Both of the above solutions use 8 ccs on a z80.

As a note (and important if you're exploring other ways to try to mess with just Z), typical shift/rotate instructions (RLC C, RR L, SRL A) will affect Z like you'd think, but their more efficient single-byte version for register A (RLA, RRA, RLCA, etc.) does NOT. Had to learn that the hard way

EDIT: I lied. The bit that started with SCF was to reset, and the one with OR A was to set (post changed to reflect that). Heh. I confuse my thoughts and wording despite the comments themselves being correct.
Title: Re: Random Questions
Post by: E37 on July 28, 2016, 06:24:32 pm
thanks!
Again with the command list thing... I don't actually know what SBC does...
I'm just using the 83plus in 28 days to learn. Is there any better way?
Title: Re: Random Questions
Post by: c4ooo on August 03, 2016, 02:42:05 am
Here is a good list of instructions: http://clrhome.org/table/ :)
(As well as what they do, how many memory they take up, how long they take to execute, and more :P )
Title: Re: Random Questions
Post by: E37 on August 08, 2016, 11:22:34 am
Thanks!
Is there any way to combine two files that fit in ram individually, but together can't? I have 2 very large text files, and can't find a way to combine them.
Title: Re: Random Questions
Post by: Runer112 on August 12, 2016, 09:47:10 am
Thanks!
Is there any way to combine two files that fit in ram individually, but together can't? I have 2 very large text files, and can't find a way to combine them.

You can combine them with a computer-side editor, as you don't have a RAM limitation there. The only limitation you'll still have is that it has to fit in a ROM sector, which means it can be at most about 65500 bytes.
Title: Re: Random Questions
Post by: E37 on August 12, 2016, 05:46:30 pm
Awesome, this would be useful (I was making an on-calc version of the Axe command list) if I hadn't broke my calc.
Here is what I have done:
After a crash I decided to reinstall my 84's OS since it wouldn't get past the ram cleared screen.
Now it will install the OS but fail the validation after 3 seconds and ask for it to be reinstalled again.
I've tried XXX times...
I have unsigned installed, and can't get past the "Waiting... Please install operating system now."

I have used the mode key on the install screen to erase all flash  - many times.
I have tried reinstalling ti connect.
I have replaced all the batteries. (including the backup)
And each time it does exactly the same thing: Successfully transfer the os, validate, then error and go back to waiting for an OS.
Any suggestions? (it has been a day now and no luck)
Title: Re: Random Questions
Post by: Runer112 on August 12, 2016, 05:53:22 pm
Perhaps the boot code flash test (http://wikiti.brandonw.net/index.php?title=83Plus:OS:Secret_Key_Combinations#Battery_.2B_Mode) may help by either revealing a problem or magically fixing one? Also, have you tried sending other OS files, even different versions? Perhaps the one you have is somehow invalid?

Beyond that, I'd wait a bit for the replies of those more knowledgeable about the boot code and hardware, but you may be approaching panic level 6 (http://t.eeems.ca/ASMin28Days/ref/crash.html).
Title: Re: Random Questions
Post by: E37 on August 12, 2016, 05:56:20 pm
Ill try that...
I've had the calc for 3 years. No hope of returning it.
Edit: which one? I've already used ON+mode to clear flash.



Update: Fixed it!
It turns out that instead of sending 2.55MP I was actually sending 2.22. No idea where that came from.
It worked fine with 2.55. I have a copy of 2.22 if anyone wants it. (PM me)
Thanks for all your help!



I have been working on an Axiom that emulates the assembly stack (letting the user pop and push 2 byte variables) but it doesn't seem to work. I've looked it over many times and can't seem to figure out what's wrong. (Y6t acts as (sp)) The command's arguments need a location (ex. Pop (angle)A). Is there a way to have the angle sign inserted automatically?
Spoiler For Spoiler:
#include "includes\ti83plus.inc"
#include "includes\Axe.inc"
#include "includes\tokenhook.inc"
stk   .EQU   AXV_Y6t
   .dw $C0DE
;Push:
   .dw    PushEnd
   .db    AXM_ALL
   .dw    tFMax
   .db    AXM_SUB
   .db    1
   .org    0   
   ld   e,(hl)
   inc    hl
   ld   d,(hl)
   ld    hl,(stk)
   ld    (hl),e
   inc    hl
   ld    (hl),d
   inc    hl
   ld    (stk),hl
   ret
PushEnd:

;Pop:
   .dw    PopEnd
   .db    AXM_ALL
   .dw    tFMin
   .db    AXM_SUB
   .db    1
   .org    0
   push    hl
   ld    hl,(stk)
   dec    hl
   ld    d,(hl)
   dec    hl
   ld    e,(hl)
   ld    (stk),hl
   pop   hl
   ld   (hl),e
   inc   hl
   ld   (hl),d
   ret
PopEnd:
   .dw    0
   .dw    hFMin
   .db    4,"Pop "
   .dw    hFMax
   .db    5,"Push "
Thanks for any help!
Edit: I fixed it. The value of the tokens in the Inc were different than the calc`s...



Is there any way to automatically insert the location sign to an argument in an axiom.
Right now my commands need to be called: COMMAND(oVAR), But I would like to just call them :COMMAND(VAR)
I assume this is possible because commands like the for loop uses a variable instead of a location.

Edit (Eeems): Merging quadruple post