I'm trying to figure out the 8xp file structure in hopes of making a Python BASIC editor or something just for the heck of it. I'm a bit confused about how it works, though.

Here are three sample files, and what Python outputs when I read them:


Code:

Disp 123
Output(1,1,"ABC"
--
b'**TI83F*\x1a\n\x00Created by SourceCoder 3 - sc.cemetech.net.\x00\r\x00\x1d\x00\x05TSTFILE\x00\x00\x00\x1d\x00\x1b\x00\xde123?\xde*ABC?\xe01+1+*ABC?1\x04A?\xdeA\xdd\n'


Code:

Disp 123
Disp "ABC"
Output(1,1,"ABC"
1->A
Disp A
--
b'**TI83F*\x1a\n\x00Created by SourceCoder 3 - sc.cemetech.net!\x00\r\x00\x10\x00\x05TESTFILE\x00\x00\x10\x00\x0e\x00\xde123?\xe01+1+*ABC\xdb\x06'

and one exported from TokenIDE:

Code:

Disp 123
Disp "ABC"
Output(1,1,"ABC"
1→A
Disp A
--b'**TI83F*\x1a\n\x00Merthsoft Token IDE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.\x00\r\x00\x1d\x00\x05TEST2\x00\x00\x00\x00\x00\x1d\x00\x1b\x00\xde123?\xde*ABC?\xe01+1+*ABC?1\x04A?\xdeA4\n'


The linkguide on merth's website says that the first byte of the data section is equal to either x0B (Bh, 11) or x0D (Dh, 13), but in this code

Code:
b'**TI83F*\x1a\n\x00Created by SourceCoder 3 - sc.cemetech.net!\x00\r\x00\x10\x00\x05TESTFILE\x00\x00\x10\x00\x0e\x00\xde123?\xe01+1+*ABC\xdb\x06'

the text '\x0b\' isn't located anywhere. How do I locate the data section here?

I'm also not entirely clear on how the checksum works, or how I can calculate the lower 16 bits of the data section.
You should really be looking at this in hexadecimal as well as ASCII to make it easier to understand. Try adding this right after whatever prints out those strings:
Code:
print " ".join(["0x%02x" % ord(contents[c]) for c in xrange(len(contents))])
Of course, you need to replace contents with the name of your actual string in two places. You're not seeing 0x0B or 0x0D because they're vertical tab and carriage return, respectively.
KermMartian wrote:
You should really be looking at this in hexadecimal as well as ASCII to make it easier to understand. Try adding this right after whatever prints out those strings:
Code:
print " ".join(["0x%02x" % ord(contents[c]) for c in xrange(len(contents))])
Of course, you need to replace contents with the name of your actual string in two places. You're not seeing 0x0B or 0x0D because they're vertical tab and carriage return, respectively.


Thanks, that helped a lot! I did have to fiddle with it a bit, though, as Python 3 is a bit different:


Code:
print(" ".join(["0x%02x" % contents[c] for c in range(len(contents))]))


And in decimal, too, because why not?


Code:
print(" ".join([str(int(str(contents[c]),10)) for c in range(len(contents))]))


The file structure definitely makes more sense now. I was wondering, though, about your use of %02x for formatting; I wasn't able to find anything in the official python docs about using numbers (like 02) after % operators for formatting (although they do say that %x is used for hex characters), and the results don't seem to come out the same if I use another operator, like %x, %0x or %2x.
M. I. Wright wrote:
The file structure definitely makes more sense now. I was wondering, though, about your use of %02x for formatting; I wasn't able to find anything in the official python docs about using numbers (like 02) after % operators for formatting (although they do say that %x is used for hex characters), and the results don't seem to come out the same if I use another operator, like %x, %0x or %2x.

Unless I am mistaken, (I don't program in Python often), the %02 means that the output should be made up of two bytes in hexadecimal.

By the way, how goes progress on this? Looks like you are getting the hang of it! Smile
MateoConLechuga wrote:
M. I. Wright wrote:
The file structure definitely makes more sense now. I was wondering, though, about your use of %02x for formatting; I wasn't able to find anything in the official python docs about using numbers (like 02) after % operators for formatting (although they do say that %x is used for hex characters), and the results don't seem to come out the same if I use another operator, like %x, %0x or %2x.

Unless I am mistaken, (I don't program in Python often), the %02 means that the output should be made up of two bytes in hexadecimal.

By the way, how goes progress on this? Looks like you are getting the hang of it! Smile


That's probably it, yeah; I hadn't thought of that. The whole thing is going decently well, although homework has gotten in the way :/
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement