Author Topic: Weird "Call" command error, please help! (ASM TI-84+)  (Read 12739 times)

0 Members and 1 Guest are viewing this topic.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Weird "Call" command error, please help! (ASM TI-84+)
« on: May 16, 2010, 09:24:11 am »
There's no reason why my script isnt working:
(Do I have to post what's "inside" the calls? I dont think its relevant...)
Code: [Select]
*some codes*
CALL newsprr1n1 ;Just some stuff, not important I think...
LD B, 6 ;
CALL hidemoveshowncount ;
JP Label ;Gets executed, nothing wrong

;But if I do this:
*some codes*
CALL test123 ;Ram-Reset :C
JP Label ;Doesn't get executed. Ram resets the previous line.

test123:
CALL newsprr1n1 ;The EXACT same stuff!
LD B, 6 ;
CALL hidemoveshowncount ;
ret

What is the matter?
Am I missing something obvious?
Why does the call result in a crash?

MAYBE it has something to do with the fact that my program is over 8kB.
I've read (in the ASM-in-28-Days tutorial) that I should keep programs for the TI 84+ below 8kB, but that's impossible since I'm making a game.
But why shouldnt programms be larger then 8kB?

That might not be related to the errors though, I'm just guessing (and I want to know what's the deal with that 8kB limit).

ANY help at all would be greatly appreciated!

*EDIT*

Okay, I'm quite sure it has something to do with the limit now.
I moved the piece of malfunctioning script from the bottom of my script to the top, and now it's working perfectly fine.
Please explain the WHY, and HOW I fix it?
« Last Edit: May 16, 2010, 09:37:37 am by Jerros »


79% of all statistics are made up randomly.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #1 on: May 16, 2010, 12:01:56 pm »
The simplest way to fix it is to turn it into an app, that gives you a 16kb executable limit instead of 8.  Revsoft is down right now, but I think someone might still have a copy of wabbitsign you can use.  The only consideration is that you can't have self-modifying code in an app.  If you do, you have to copy that code to the ram and call it there instead of directly in the app.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #2 on: May 16, 2010, 07:48:42 pm »
Another alternative is to try to turn as many things as possible into data form. For example, in a RPG, if you got NPC convos, store them into memory, same for NPC patterns, enemy stats, possible attacks in battles, or if you're making an action game, store bosses movement pattern into data too instead of hardcoding it. Data doesn't count in that 8 KB code limit since it's not code, just the action of storing the data in memory takes code space.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #3 on: May 17, 2010, 02:00:28 am »
Good advice to turn it into an app, though I don't know how, but that should'nt be hard to figure out.
As for DJ Omnimagas idea, I don't think that's going to be possible in my programm, but thanks for the idea.

I do have self-modifieing code in it (hi-scores, achievements ect.), but you're suggesting I store that outside of the main programm, into a smaller programm just for the scores?
No idea how to, but I'll do some reading and reasearching and stuff.

Thank's for the reply, I've been stuck with big questionmarks for weeks, since I didnt knew a progream should stay under 8 kB, so I was thinking the errors were in my script.
It made me crazy to go over and over the script again, searching for an error that wasn't there...

Thanks.


79% of all statistics are made up randomly.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #4 on: May 17, 2010, 02:26:21 am »
Yeah, I get those all the time.  Once when I was dealing with interrupts, I forgot to save the ix register in my interrupt code and so the program would occasionally start doing some cray stuff and I couldn't find the error anywhere and it took me at least a week to find it after disassembling it line for line and finally realized there was no error.

When I say "outside the main program" I just mean anywhere in the ram, you wouldn't want to write it to a program or any user variable.  It gets confusing becasue you have to change your pointers around when making absolute calls, jumps, and loading and saving from ram since the locations are different than your code.  Fortunately I have some very useful macros that I used in pyoro to simplify this:

Code: [Select]
;Use this instead of a label in any code that is to be copied somewhere else.
#define MAP(name,src,dest) name = ($+0 - src) + dest

;This is just a simple copy routine
#define COPY(src,dest,size) ld hl,src \ ld de,dest \ ld bc,size \ ldir

Here is it used in a useless example before and after:

BEFORE
Code: [Select]
call ClearScrn

ClearScrn:
inc a
dec hl
smc_Gray= $+1
ld a,%10101010
rrca
ld (smc_Gray),a
ret

After
Code: [Select]
;This should be in the beginning of the program
SMCram = appBackupScreen
COPY(SMCrom,SMCram,SMCromend-SMCrom)

;This is how you call the routine (same as before)
call ClearScrn

;This is the routine that will get copied to ram
SMCrom:
;Other SMC code can go here
MAP(ClearScrn,SMCrom,SMCram)
inc a
dec hl
MAP(smc_Gray,SMCrom,SMCram)+1
ld a,%10101010
rrca
ld (smc_Gray),a
ret
;The rest of your SMC goes here
SMCromend:
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #5 on: May 17, 2010, 10:54:06 am »
Brilliant, though I'm not sure I completely understand...
I'm not saving complicated stuff (no routines, just data), just numbers (Hi-Scores ect.).
The way I'm saving stuf now is with:

Code: [Select]
    b_call(_PushRealO1)    ; First line of the programm
stuff
stuff
stuff
LabelQuit:
   b_call(_PopRealO1)
    b_call(_ChkFindSym)
    LD    HL, DataStart - $9D95 + 4
    ADD    HL, DE
    EX    DE, HL
    LD    HL, DataStart
    LD    BC, DataEnd - DataStart
    LDIR
     ret

DataStart:
Score1: .DB 0, 0       ; Here goes the stuff
Points2:  .DB        0           ; I want to save.
DataEnd:

