Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Jerros on August 17, 2010, 08:59:27 am

Title: Multi-Page Apps, what's the difference?
Post by: Jerros on August 17, 2010, 08:59:27 am
So my game is getting to big for 1 page, (my compiler sais my header is invalid, though when I remove the last lines of code I've written, I can just compile it like always, so I guess it's getting too big), but simply changing the "2" in the header doesn't seem to work  :) :
Code: [Select]
#INCLUDE "DWEDIT.INC"
.org $4000
.db $80,$0F ;Field: Program length
.db $00,$00,$00,$00 ;Length=0 (N/A for unsigned apps)
.db $80,$12 ;Field: Program type
.db $01,$04 ;Type= Shareware, TI-83Plus
.db $80,$21 ;Field: App ID
.db $01 ;Id = 1
.db $80,$31 ;Field: App Build
.db $01 ;Build = 1
.db $80,$48 ;Field: App Name
.db "MyNameXX" ;Name must be 8 characters
.db $80,$81 ;Field: App Pages
.db $02 ;App Pages = 2                               <-------------- Simply changing this won't do.
.db $80,$90 ;No default splash screen
.db $03,$26,$09,$04,$04,$6f,$1b,$80 ;Field: Date stamp- 5/12/1999
.db $02,$0d,$40 ;Dummy encrypted TI date stamp signature
.db $a1,$6b,$99,$f6,$59,$bc,$67
.db $f5,$85,$9c,$09,$6c,$0f,$b4,$03,$9b,$c9
.db $03,$32,$2c,$e0,$03,$20,$e3,$2c,$f4,$2d
.db $73,$b4,$27,$c4,$a0,$72,$54,$b9,$ea,$7c
.db $3b,$aa,$16,$f6,$77,$83,$7a,$ee,$1a,$d4
.db $42,$4c,$6b,$8b,$13,$1f,$bb,$93,$8b,$fc
.db $19,$1c,$3c,$ec,$4d,$e5,$75
.db $80,$7F ;Field: Program Image length
.db 0,0,0,0 ;Length=0, N/A
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved
.db 0,0,0,0 ;Reserved

