[TI-ASM]Overwriting labels

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

[TI-ASM]Overwriting labels

Post by LolBbq »

If I had the following somewhere down in my code:

Code: Select all

Overwriting:
.db $FFFF
DontOverwrite:
.db $FFFF
and then stored 768 bytes to Overwriting, would it flood over into DontOverwrite? And how could I make it so I can do so without disturbing contents in DontOverwrite?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Yes, it would overflow.

Note that .db $FFFF will only store one byte, $FF. If you want to store two bytes ($FFFF), use .dw instead of .db.

You cannot prevent this from happening (at least, not on the TI hardware). What do you really intend to happen?

What are you trying to do? "Variables" in the assembly sense are not like variables in the TI BASIC sense.
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

I was trying to think how to store a large undetermined amount of values to a buffer space that would expand with it. Would moving the label with the buffer space to the very last line work?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

You'd need to somehow allocate that space in the first place, and keep another variable as a pointer to the current position you're writing to.

It's a pretty mucky thing to be doing. I, personally, would use the TIOS variable functions to create a large program file on the calculator, and read and write data to and from it. If you look in the manual, there are documented ROM calls to create a program, open it for editing (which allocates all of the free memory to it, IIRC) then closing it so it snaps back down to only take as much room as required.

I cannot help you more explicitely, as I have not done something like this myself.

If the maximum amount of data you wish to write is relatively small (<768 bytes, for example), you could get away with using one of the safe RAM areas to write to.
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

Yep, I also thought of the option of writing all that to a fully protected program file. Although isn't that option a bit slower than writing and reading directly from the program's local variables?

Also, is it possible to define or create your own tokens that could function similarly to the existing tokens for the TI-OS?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

It's just RAM, so no, it would be just as fast. The slowness would come from having to update the TIOS pointers as well as your own pointers so it knows how much space the edited program takes up when it closes it after editing, but you could only update those at the end.

I've heard of a clever trick where you can insert all the free RAM into the end of the currently running program, but I've never attempted it myself.
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

Thank you very much, I understand it quite a lot better now. :)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

What sort of variables are you using anyway? pictures? TIfloats? words? bytes?
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

I'm attempting to make a better asm on-calc assembler, and for the compiler, it reads off the editor's saved instructions and converts them into the appropriate binary opcodes (not the tokens that would represent the program in hex, such as "tAsmProgm,tE,tF,tC", etc. The thing is right now I have barely a clue how to go about doing this, although I'm always willing to learn. 8)
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

King Harold tried this recently, and made some progress on an on-calc assembler. If you need help getting started on it, I'm sure he'd be happy to help you. :)
In Memory of the Maxcoderz Trophy Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

You should know the size of the assembled program after the first pass.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

And don't forget to store the adres of every label, and handle defines and includes, and in the second pass you must check whether relative jumps exceed their jump-limit and give an error if one does, and ZIX instructions have the variable byte at a weird place..
All in all its a real pain, but it can be done.. (mine's still crashing, but im working on it)
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

But still, is it possible to make your own tokens like Omnicalc etc?
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

it is, but why would you want to?
(you might want to look into the parserhook and tokenhook)
the parserhook is very easy to use (well, comparatively)
LolBbq
New Member
Posts: 20
Joined: Thu 23 Nov, 2006 3:01 pm

Post by LolBbq »

I want to make the assembler/editor have tokens, which would increase ease of programming (instead of typing on the awkward "keyboard" on the calc). It would be similar to TI-BASIC tokens, but I don't know how to "define" tokens.
Post Reply