English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 12 April 2007, 15:56   #1
BippyM
Global Moderator
 
BippyM's Avatar
 
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?
BippyM is offline  
Old 12 April 2007, 17:50   #2
BippyM
Global Moderator
 
BippyM's Avatar
 
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)
BippyM is offline  
Old 12 April 2007, 19:30   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,570
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.
Toni Wilen is offline  
Old 16 April 2007, 09:27   #4
Doc Mindie
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
Doc Mindie is offline  
Old 16 April 2007, 13:35   #5
Asman
68k
 
Asman's Avatar
 
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
BCPL is address divided by 4, for example if you have adr = $10000 , then bcpl of adr = $10000 / 4.

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
 ...
 ...
Gretz
Asman is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07445 seconds with 13 queries