So My questions are:
What do I need to change in order to make my header "valid" again?
What's the key difference between having a singe-page App, or multi-paged ones?
How is this going to affect my programming?
What do I need to keep track of with multiple pages?
Is it importand that some things are on the same page? Or can I just randomly do as I please? (probably not :-[)

A lot of questions, but if anyone can share any wisedom it would be great@
Title: Re: Multi-Page Apps, what's the difference?
Post by: TIfanx1999 on August 17, 2010, 09:12:45 am
Others can answer better than I can, but you will likely have to reorganize your code. It is necessary to keep some stuff together, and from what I've heard multipage apps can be somewhat of a pain. D:
Title: Re: Multi-Page Apps, what's the difference?
Post by: ztrumpet on August 17, 2010, 10:12:03 am
I can feel that this will be a great topic.  Here's about all the wisdom I can offer:  When you have more than one page you must deal with page switching.  Since page switching is slow, don't split code that needs to be fast over the boundary.  However, if you just want to include data on the second page I think you'll be fine. :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 17, 2010, 11:20:39 am
How do I decide what data goes on what page, and when it switches pages?
And what data will get lost when switching?
More importantly, how to switch?
Is the only way to interacts between page by an appVar or the AppBackupScreen bytes?
And what do i need to change in my header in order to get it working again?

Really a load of ??? here, and that Developpers guide doesn't help me much at all, I'm still a rookie programmer...
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 17, 2010, 11:27:08 am
Ok, here's the deal:  Your application header is fine.  Since you have a knowledge of ASM, I'll get into a little bit of technical talk, but you can always ask questions if you are confused.

Even though your application is run directly from flash ROM, you can only have access to one application page at a time.  As was said eariler, you need to switch pages to access them.  If you are running a 2-page application, you cannot run page 1 (the second page) until you switch to it from page 0.

Now, your calculator does all this switching for you, but you need to tell the calculator which page to jump to, and WHERE on the page to jump to.  You need what's called a "branch table."  This is where you put all functions (with labels, variables, etc) that must be called from another page.

After your application header, use a "jp" statement to jump to where your program begins. 

Now, you start typing in data for labels that are on your second page.  If there is a label on your second page that your first page needs to call, you need to place it in this branch table.  If there is a label on your second page that ONLY your second page uses, you don't need to type in any data about it.

Suppose you have a label on your second page called Access_Sprite_Data, and you need to call it from your first page.  Remember, your first page is called page 0, and your second page is called page 1. 

The data to tell the calculator about this label should be typed in after your JP statement.  However, make sure that this page data starts on a byte that is a multiple of 3--and I would not be the best person to help you with that.  If it does not start on a byte that is a multiple of 3, add some .db 0 statements until the data is.  We're going to pretend that the data starts on byte 132, which is a multiple of 3.

.dw Access_Sprite_Data        ; The label on the second page that you need to call from the first page
.db 1                                  ; This function is on the second page

Now, let's say you have a third application page, with a timer function.

.dw Adjust_Timer
.db 2

And so on and so forth.  Just remember that you only need to type in functions/labels that are called from another page.

But you're not done yet.  The data is there, but the calculator doesn't know it.  So what you need is a "nickname" for each label in that branch table.  We will use ASD as the nickname for Access_Sprite_Data, and Timer as the nickname for Adjust_Timer.

ASD .equ 44 * 3     ; 44 * 3 = 132.  We need this because the page data for Access_Sprite_Data is on byte 132 of the program.
Timer .equ 45 * 3   ; 45 * 3 = 135, and the data for Adjust_Timer is on byte 135 of the program


Now, to actually call the label, use B_CALL on the nickname.  DO NOT use call, and do not use the actual label name.

B_CALL ASD
B_CALL Timer


If you need to jump to a label instead of calling it, use B_JUMP.

Now, this technique can only be used for labels that can be called and jumped to.  You, unfortunately, cannot use this to access data from another page.  You should have functions on the page with your data to access that data.

The last thing is, you have to tell your compiler which data goes on which page.  But this differs with each compiler (which one are you using?), so that is something I cannot help you with
Title: Re: Multi-Page Apps, what's the difference?
Post by: ztrumpet on August 17, 2010, 11:33:26 am
Wow, that's complex.  Thanks for enlightening us/me.  That's more knowledge than I ever knew about multi page apps.  Thanks Hot Dog! ;D
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 17, 2010, 11:37:29 am
Wow, that's complex.  Thanks for enlightening us/me.  That's more knowledge than I ever knew about multi page apps.  Thanks Hot Dog! ;D

Your welcome! 

Yes, it gets a little bit complicated, and the Developer's Guide can get confusing.  That's why I'm including an appendix in the Z80 ASM lessons about how to write applications -- single and multipage.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 17, 2010, 11:45:25 am
Thanks, I think I get it.
I'll try and see.
Unfortunately, I dont ahve acces to my stuff right now, but I'll edit this, cuz I do still ahev a question or two ^_^
Anyway, thanks alot!

EDIT:

"After your application header, use a "jp" statement to jump to where your program begins."  
Huh? there's just my header, and then, after a long list of #define and "a .equ b" there's just
Code: [Select]
b_call _RunIndicOff
        b_call _GrBufClr
        rest of lines
So where would I do that JP statement?
Doesn't seem necessary either...

Suppose you have a label on your second page called Access_Sprite_Data, and you need to call it from your first page.  Remember, your first page is called page 0, and your second page is called page 1. 

The data to tell the calculator about this label should be typed in after your JP statement.  However, make sure that this page data starts on a byte that is a multiple of 3--and I would not be the best person to help you with that.  If it does not start on a byte that is a multiple of 3, add some .db 0 statements until the data is.  We're going to pretend that the data starts on byte 132, which is a multiple of 3.
How do I check if the byte's on a multiple of 3?
Also, what exactly should be on a multiple of 3?
The label I'm jumping to?
Or the command "JP"?

Thanks again!
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 18, 2010, 08:56:03 am
So, at $4000 on the first page will be the header, which goes to $407F.
The calculator starts execution of the app at $4080. If you want a multipage app, (or rather if you want to run routines on other pages), you'll need a branch table (what was mentioned above). However, you'll need to skip over the table because executing it would not be good, so you'll want to use jp to skip over it. After that you'll need one byte of padding to get to a multiple of three (anything will do, so just use nop). After that, you'll need to add your off-page calls.
Starting at $4084, after the header, jp, and nop, will be the branch table. As Hot_Dog said, first you'll put the address of the routine, then the page, indexed from 0. (So the main page is page 0, the next page is page 1, and so on) As for a "nickname," it would be easiest to adapt a convention for naming them. The one I'll use in the example I'm about to give will be to prefix an underscore ('_') to the label name. For getting what it is divided by three, you'll want to use ($-$4000)/3. Now for an example.
Code: [Select]
;Branch table example
.org $4000
;Header goes here
.org $4080
    jp Start
    nop
;We're now at $4084, and here will be the branch table
;Let's suppose you have a routine called PutSprite on the third page
_PutSprite .equ ($-$4000)/3
    .dw PutSprite
    .db 2
;And a routine FetchData on the second page
_FetchData .equ ($-$4000)/3
    .dw FetchData
    .db 2
Start:
;At the end of the branch table, your code can start
;When you need to run PutSprite, use b_call(_PutSprite)
;Same for FetchData, for which you use b_call(_FetchData)
If you're still confused, feel free to continue asking. :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 22, 2010, 10:11:10 am
Got 1 problem now it seems:
When I compile it, I get an error message on this line:
Code: [Select]
LabelOnPage2_Jump .equ ($-$4000)/3 ; LabelOnPage2_Jump is the nickname for LabelOnPage2
    .dw LabelOnPage2 ; Name of the label on the other page
    .db 1 ; 0=page1   and   1=page2   right?
on the second line, my compiler tells me "Label not found: <LabelOnPage2>"

At the very beginning of the programm, after the header and between all other #defines and .equ's theres:
Code: [Select]
LabelOnPage2_Jump .equ 1*3
I don't know if the 1*3 is correct though, page 2 looks like this:
Code: [Select]
nop
nop
LabelOnPage2:
...rest of things
Also, how do I keep track of the location of the labels on the second page?
The first label is easy, I assume that line 1 = byte 1, so adding 2 nop's made the label be at byte 3.
But how do I keep track of labels further down in the programm?

Thank you!

EDIT: Ok, I realize now that I have a duplicate label, since I have both:
Code: [Select]
LabelOnPage2_Jump .equ 1*3
and
Code: [Select]
LabelOnPage2_Jump .equ ($-$4000)/3 ; LabelOnPage2_Jump is the nickname for LabelOnPage2
    .dw LabelOnPage2 ; Name of the label on the other page
    .db 1 ; 0=page1   and   1=page2   right?
Fixed that by only using the secon thing (the 3-lines one), but the problem is still that it gives the "Label not found" message I described earlier.
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 22, 2010, 07:19:39 pm
Hm... How is the assembly source structured and what assembler are you using? That can influence how labels are handled.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Builderboy on August 22, 2010, 08:42:21 pm
Im curious as to what happens if you have a second page with only data and no actual code?
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 22, 2010, 08:47:53 pm
Im curious as to what happens if you have a second page with only data and no actual code?

You could probably theortically access this data, but if so it's a lot more complicated than meets the eye.  If you try to access it simply by using code from your first page, you could crash your calculator.  It's much easier to load it with your own code on the data page.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Builderboy on August 23, 2010, 01:06:01 am
Ah i see, im asking because of Axe parser, i was wondering if 2 page apps might be possible if there was only data on the second page, as quigibo already said how page switching for code was not going to happen.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 02:15:23 am
Hm... How is the assembly source structured and what assembler are you using? That can influence how labels are handled.
I'm using "AppDev".
It needs 2 seperate .z80 files for 2-paged apps, one named "Name" and the other "Name2".

I've kinda figured alot out by now, though my asseblrer wants the specific offset for the labels I jump to, which I really wouldn't know:
Code: [Select]
JumpToLabelPage2 = $ - $4000
  .dw $4000                                 ; <-- if its the first line of the page, it'd be this. How do I know the offset of labels further down the programm?
  .db 1

;Why is there big empty space down here? Mods?
So... how do I know the offsets of the labels in the programm?
And ehh, I can have lables with the same name on page1 and page2 right?
Title: Re: Multi-Page Apps, what's the difference?
Post by: matthias1992 on August 23, 2010, 05:24:45 am
Im curious as to what happens if you have a second page with only data and no actual code?

You could probably theortically access this data, but if so it's a lot more complicated than meets the eye.  If you try to access it simply by using code from your first page, you could crash your calculator.  It's much easier to load it with your own code on the data page.
that's: ouch. So basically you can't have a game engine on page 0 and game data on page 1. That sucks, leads to alot of duplicate code i guess...or am I misunderstanding?
Title: Re: Multi-Page Apps, what's the difference?
Post by: BuckeyeDude on August 23, 2010, 08:06:45 am
Im curious as to what happens if you have a second page with only data and no actual code?

You could probably theortically access this data, but if so it's a lot more complicated than meets the eye.  If you try to access it simply by using code from your first page, you could crash your calculator.  It's much easier to load it with your own code on the data page.
that's: ouch. So basically you can't have a game engine on page 0 and game data on page 1. That sucks, leads to alot of duplicate code i guess...or am I misunderstanding?
If its pretty small then yeah you can duplicate it or if its speed critical. Most of the time anything like data is stored on a separate page(s) and then loaded into RAM (this also conveniently encourages you compress your data) since your ram page is visible to any app page.

Also Jerros, I'm going to shamefully plug spasm here, but there is really not a much simpler way to build a multipage app. And since im pretty sure AppDev uses TASM any code you've written is (hopefully) compatible. SPASM is here (http://wabbit.codeplex.com/releases/view/45088). Once you've got that download app.inc (http://group.revsoft.org/app.inc) and put it in the same directory as your project.

Code: [Select]
#include "ti83plus.inc"
#include "app.inc"
defpage(0, "MyApp")
;for bcallin
_AddHLOne .equ $ - $4000
.dw AddHLOne    ;i think address comes first...
.db 1
;all code on page 0 goes here
 ld hl,0
 bcall(_AddHLOne)
 bcall(_JForceCmdNoChar)
defpage(1)
;oh look an incredibly efficient routine on page 1 :D
AddHLOne:
 ld de,1
 add hl,de     ;lalala
 ret        ;impossible to optimize btw ;)
validate()
And then run
Quote
spasm -T -L infile.asm outfile.8xk
in the command prompt (or I recommend creating a .bat file). And boom multipage app. I think the code i wrote will work, but its like 5 am here so yeah i'm starting to crash :/

I should also mention that if you need some better speed than TIs bcall routine (which require 800-1000 clocks overhead), you can write your own page swap routine. Its not terribly difficult, just load it to ram, and mess with port 6. I might post one later, but I can guarantee whatever I write now won't work :P
Title: Re: Multi-Page Apps, what's the difference?
Post by: calc84maniac on August 23, 2010, 08:29:01 am
You forgot the JP after the header, btw. You don't want to be executing the .dw/.db data.

And you can access data on the other page easily using the flash reading bcalls. I believe this is what is planned for multi-paged apps in Axe (and reading from archived files already uses this method)
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 09:35:23 am
I can plug Brass :)
Modifying your post, I get this.

