Welcome, Guest. Please login or register.

Author Topic: execbase in assembler question  (Read 3201 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline DisplacerTopic starter

  • Newbie
  • *
  • Join Date: Apr 2011
  • Posts: 4
    • Show only replies by Displacer
execbase in assembler question
« on: May 02, 2011, 06:32:54 PM »
I have several books on programming the Amiga, and I'm learning to code in assembler on it. Question I have is something that is confusing about the exec library. I've looked at some assembly code that refers to the CoolCapture vector. In the code that I looked at, its absolute address is (assuming A6 holds offset 0)

$2E(A6)

But looking in the docs I have, specifically execbase.h the structure is listed as:

Code: [Select]
   UWORD    SoftVer;    /* kickstart release number (obs.) */
    WORD    LowMemChkSum;    /* checksum of 68000 trap vectors */
    ULONG    ChkBase;    /* system base pointer complement */
    APTR    ColdCapture;    /* coldstart soft capture vector */
    APTR    CoolCapture;    /* coolstart soft capture vector */
    APTR    WarmCapture;    /* warmstart soft capture vector */
    APTR    SysStkUpper;    /* system stack base   (upper bound) */
    APTR    SysStkLower;    /* top of system stack (lower bound) */
    ULONG    MaxLocMem;    /* top of chip memory */
    APTR    DebugEntry;    /* global debugger entry point */
    APTR    DebugData;    /* global debugger data segment */
    APTR    AlertData;    /* alert data segment */
    APTR    MaxExtMem;    /* top of extended mem, or null if none */

    UWORD    ChkSum;    /* for all of the above (minus 2) */
Which puts the offset at 0C from the start of this structure, so what am I missing?

Thanks!
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: execbase in assembler question
« Reply #1 on: May 02, 2011, 07:14:50 PM »
Remember that struct ExecBase is an extended library base. Therefore, it starts with an embedded struct Library. You have to add the (aligned, IIRC) size of that to your offset. In C terms, that's

Code: [Select]
struct ExecBase {
  struct Library LibNode;

  UWORD SoftVer;

  /* other fields... */

};

Look in your includes for exec/libraries.h to see that structure.
« Last Edit: May 02, 2011, 07:17:20 PM by Karlos »
int p; // A
 

Offline Lando

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 1390
    • Show only replies by Lando
    • https://bartechtv.com
Re: execbase in assembler question
« Reply #2 on: May 02, 2011, 07:15:33 PM »
Hi,

struct Library LibNode;

comes before

UWORD   SoftVer;

in the execbase structure, which would explain the missing bytes.
 

Offline DisplacerTopic starter

  • Newbie
  • *
  • Join Date: Apr 2011
  • Posts: 4
    • Show only replies by Displacer
Re: execbase in assembler question
« Reply #3 on: May 02, 2011, 08:39:54 PM »
OK, I missed the Library struct. I went back and counted the bytes again, and still can't come up with the right number. I think it's the NODE struct in the Library struct that's messing me up. It has the comment that it's word aligned so what is the size exactly of the NODE struct? Sorry for all the questions and I hope it's the alignment that's messing me up instead of just not being able to count ;)
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: execbase in assembler question
« Reply #4 on: May 02, 2011, 09:25:18 PM »
Code: [Select]
  STRUCTURE    LN,0
        APTR    LN_SUCC ; 0
        APTR    LN_PRED ; 4
        UBYTE   LN_TYPE ; 8
        BYTE    LN_PRI  ; 9
        APTR    LN_NAME ; 10
        LABEL   LN_SIZE ; 14

 STRUCTURE LIB,LN_SIZE
    UBYTE   LIB_FLAGS                   ; 14
    UBYTE   LIB_pad                     ; 15
    UWORD   LIB_NEGSIZE         ; 16
    UWORD   LIB_POSSIZE         ; 18
    UWORD   LIB_VERSION         ; 20
    UWORD   LIB_REVISION                ; 22
    APTR    LIB_IDSTRING                ; 24
    ULONG   LIB_SUM                     ; 28
    UWORD   LIB_OPENCNT         ; 32
    LABEL   LIB_SIZE    ;34

 STRUCTURE  ExecBase,LIB_SIZE
        UWORD   SoftVer ; 34
        WORD    LowMemChkSum    ; 36
        ULONG   ChkBase ; 38
        APTR    ColdCapture     ; 42
        APTR    CoolCapture     ; 46 = $2E
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: execbase in assembler question
« Reply #5 on: May 02, 2011, 09:29:40 PM »
Piru FTW!
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline DisplacerTopic starter

  • Newbie
  • *
  • Join Date: Apr 2011
  • Posts: 4
    • Show only replies by Displacer
Re: execbase in assembler question
« Reply #6 on: May 02, 2011, 10:45:49 PM »
Ah, there's the problem. The node struct I have is:

Code: [Select]
struct Node {
    struct  Node *ln_Succ;
    struct  Node *ln_Pred;
    UBYTE   ln_Type;        
    BYTE    ln_Pri;
    char    *ln_Name;
};
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: execbase in assembler question
« Reply #7 on: May 02, 2011, 10:55:23 PM »
Quote from: Displacer;634966
Ah, there's the problem.
Where?
Quote
The node struct I have is:

Code: [Select]
struct Node {
    struct  Node *ln_Succ;
    struct  Node *ln_Pred;
    UBYTE   ln_Type;        
    BYTE    ln_Pri;
    char    *ln_Name;
};
This is exactly the same as the STRUCTURE LN in nodes.i.
 

Offline DisplacerTopic starter

  • Newbie
  • *
  • Join Date: Apr 2011
  • Posts: 4
    • Show only replies by Displacer
Re: execbase in assembler question
« Reply #8 on: May 02, 2011, 11:43:48 PM »
I know it is, sorry I wasn't clear. What I meant is the char is what messed me up. I was treating that entry as a char (single byte) instead of APTR (4 bytes) and that's exactly how far my count was off. My own fault

Thanks for the help!
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: execbase in assembler question
« Reply #9 on: May 03, 2011, 07:34:26 AM »
Wouldn't have been a very long label if it was a single char. Having said that, it was enough for Microsoft's drive enumeration scheme for years :lol:
int p; // A