If you can give me a concrete exemple of how I save stuff "outside" the programm, so I can turn it into an APP for the 16kB limit, that would be great.
thnx


79% of all statistics are made up randomly.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #6 on: May 17, 2010, 02:28:00 pm »
Oh, are they just simple non-executing data?  Much simpler!  You can create variables in ram instead of in the rom (as long as they fit there) by just defining them to be there.  If they need to start initialized with some value, just make sure you initialize it all at the beginning of the program.  I also have a macro for variables:

Code: [Select]
#define VAR(name,size) name: \ .org name+(size)

This creates a variable of any size at the current .org position.  I usually define them at the end of the program, but you can put them in the beginning too.

Code: [Select]
;Program goes here
ld   a,(timer)
ld   (score),hl
;End of program

;You can use any safe ram for this.  This is where the variables get stored.
.org appBackUpScreen

;Declare all variables and appropriate sizes
VAR(timer,1)
VAR(score,2)

;This allocates 1 byte to the timer variable and 2 bytes to the score variable.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #7 on: May 17, 2010, 02:37:10 pm »
If you are using SPASM, I have a nicer set of macros. (justified for each case bellow)

There is relocate.inc for relocating easily code. You don't need to use the macro in every jump...
Code: [Select]
relocate($4000)

relocatedcode:
 ;code as usual
 ret

 end_relocate()

And var.inc for variables allocation. You can use it anywhere in your source code and detects overflows.

Code: [Select]
varloc(savesscreen, 768)
player_x = var(1)  ; 1 byte var
player_y = var(1)
saveHL = var(2)

; another place
 varloc(tempswaparea, 323)
array = var(500) ; triggers a error

You can see other useful macros in my macros package here.
Hobbing in calculator projects.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #8 on: May 18, 2010, 02:31:28 am »
Oh, are they just simple non-executing data?  Much simpler!  You can create variables in ram instead of in the rom (as long as they fit there) by just defining them to be there.  If they need to start initialized with some value, just make sure you initialize it all at the beginning of the program.  

Nice, it's working!
And when I edit the program, then re-send it to my calc, the scores won't disappear, which is great to! (else every time I'd release an improved version of my game, all scores/progress would be lost).
I don't really get how it works though, is it save?
Or do the variables easely get overwritten?

Ah, I suppose it doesn't matter.
It's working like a charm right now, so all is fine.
Now I just need to find out how to turn the programm into an app, which I'm sure google will help me with that  ;).

anyway, thank you for this.
« Last Edit: May 18, 2010, 03:03:18 am by Jerros »


79% of all statistics are made up randomly.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #9 on: May 18, 2010, 03:11:19 am »
It is extremely volatile.  If the user runs any other assembly program its very likely all the data you have stored there will get scrambled.  Even the operating system might clear it depending on where you saved it to.  To actually save data permanently, you need to create an application variable.  The TI bcalls make this fairly simple, I assume you have the developer's guide already with all the information about those things.  But I always do the high score stuff last when I program.  Getting the game working first is much more important.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #10 on: May 18, 2010, 03:42:19 am »
Game is practically working (exept that it isn't because of the 8 kB limit).
All thats left is to work out the achievements/score system.
Game is nearly finished, but I'm still struggling with converting my prog to an app.
I found the Wabbitsign tool, but I must be doing something wrong, since i get a "source file open error" when I do what wabbitsign tells me:
It sayd I've got to:

Do the following at the command line to assemble your code into binary format and then sign.

   tasm -80 -i -b infile.z80 outfile.bin
   wabbit outfile.bin App.8xk

So I go to my c:\asm\tasm and there I type the first line (with infile and outfile filled in ofcourse), but then I get that "source file open error".

But first I must learn how to turn my program into an application, THEN i can use AppVars :P



Anyway, I'll struggle on and see where I strand, you've really been a big help Quigibo!
« Last Edit: May 18, 2010, 03:55:43 am by Jerros »


79% of all statistics are made up randomly.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #11 on: May 18, 2010, 03:45:42 am »
When the game is finished, you should announce it in the projects section, as it might get more attention from all members. You can also showcase the project before completion (or future projects) there too.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #12 on: May 18, 2010, 04:16:29 am »
This is the line I've got in my batch script:

"C:\wabbitdirectory\rabbitsign" -g yourfile.bin
« Last Edit: May 18, 2010, 04:17:24 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #13 on: May 18, 2010, 04:56:07 am »
I need to convert the .z80 into a .bin for that...
Can tasm do that?
I've loked into some forums, but all the instructions fail...
Keep getting:

            source file open error on *MyProgram'sName*
« Last Edit: May 18, 2010, 05:15:00 am by Jerros »


79% of all statistics are made up randomly.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Weird "Call" command error, please help! (ASM TI-84+)
« Reply #14 on: May 18, 2010, 12:18:17 pm »
Yes, TASM and SPASM should be able to do this.  I have this line directly before the conversion in tasm:

"C:\tasmdirectory\tasm" -80 -i -b yourfile.z80 yourfile.bin


I attached the fully automated batch file I use, rename it .bat.  You'll have to change some of the directories to where you keep tasm and wabbitsign in.  When you click on the batch file, it searches its current directory, finds the file with a .z80 extension (you should only have 1 per directory, the rest should be .inc), copies some temporary files around needed for compiling, compiles it to an app, and then deletes the temporary files.  Also catches and displays errors.

I think spasm might be better for this, I know it comes with a lot of macros and things to make app compiling a lot easier.  You also need a special header for the app.
___Axe_Parser___
Today the calculator, tomorrow the world!