Code: [Select]
.binarymode ti8xapp
.variablename "outfile"
#include "ti83plus.inc"
.defpage 0,$4000,$4000 ;Define pages 0 and 1
.defpage 1,$4000,$4000

.page 0 ;Page 0 goes here
.block 128 ;Set aside 128 bytes for the header
    jp Start ;Jp over the branch table
    .branch AddHLOne
Start ;Colons after labels are optional
    ld hl,0
    bcall(_AddHLOne)
    bcall(_JForceCmdNoChar)
.page 1 ;Page 1 code goes here

AddHLOne
    ld de,1
    add hl,de
    ret
And then run
Code: [Select]
brass infile.asmin the command prompt. You'll get two files. A raw hex file "outfile.hex" and a signed app "outfile.8xk"
Title: Re: Multi-Page Apps, what's the difference?
Post by: thepenguin77 on August 23, 2010, 10:01:35 am
Ok, I feel like I need to say this. There is another hacky way that you can get info off the second page of your app, or any flash page for that matter.

Code: [Select]

ld (saveSP), hl

ld a, 1
out (05), a ;puts ram page 1 in $C000, (it's usually page 0)

in a, (06)
inc a
out (07), a ;puts second page of app in $8000

ld sp, textShadow+$4000 ;anywhere will work as long as it's free

;now you access your variables+$4000 because they
;are swapped into $C000 instead of $8000

ld a, 4
ld (enemies+$4000), a

;even cooler yet, you can put ram routines way out in the
;$C000 region and execute them

ld hl, doStuff
ld de, statVars+$4000
ld bc, doStuffEnd-doStuff
ldir

call statVars+$4000

;or you can call a routine on the second half of your app

call secondPageRoutine ;it's address is ($9123) or something

ld a, $81
out (07), a ;ram page 1
xor a
out (05), a ;ram page 0

ld sp, (saveSp)

ret


doStuff:
ld a, 5
ret
doStuffEnd:

This essentially makes your app run from $4000 through $8000 to $C000. You could actually even have your second page .org $8000 and just run it like this. The only downfall is that you can't use bcalls. You would either have to make a bcall routine that puts memory back to normal and calls it, or not use bcalls.

Edit:
   Just realized why no one does this. It won't work on an 83+. That doesn't bother me, but you might want it to work on those.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 23, 2010, 10:08:57 am
Quote
There is another hacky way that you can get info off the second page of your app, or any flash page for that matter.


/me just learned something new ;D
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 10:10:33 am
The only problem with that is it doesn't work on the 83+, for which RAM page 0 is permanently in $C000-$FFFF in memory map mode 0. There's no good way to do it in memory map mode 1, either, or I would write one.
Edit: Ninja'd :P
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 10:22:19 am
I've kinda figured alot out by now, though my assembler wants the specific offset for the labels I jump to, which I really wouldn't know:
Code: [Select]
JumpToLabelPage2 = $ - $4000
  .dw $4000                                 ; <-- if its the first line of  page2, it'd be this. How do I know the offset of labels  ?
  .db 1                                        ;  further down the programm?

;And mods, I didn't put the big empty space down here?
Also, these^ things work fine if I just put these^ kind of jump things anywhere in the programm.
Why put 'em on top and JP to your ProgStart?
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 10:25:41 am
Again, what assembler are you using and how is your source formatted? Are you using one file per page or one file for the whole app?
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 10:43:12 am
One .z80 file per page.
Page 2 looks like this:
Code: [Select]
#DEFINE NOAPPHEADER
#INCLUDE "DWEDIT.INC"
...
Long list of #defines and .equs
...
FirstLabel:                         ; When I need to call this one it's easy, gotta fill in $4000 and it works
                             ; Becomes a problem when I need the offset of"labels further down.
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 10:55:20 am
Ah, that's the problem. Since they're assembled one page at a time, each page is unaware of the other's labels.
Depending on what assembler you're using, you could make the whole app one file (BuckeyeDude and I gave examples for Spasm and Brass).
But, if you insist on doing it this way, you have two options. The first is to have each page file included in a larger file, but your assembler still has to support multiple pages in one file. The other option is to make use of the export directive, but this entails adding another #include to the first page and means you have to assemble the first page last.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 11:12:49 am
Quote
author=calcdude84se link=topic=4102.msg57402#msg57402 date=1282575320]
Ah, that's the problem. Since they're assembled one page at a time, each page is unaware of the other's labels.
Nono, fixed that already.
This assembler works like a charm, and I don't really feel like spending another week learning the psychology of a new assembler ><
My only problem is that it needs to know the offset.
AppDev doesn't even need me to do the:
Code: [Select]
JumpToLabelPage2 = $ - $4000
  .dw $4000
  .db 1
at the start of the program, anywhere will do. (saves a JP statement n_n)
My problem is that I only know the offset of the first label on page 2 ($4000, duh), but I'd like to know how to point at any other label too!
And for that, I need to know the offset of a label, which I don't.
Of course it's possible to do everything with only that one jump, but that's rediculous since there's got to be a way to check the offsets of my labels. ^_^
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 11:29:08 am
No... you need to jp to the start of the code, skipping the branch table.
And the "offset" you're talking about is the label on the second page.
That .dw should be followed by a label name on the second page. But since they are different files, you get the problem I listed.
Sorry if I sound rude, but one or both of us are very confused. :(
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 11:35:10 am
About the branch table thing - I dont put that at the start of my programm, and it still jumps to the right place on page 2.
Since I dont put it at the start, there's no need for the JP to the ProgStart either. :P
And appearantly my assembler doesn't want the label name after the .dw, it wants the offset.
Like I said, If my label is the first thing on  Page2 i just put $4000 there, but I don't want to manually count every line to calculate what offset the other labels are at, that's insane!
Of course I could load a number in AppBackupScreen and then make a jump table at the first label of Page 2, which isnt much work or takes much room, but it's still cheating and a way of hiding my incompetence as a programmer, ghehe...
And I'm not having ANY problems at the moment, everything is working fine.
Well, I still can't jump to anyhing but the first label on page 2, but you now know why that is ;)
And don't worry, you aren't sounding rude.
I should've made muself much much more clear, you're no psychic.
I'm already overwhelmed by the many people willing to help me, and they're helping me ALOT, so thank you!
Title: Re: Multi-Page Apps, what's the difference?
Post by: calc84maniac on August 23, 2010, 12:16:14 pm
Just put the label after the .dw statement. That's what labels are for, so you don't have to calculate manual offsets ;)
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 23, 2010, 12:29:36 pm
Just put the label after the .dw statement. That's what labels are for, so you don't have to calculate manual offsets ;)
Ye, but I'm pissing off my assembler with that.
When I put the name of a label there, it gives the "label not found" message.
I HAVE to put the offset there.
But like I said, if there's really no way to check the offstes of my labels, I'll just make a jump table at the top of Page2.
It might even save space, since I don't need the branch table.
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 23, 2010, 01:35:04 pm
About the branch table thing - I dont put that at the start of my programm, and it still jumps to the right place on page 2.
The branch table is the pairs of .dw's and .db's. Unless you're not using the code you posted, you have a branch table.
Since I dont put it at the start, there's no need for the JP to the ProgStart either. :P
Same as above. Are you using the code you posted?
And appearantly my assembler doesn't want the label name after the .dw, it wants the offset.
As calc84 said, labels pretty much are offsets. The assembler doesn't like it because it's in a different file. You might have to move away from TASM, or at least AsmDev.
Like I said, If my label is the first thing on  Page2 i just put $4000 there, but I don't want to manually count every line to calculate what offset the other labels are at, that's insane!
I think I've already responded to this :P
Of course I could load a number in AppBackupScreen and then make a jump table at the first label of Page 2, which isnt much work or takes much room, but it's still cheating and a way of hiding my incompetence as a programmer, ghehe...
That's slower, not to mention unnecessary.
And I'm not having ANY problems at the moment, everything is working fine.
Well, I still can't jump to anyhing but the first label on page 2, but you now know why that is ;)
Yes we do :P
And don't worry, you aren't sounding rude.
Good :)
I should've made muself much much more clear, you're no psychic.
I'm already overwhelmed by the many people willing to help me, and they're helping me ALOT, so thank you!
We're trying our best :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 24, 2010, 02:30:46 am
The branch table is the pairs of .dw's and .db's. Unless you're not using the code you posted, you have a branch table.
My layout:

