12 April 2007, 15:56 | #1 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
loadseg help
Hey guys, im disassembling a prog and it loadseg's a file, with the base of the seglist is returned in d0.
How do I read the seglist and what is the structure of the seglist? or is it irrelevent and the address of the loaded file is in d0? |
12 April 2007, 17:50 | #2 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Okay i have figured out the following
Loadseg the file and it returns the address as a bcpl pointer why do i need to multiply by 4 and then add 4 to get the real address? Code:
lsl.l #2,d0 addq.l #4,d0 move.l d0,(_GameExeBase) |
12 April 2007, 19:30 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
Pointer from LoadSeg is BCPL pointer -> need to multiply by 4. It points to BCPL pointer to next hunk (or zero if program has only one hunk).
Btw, pointer - 4 = points to size of hunk. |
16 April 2007, 09:27 | #4 |
In deep Trouble
Join Date: Sep 2004
Location: Manchester, Made in Norway
Age: 51
Posts: 841
|
If I remember the 68k right.... from what I understand, your program here has an offset of 12, and it's faster to lsl twice+4 than to mul(tiply) it to twelve.
At least I think it's in those lines. Though, I've said it before, I'm nocoder and could be VERY wrong about this |
16 April 2007, 13:35 | #5 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Sorry, you're wrong. It's not offset 12 ( its BCPL*4+4 and gives address of start first hunk ), the fastest way is ( d0 = BCPL pointer to first hunk )
Code:
add.l d0,d0 add.l d0,d0 addq.l #4,d0 ; d0 = address of first hunk code or data So, dos function LoadSeg return a seglist ( read autodocs about dos.library or you can find more information in books ). It looks like Code:
; hunk 00 label_0 dc.l label_1 / 4 nop nop ... data or code ... ; hunk 01 label_1 dc.l label_2 /4 rts ... ... ... ; hunk 02 label_2 dc.l 0 ; thats mean end of seglist ... ... |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
LoadSeg / Relocate to fixed address? | a4k-oerx | Coders. General | 7 | 24 November 2008 17:35 |
|
|