Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Get extension token from .lib  (Read 3738 times)

0 Members and 1 Guest are viewing this topic.

iliak

  • Guest
Get extension token from .lib
« on: July 19, 2016, 10:10:30 AM »

Hi

How can I get extension token ID in .Lib ? I made a little Python progam to parse and decode .AMOS source code and extract functions and instructions from amos library. The missing part is how to extract function/instruction ID ?
Here's an example from the Music.Lib :

            0x0012: "Vumeter",
            0x0020: "Voice",
            0x002c: "Music Stop",
            0x004c: "Tempo",
            0x0058: "Music",
            0x0074: "Boom",
            0x007e: "Shoot",
            0x026e: "Track Loop On",
            0x0282: "Track Loop Off",
            0x0296: "Track Play",
            0x02a8: "Track Play",
            0x02ba: "Track Load",

When parsing AMOS source code and encounters the tokenID 0x4E, it's an instruction from an extension. Id 0x12 means Vumeter, Id 0x0296 means Track Play. I need to find thoses ID, but I don't know how...

The project can be found at : https://github.com/iliak/amosparser
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Get extension token from .lib
« Reply #1 on: July 19, 2016, 11:04:39 PM »

Hi iliak

Not too sure what it is you're trying to do, but the attached PDFs might help.  Both of them are work-in-progress (i.e. very unfinished) though the one on the AMOS file format should get you heading in the right direction.

Note that AMOS will give you two different formats depending on whether a program has been 'verified' or not (the Test or Run buttons do this).  The documents should explain enough about how this works.  Just remember that when a line of code is typed or edited in the Editor, AMOS doesn't know anything about the rest of the program.  So it tokenises it as best it can until the Test phase before it is run.  It then adds in the missing stuff.  A prime example is references to the Names of Variables, Procedures and Labels.  It doesn't know what a Name really is until it's examined the rest of the program.  So it always tokenises them as Variables before the Test phase.  The exception is a Label at the beginning of a line, where it knows for sure it's a Label because of the semi-colon after the name.

For your specific query on Extension Library tokens, they will occur in these two formats:

Before Verification (Test):
Word   $004E   The token for an Extension Library
Byte$nnThe Extension Library' s Slot Number
Byte$00Padding byte
Word$ttttThe token for the instruction in the Extension Library

After Verification (Test):
Word   $004E   The token for an Extension Library
Byte$nnThe Extension Library' s Slot Number
Byte$ppNumber of Parameters for the instruction (if any)
Word$ttttThe token for the instruction in the Extension Library

As an instruction may have more than one token (for different numbers of Parameters) the token after Verification may be different to the one before Verification.

Some of the AMOS Pro Tokens are followed by Data Words (as in the Extension Library instruction example above).  You need to take these into account so you can skip over the appropriate number of words to get to the next instruction.  See the table at the end of the File Format doc.  These Token Data words only apply to some instructions in the core library (AMOSPro.Lib).  You'll never get them in an Extension Library.

Missing from that doc. are the Tokens for Operators.  These do not appear in the library, they're hard-code in the AMOS Pro executable.  They each only take up one word (no extra data required):

Token   AMOS Operator)
$FF37   ' xor '
$FF45   ' or '
$FF52   ' and '
$FF60   '<>'
$FF6B   '><'
$FF76   '<='
$FF81   '=<'
$FF8C   '>='
$FF97   '=>'
$FFA2   '='
$FFAC   '<'
$FFB6   '>'
$FFC0   '+'
$FFCA   '-'
$FFD4   ' mod '
$FFE2   '*'
$FFEC   '?'
$FFF6   '^'

I've enclosed the AMOS Operators in single quotes to show the spaces that AMOS inserts when it De-tokenises a program and turn it back into text.

Hope this lot helps.  I will get around to completing the docs but I've got too many projects on the boil at the moment!   ::)  And V2.10 and the rewritten Help System have priority,
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022