- Header
- Bunch of .equ's and #define macros
- Program just starts, in my case with:
Code: [Select]
b_call _RunIndicOff
        b_call _GrBufClr
- rest of programm
- somewhere in the middle there's:
Code: [Select]
JumpToPage2 = $ - $4000
  .dw $4000  
  .db 1
- and then rest of programm

So I don't see why the JP as first line of the programm is necessary with this. :P

That's slower, not to mention unnecessary.
The speed difference is neglectable, right?
Besides, there's no need a that point in my program to be fast, so that shouldn't be a problem.
As for the size difference, it might be ~20 more lines, hardly worth noticing.
It absolutely unnecessary, no can argue with that. :)
As calc84 said, labels pretty much are offsets. The assembler doesn't like it because it's in a different file.
I know, but there should be a way to get the actul offset of the labels right?
I'd rather do the nooby jump table at the start of the second page than switching to another assembler...
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 24, 2010, 08:44:49 am
Hm... Looking at it, you don't actually have to have the branch table at the beginning. Good for you, figuring that out :)
Don't you need ($-$4000)/3 rather than $-$4000, though? Anyway, if you edit AsmDev's batch files somewhat (and change your source a bit), you won't have to go away from AsmDev and TASM.
In short, you'll need to change the compilation order to compile the first page last, add export directives to all pages except the first, and add an #include to the file for the first page so it includes the labels exported from the other pages.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 24, 2010, 08:54:10 am
Don't you need ($-$4000)/3 rather than $-$4000, though?
($-$4000)/3 doesnt work.
$-$4000 does.
I don't know why, I just like it when things do.
Anyway, if you edit AsmDev's batch files somewhat (and change your source a bit), you won't have to go away from AsmDev and TASM.
In short, you'll need to change the compilation order to compile the first page last, add export directives to all pages except the first, and add an #include to the file for the first page so it includes the labels exported from the other pages.
Huh...?
I'm sorry, but I think I'm going with my nooby "jump tree at start of second page" plan.
It's slower, takes more space, but works NOW without me having to learn anything new ^_^
That a completely wrong attitude, and I'm prbably shooting myself in the foot with it, but I just love it when things work.
I don't know why or how, they just do. (which has often resulted in random crashes because I had no idea what the heck I was doing).

