Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: the_mad_joob on April 18, 2014, 08:36:45 am

Title: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 08:36:45 am
Hey there.
I have 2 questions, actually :

1) the swap sector
According to TI offcial documentation (pdf), it can only be either the first ($08>$0B) or the second ($0C>$0F).
According to wikiti, it can be any of the sectors.
I made some quick tests, and it seems that the OS uses only the first & second, but i'd like to be sure...

2) the sector status byte
We're assuming the sector i'm talking about doesn't include any app data at all.
From what i've tested, $FF specifies an empty sector, $F0 a sector used for variable data, $FE a sector used for swap.
What is $FC supposed to specify ? (according to wikiti, it can start with that byte).

Thx in advance =]
Title: Re: 8X+ > questions about archive structure
Post by: Runer112 on April 18, 2014, 10:32:51 am
Hey there.
I have 2 answers, actually:
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 10:58:10 am
Hey there.
I have 2 answers, actually:
  • TI will only ever put the swap sector starting at page $08 or $0C, but technically third-party code could put it somewhere else and the OS should theoretically still function fine. If you need to locate it, I'd recommend using B_CALL(_FindSwapSector) (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:5095). Despite what that documentation says, I wouldn't worry about the swap sector not existing, and the call is not pointless.
  • Sounds like you got a little mixed up about the variable data flag: "The flag byte will be 0FCh (valid) or 0F0h (deleted, ignore it)." To clarify, $FC marks the start of an archived variable and $F0 marks the start of a deleted archived variable to be removed at the next garbage collection. These flags exist at the start of every archived user variable, not just at the start of user archive sectors, but of course if a user archive sector is non-empty, it will start with a user variable, and that will start with $FC or $F0. So if a sector starts with either of those two flags, it's a user variable storage sector.
Thx for the answers =]
About question 2 :
Actually, the sector status byte and the variable status byte are two different things.
I am talking about the sector status byte, not the other one.
For example, if you have a random variable stored at the very begining of the archive, and that variable is valid (not to be deleted), the first byte will be $F0 (meaning the sector is used for variable data storage), followed by $FC (the variable status byte).
In other words, when a variable starts at the begining of a sector, its status byte is the second byte, not the first.
What i want to know is, under which circumstances can the sector status byte be $FC, as mentioned in wikiti.
Title: Re: 8X+ > questions about archive structure
Post by: Runer112 on April 18, 2014, 11:01:21 am
Hey there.
I have 2 answers, actually:
  • TI will only ever put the swap sector starting at page $08 or $0C, but technically third-party code could put it somewhere else and the OS should theoretically still function fine. If you need to locate it, I'd recommend using B_CALL(_FindSwapSector) (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:5095). Despite what that documentation says, I wouldn't worry about the swap sector not existing, and the call is not pointless.
  • Sounds like you got a little mixed up about the variable data flag: "The flag byte will be 0FCh (valid) or 0F0h (deleted, ignore it)." To clarify, $FC marks the start of an archived variable and $F0 marks the start of a deleted archived variable to be removed at the next garbage collection. These flags exist at the start of every archived user variable, not just at the start of user archive sectors, but of course if a user archive sector is non-empty, it will start with a user variable, and that will start with $FC or $F0. So if a sector starts with either of those two flags, it's a user variable storage sector.
Thx for the answers =]
About question 2 :
Actually, the sector status byte and the variable status byte are two different things.
I am talking about the sector status byte, not the other one.
For example, if you have a random variable stored at the very begining of the archive, and that variable is valid (not to be deleted), the first byte will be $F0 (meaning the sector is used for variable data storage), followed by $FC (the variable status byte).
What i want to know is, under which circumstances can the sector status byte be $FC.

Oh, you are indeed correct, I didn't know that. In that case, I have no idea what a status byte of $FC would mean. Are we even sure it exists?
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 11:05:29 am
Oh, you are indeed correct, I didn't know that. In that case, I have no idea what a status byte of $FC would mean. Are we even sure it exists?
I absolutely don't know, but i guess if it's mentioned in wikiti, there is a significant chance it does.
I'm sure someone will clarify that =]

I'm thinking of something else about the swap sector.
What happens if the archive is totally full (with no swap sector), then you unarchive a small variable, then perform a garbage collect ?
I mean, can the OS handle garbage collecting without enough space to create a swap sector ?
Title: Re: 8X+ > questions about archive structure
Post by: Runer112 on April 18, 2014, 11:07:29 am
The swap sector should always exist, so that shouldn't be a problem.
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 11:09:49 am
The swap sector should always exist, so that shouldn't be a problem.
Hmm, actually, it seems it is created during the very first garbage collect (according to wabbit, for what it's worth).
Title: Re: 8X+ > questions about archive structure
Post by: Runer112 on April 18, 2014, 11:12:21 am
The swap sector should always exist, so that shouldn't be a problem.
Hmm, actually, it seems it is created during the very first garbage collect (according to wabbit, for what it's worth).

Anyone have any mint condition calculators to check this with? ... Probably not. :P
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 11:16:58 am
I'll try to test that when possible =]
Title: Re: 8X+ > questions about archive structure
Post by: Streetwalrus on April 18, 2014, 11:30:46 am
The swap sector should always exist, so that shouldn't be a problem.
Hmm, actually, it seems it is created during the very first garbage collect (according to wabbit, for what it's worth).

Anyone have any mint condition calculators to check this with? ... Probably not. :P
You can just reformat the flash with the key combo (it's indicated on WikiTI).
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 18, 2014, 01:10:39 pm
Did some more tests with wabbit before trying on physical hardware.
What i tried (no swap sector at the begining of the test) :
1) fill all sectors with apps, except the first one
2) create empty prgmA, then archive it
3) create empty prgmB, then archive it
4) unarchive prgmA
5) garbage collect
Result : OS creates a swap on the 1st sector, erases 2nd sector, and moves prgmB at its begining.
The problem ? 4 app pages destroyed XD
Of course, that shouldn't be too much of a problem on models with lots of flash, but on a basic 83+, that could easily happen if you manage to transfer the maximum number of app pages (10) right after having transfered the OS.
Once again, thx TI !
Title: Re: 8X+ > questions about archive structure
Post by: Streetwalrus on April 18, 2014, 01:20:32 pm
Yay TI made a bad mistake again ! :w00t:
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 19, 2014, 03:05:09 am
Tested on real hardware, and the swap sector is there after reinstalling a fresh OS (was just a wabbit thing).
About that $FC byte, the OS doesn't really digest it, so i'll assume no variable-dedicated sector can start with it (feel free to tell me if it can).

Since i'm preparing a small app, i have a new question about the swap sector.
For what i've tested, it seems to be only used when garbage collecting and defragmenting.
Anybody knows if it's used in some other context ?
Thx in advance =]
Title: Re: 8X+ > questions about archive structure
Post by: Streetwalrus on April 19, 2014, 03:57:49 am
Installing a fresh OS doesn't wipe flash. See the secret key combos page to find something that does. ;)
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on April 19, 2014, 11:38:29 am
Installing a fresh OS doesn't wipe flash. See the secret key combos page to find something that does. ;)
True.
I guess under normal circumstances, the swap is always present, if not deleted by some off-OS code.
I just remember having read somewhere that sending stuff with ticonnect erases the swap sector.
Anyway, i'm gonna create a new topic, cause i'll probably need some little help for my mini project.
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on July 05, 2014, 08:47:16 am
Alright, since i didn't find much doc about that, here is the thing :

Normally, apps are automatically defragmented by the TI-OS when deleted.
However, that's not the case when they are deleted by a user program or app using _deleteapp (it just marks the app as deleted, $00 at 1st byte of 1st page).
Now, let's say i want to code a routine that will defragment the apps area.
In the case i have to erase page $68 or $69 (or both), i will of course have to erase the whole sector.
The thing is, that will include pages $6A & $6B (described as "certificate list" in the SDK).
Anybody knows what kind of data those pages are supposed to hold ?
Of course, i intend to restore them after the erase procedure, but is erasing them a problem ?
Title: Re: 8X+ > questions about archive structure
Post by: DrDnar on July 05, 2014, 09:01:42 pm
The thing is, that will include pages $6A & $6B (described as "certificate list" in the SDK).
Anybody knows what kind of data those pages are supposed to hold ?
Nobody knows. The only thing BrandonW knows about it is that the OS will preserve any data in there when defragmenting apps. Since the OS does it, you should do it too---after all, something like zStart might decide to put something there.

Deleting it probably won't cause any problems, except for things that do weird hacks.
Title: Re: 8X+ > questions about archive structure
Post by: the_mad_joob on July 06, 2014, 04:55:31 am
Ok...
I had to ask, since wabbit says those 2 pages are empty...
I just hope it is not supposed to include such infos as app locations, cause that would mean i'd have to update that stuff, and i'm definitely lazy about that =P