You've helped me ALOT though, thanks.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 24, 2010, 10:22:57 am
Quote
Don't you need ($-$4000)/3 rather than $-$4000, though?

($-$4000)/3 doesnt work.
$-$4000 does.
I don't know why, I just like it when things do.

In some assemblers, / doesn't work for division, and for good reason.  Instead, it's like the TI-Basic colon, allowing one to place more than one ASM instruction on the same line.
Title: Re: Multi-Page Apps, what's the difference?
Post by: calc84maniac on August 24, 2010, 10:26:31 am
Quote
Don't you need ($-$4000)/3 rather than $-$4000, though?

($-$4000)/3 doesnt work.
$-$4000 does.
I don't know why, I just like it when things do.

In some assemblers, / doesn't work for division, and for good reason.  Instead, it's like the TI-Basic colon, allowing one to place more than one ASM instruction on the same line.
You are thinking of backslash ("\"). "/" is division in every assembler I know of.

And Jerros, how are you specifying the second page of code? I'm only familiar with app building in spasm.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 24, 2010, 10:32:44 am
Quote
Don't you need ($-$4000)/3 rather than $-$4000, though?

($-$4000)/3 doesnt work.
$-$4000 does.
I don't know why, I just like it when things do.

In some assemblers, / doesn't work for division, and for good reason.  Instead, it's like the TI-Basic colon, allowing one to place more than one ASM instruction on the same line.
You are thinking of backslash ("\"). "/" is division in every assembler I know of.

So then with integer division, is the answer rounded in case of a decimal answer?
Title: Re: Multi-Page Apps, what's the difference?
Post by: calcdude84se on August 24, 2010, 10:33:47 am
He's using AppDev (http://www.ticalc.org/archives/files/fileinfo/323/32393.html)
From what I can tell, it uses TASM, and each page is in a different file, which is causing his label problems.
My solution was to edit AppDev's .bat files and use export to allow using the second-page labels on the first.
Edit: Oh, and I forgot to mention this earlier. If your branch table isn't right after the app header, you do need to make sure it is at an address divisible by three after subtracting $4000.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 25, 2010, 02:32:33 am
Oh, and I forgot to mention this earlier. If your branch table isn't right after the app header, you do need to make sure it is at an address divisible by three after subtracting $4000.
... Never paid attention to that, but even after editting it still works.
Maybe I'm lucky and it the adress is divisible by 3 each time, though I don't know.
Title: Re: Multi-Page Apps, what's the difference?
Post by: calc84maniac on August 25, 2010, 08:17:18 am
Oh, and I forgot to mention this earlier. If your branch table isn't right after the app header, you do need to make sure it is at an address divisible by three after subtracting $4000.
... Never paid attention to that, but even after editting it still works.
Maybe I'm lucky and it the adress is divisible by 3 each time, though I don't know.
I'm about 99% sure that any address within the app should work, and the "multiple of 3" thing is just a result of silly TI documentation. Because the *only* way that the remainder when divided by 3 would matter is if TI actually divided it by 3 in the bcall routine, which I am very sure they don't.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 25, 2010, 10:20:44 am
Oh, and I forgot to mention this earlier. If your branch table isn't right after the app header, you do need to make sure it is at an address divisible by three after subtracting $4000.
... Never paid attention to that, but even after editting it still works.
Maybe I'm lucky and it the adress is divisible by 3 each time, though I don't know.
I'm about 99% sure that any address within the app should work, and the "multiple of 3" thing is just a result of silly TI documentation. Because the *only* way that the remainder when divided by 3 would matter is if TI actually divided it by 3 in the bcall routine, which I am very sure they don't.

In that case, they said exactly what I would say if I were TI..."We've done it for years this way, and it works perfectly and easily, so you should do it the way that WE do it.  Don't bother us with questions if you have problems simply because you decided to try a different route."
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 26, 2010, 03:44:17 am
Don't bother us with questions if you have problems simply because you decided to try a different route."

Q_Q
Sorry, my origional question has been answered.
It's just that someone else said I was doing it wrong when I posted the piece of script.
So I just asked why it was wrong, because it was working fine.
I know I've been a nuisance throughout the last couple of months.
But look at it on the bright side, if a new programmer would read all my questions and all your answers, they can just skip all tutorials and get right at it ;)
Title: Re: Multi-Page Apps, what's the difference?
Post by: DJ Omnimaga on August 26, 2010, 03:52:43 am
I don't think Hot Dog meant it the wrong way. I am unsure if it was directed at you. I am confused, though, about what he meant. In any case, don't feel bad if you make mistakes. Everyone gotta start somewhere and with z80 assembly, there is a lot to understand. From what I notice you seems to learn pretty fast. (I myself tried 3 times to learn ASM so far and no luck ;D)

Normally Hot Dog doesn't respond harshly to other members, which tells me that he might have misworded his post or forgot a part. If it was really meant as rude, then he needs to know those responses are not wanted on the forums, because Omnimaga is supposed to be welcoming to new members who want to learn and our motto is that "everyone gotta start somewhere". :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: ztrumpet on August 26, 2010, 10:14:14 am
In that case, they said exactly what I would say..."We've done it for years this way, and it works perfectly and easily, so you should do it the way that WE do it.  Don't bother us with questions if you have problems simply because you decided to try a different route."
I believe Hot Dog is saying that if He were TI then...

Does that clear it up? :)

Jerros, sorry if you were offended, but I'm sure Hot Dog didn't mean it badly.  These are good questions, and I'm sure I'll use this thread when I make Multi Page Apps of my own. :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: Hot_Dog on August 26, 2010, 11:12:34 am
Don't bother us with questions if you have problems simply because you decided to try a different route."

Q_Q
Sorry, my origional question has been answered.
It's just that someone else said I was doing it wrong when I posted the piece of script.
So I just asked why it was wrong, because it was working fine.
I know I've been a nuisance throughout the last couple of months.
But look at it on the bright side, if a new programmer would read all my questions and all your answers, they can just skip all tutorials and get right at it ;)

Man, I'm really sorry, Jerros.  The quote was directed at TI, not at you.  So I hope you'll still feel welcome.  The others were right, it was an accidental miswording and I was shocked to see that I had typed it out wrong.

We've known TI to not be very through in answering questions.  But I hope you always feel welcome to bring any questions you have to this site.

I think I will accidentally come out the wrong way if I try to explain what happened, but I hope you understand that nothing was directed toward you.  I was glad to see that you brought this question to use as opposed to another site, and I was happy to do my part in helping you out.
Title: Re: Multi-Page Apps, what's the difference?
Post by: Jerros on August 27, 2010, 02:15:12 am
Wasn't offended, haha.
People are making a big deal out of this.
Sorry that my incapability of reading things right has caused trouble for you, HotDog >.<

That being said, back on-topic.
Though there's not much to be said anymore, thanks to you helpfull people I can now go on with my work. :)
Title: Re: Multi-Page Apps, what's the difference?
Post by: DJ Omnimaga on August 27, 2010, 02:26:36 am
No problem. Feel free to ask more questions if you need more help :)

By the way, I tend to get worried if someone gets offended or risk being offended because I have been in the TI community for 9 years and in the past, I saw people leave forums due to offensive posts. Everyone is different so we need to be careful, since the new members who come to learn are the ones who will keep the community alive as older member leave.