| Poster | Thread |
Yicker
|  |
Amiga Library Structure Posted on 1-May-2012 23:21:41
| | [ #1 ] |
|
|
 |
New Member |
Joined: 20-Jan-2005 Posts: 9
From: Unknown | | |
|
| Hi all,
Does anyone know where I can find details about the structure of Amiga Library (.lib) files?
Thanks Scott
|
|
| Status: Offline |
|
|
Yicker
|  |
Re: Amiga Library Structure Posted on 1-May-2012 23:57:24
| | [ #2 ] |
|
|
 |
New Member |
Joined: 20-Jan-2005 Posts: 9
From: Unknown | | |
|
| @Yicker
Sorry, that should be .library files |
|
| Status: Offline |
|
|
Belxjander
|  |
Re: Amiga Library Structure Posted on 2-May-2012 2:34:44
| | [ #3 ] |
|
|
 |
Regular Member  |
Joined: 4-Jan-2005 Posts: 463
From: Chiba prefecture Japan | | |
|
| @Yicker
RKRM Libraries, 3rd Edition has information about these along with an example.library template to work from...
The first object is a "Resident" structure (usually prefixed by a small executable routine to return...
for AmigaOS 3.x this will point to an "InitTable" as part of its information to describe the basics of the in Memory LibraryBase structure created when the Library is loaded.
there is also a FunctionTable referenced as part of the InitTable and here is where all the routines that the system needs along with additional functions that the system and applications may call.
in addition to this there is a "LibInit" function that is called from the InitTable information when the "ramlib" task has Allocated memory for the LibraryBase, with the return value being the base address of the completed LibraryBase structure.
LibInit() is called from the "ramlib" task context.
the FunctionTable listing *requires* the following routines at the beginning of the list...
-6 = LibOpen() : Called from the Application context during exec.library/OpenLibrary(), updates the OpenCount -12 = LibClose() : Called from the Application context during exec.library/CloseLibrary(), updates the OpenCount -18 = LibExpunge() : Called when the Memory Management needs memory for checking that the library is not in-use and may be used for general memory garbage collection within the library -24 = LibReserved() : Currently returns NULL and a No-Op
-30 = *() The First Published Function that any Application can make use of...
This is why FD/SFD file contents usually start with a " ##bias 30 " offset for the first function in their definitions.
The above information is compatible with Amiga OS through to 3.9,
Amiga OS 4.x, MorphOS and AROS have additional options or changes to the above structures.
There is also example library sources on Aminet.net and os4depot.net.
I hope this helps with some of what you are looking for...
The Developer Kits are the best place to start for further information and details. |
|
| Status: Offline |
|
|
Yicker
|  |
Re: Amiga Library Structure Posted on 3-May-2012 0:17:07
| | [ #4 ] |
|
|
 |
New Member |
Joined: 20-Jan-2005 Posts: 9
From: Unknown | | |
|
| @Belxjander
Hi Belxjander,
Thanks for the reply. I think I've got enough info now for what I need to do.
Cheers Scott
|
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 3-May-2012 0:44:58
| | [ #5 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @Yicker
If you read address 0x00000004, you find base address for exec.library, the LVO values offsets is relative to library base address, the content you find on that address is JMP instruction and a function address to be called, etch function takes registers as arguments.
NDK3.9 and Autodocs should provide you whit information that you need, if not look in the header files.
; Hello World in 68000 Assembler for dos.library (Amiga)
move.l #DOS,a1 ; library name move.l #0,d0 ; library verson move.l 4,a6 ; get exec lib base address jsr -$0198(a6) ; Call IEXEC::OpenLibrary move.l d0,a6 ; move D0 to A6 to use DOS.library beq.s .Out ; if openlibrary failed quit
move.l #HelloWorld,d1 ; string to write moveq #13,d2 ; length of string
jsr -$03AE(a6) ;call IDOS::WriteChars jsr -$03B4(a6) ;call IDOS::PutStr
move.l a6,a1 ; library to close (dos.library) move.l 4,a6 ; get exec.library jsr -$019E(a6) ; call IEXEC::CloseLibrary .Out rts
DOS dc.b 'dos.library',0 HelloWorld dc.b 'Hello World!',$A,0
Last edited by NutsAboutAmiga on 03-May-2012 at 01:33 AM. Last edited by NutsAboutAmiga on 03-May-2012 at 01:33 AM. Last edited by NutsAboutAmiga on 03-May-2012 at 01:15 AM. Last edited by NutsAboutAmiga on 03-May-2012 at 01:14 AM. Last edited by NutsAboutAmiga on 03-May-2012 at 01:14 AM. Last edited by NutsAboutAmiga on 03-May-2012 at 01:11 AM.
_________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
thellier
|  |
Re: Amiga Library Structure Posted on 3-May-2012 13:04:37
| | [ #6 ] |
|
|
 |
Member  |
Joined: 2-Nov-2009 Posts: 95
From: Paris | | |
|
| Hi
check aminet/wazp3d.lha it contain full sources for a 68k/os3 or ppc/os4. library Alaing |
|
| Status: Offline |
|
|
startup-sequence.bat
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:05:13
| | [ #7 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @NutsAboutAmiga
Why do you bother closing dos.library, instead of just letting the system cleanup the process' resources? It seems like an unneeded complication, especially since in assembler it requires three whole lines of code to do that |
|
| Status: Offline |
|
|
Crumb
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:14:52
| | [ #8 ] |
|
|
 |
Elite Member  |
Joined: 12-Mar-2003 Posts: 2164
From: Zaragoza (Aragonian State) | | |
|
| @startup-sequence.bat
Quote:
| Why do you bother closing dos.library, instead of just letting the system cleanup the process' resources? |
AFAIK OS doesn't clean up any resource. If you use some link library that automatically opens and closes libraries when you link against it then certain libraries like DOS will be auto opened and auto closed but not all._________________ The only spanish amiga news web page/club: CUAZ |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:16:38
| | [ #9 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| @startup-sequence.bat
Quote:
startup-sequence.bat wrote: @NutsAboutAmiga
Why do you bother closing dos.library, |
If you don't know the answer as to why you should do that then I'd hate to see your code (if you do actually code)...  _________________
|
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:19:42
| | [ #10 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @startup-sequence.bat
AmigaOS 3.x does not have a garbage collector.
In every library there is libcnt counter, when library is open it increases when you close it it decreases, libcnt is atomic and used as safety feature to prevent the library or device to get unloaded premature, if library is not closed, libcnt will increases until it 16bit or 32bit integer overflows, when this happens the library might get unloaded before programs done whit the library, this might result in a system crash.
(Exec.library is never opened and never closed because execbase is always there on address 0x000004.)
AmigaOS 4.x has -lauto that takes care of opening and closing library’s, it is advised not to use it opens reaction classes whit OpenLibrary instead if OpenClass and that is some how not good, I have not noticed any side effects and no one told me what they are.
Last edited by NutsAboutAmiga on 10-May-2012 at 05:33 PM. Last edited by NutsAboutAmiga on 10-May-2012 at 05:30 PM. Last edited by NutsAboutAmiga on 10-May-2012 at 05:26 PM. Last edited by NutsAboutAmiga on 10-May-2012 at 05:22 PM.
_________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:29:03
| | [ #11 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @Franko
Considering this is thread is about learning to code for AmigaOS, maybe you should not be so critical Franko, and his nick has (*.bat) so what do you expect _________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:38:04
| | [ #12 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| @NutsAboutAmiga
Quote:
NutsAboutAmiga wrote: @Franko
Considering this is thread is about learning to code for AmigaOS, maybe you should not be so critical Franko, and his nick has (*.bat) so what do you expect |
Not really being critical as his other post here seem to suggest that he does code in assembler on the Amiga, so making a statement like that if he is a coder he should know the answer as to why you should close the dos.library when writing code... 
http://amigaworld.net/modules/newbb/viewtopic.php?topic_id=35731&forum=2#665363
Franko.bat  _________________
|
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:46:12
| | [ #13 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @startup-sequence.bat
Quote:
| especially since in assembler it requires three whole lines of code to do that |
If you where to code in Assembler for real you probably create lots of macros so don't need type so many lines of code do this stuff.
One things this example does not show best practice, because your actually advised to push and pop registers you like keep, and not hope they are not changed whit in function your calling.
But then again it probably better to code in C as the code is more portable, easy to read whit out lots of comments.
One big problem whit old code that is not commented is that takes ages to figure out what it does, and that’s probably way not more programs have been disassembled and fixed up for AmigaOS4.x and MorphOS. Last edited by NutsAboutAmiga on 10-May-2012 at 05:47 PM.
_________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 17:52:41
| | [ #14 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| @NutsAboutAmiga
Quote:
NutsAboutAmiga wrote: @startup-sequence.bat
But then again it probably better to code in C as the code is more portable, easy to read whit out lots of comments. |
Have to disagree with you on that one, to get the best possible out of the Amiga nothing beats assembler (plus portability isn't important to me)... 
Quote:
| One big problem whit old code that is not commented is that takes ages to figure out what it does, and that’s probably way not more programs have been disassembled and fixed up for AmigaOS4.x and MorphOS. |
Sort of agree with you on that one but then to me that's part of the enjoyment of disassembling old programs (something I do all the time) is figuring it all out without any notes... 
Mind you disassembling the 3.0 & 3.1 was quite a mammoth task but I got there in the end...  _________________
|
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 10-May-2012 18:25:30
| | [ #15 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @Franko
Hey it seams every one I know have disassembled AmigaOS3.0 and 3.1. _________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
startup-sequence.bat
|  |
Re: Amiga Library Structure Posted on 10-May-2012 18:47:10
| | [ #16 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @Crumb
Quote:
| AFAIK OS doesn't clean up any resource. |
Surely this can't be true. I'm pretty sure nobody would still use an OS that can't automatize such simple things in 2012. |
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 10-May-2012 19:03:47
| | [ #17 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8604
From: Norway | | |
|
| @startup-sequence.bat
AmigaOS3.x/4.x is kind a retro OS you know.
AmigaOS is based on Unix spin of called Tripos from 1970's, almost all AmigaDOS commands is from TRIPOS, the graphical user interface was introduced in AmigaOS in 1985 sines then things have gradually improved until today.
Work is being done to add garbage collector to AmigaOS4.1, for example will tell you that you have unfreed signals when program exits, also work being done create standard method to allocate system resources.
The problem whit implementing garbage collection is dependencies, free resources and closing libraries in the correct order, and also handling of opening and closing library’s, keep track of what program that does this, that is not some thing the OS does, it should be easy to implement, by creating a list, and querying FindTask(NULL), but I don't believe that has not happened yet, AmigaOS4.1 does keep track of child processes (treads).
AmigaOS applications can not be terminated by force as, AmigaOS programs often share list nodes and windows or memory allocated whit other application and the OS, AmigaOS is not a secure OS, its from age in time where memory and CPU usage was important, and it has some legacy to carry around that can't be easily broken.
Last edited by NutsAboutAmiga on 10-May-2012 at 07:19 PM. Last edited by NutsAboutAmiga on 10-May-2012 at 07:17 PM. Last edited by NutsAboutAmiga on 10-May-2012 at 07:07 PM.
_________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 19:32:33
| | [ #18 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| @startup-sequence.bat
Quote:
startup-sequence.bat wrote: @Crumb
Quote:
| AFAIK OS doesn't clean up any resource. |
Surely this can't be true. I'm pretty sure nobody would still use an OS that can't automatize such simple things in 2012. |
Methinks you're at it here... 
http://www.amiga.org/forums/showpost.php?p=692615&postcount=393
I smell some CUSA shenanigans going on...  _________________
|
|
| Status: Offline |
|
|
startup-sequence.bat
|  |
Re: Amiga Library Structure Posted on 10-May-2012 21:57:39
| | [ #19 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @Franko
Are you accusing me of having an agenda of some sort? What is CUSA? I am just a computer enthusiast eager to learn more about amiga os. I believe that all computer users are really just one big community, I just believe in sharing, knowledge and otherwise.
I am really trying my best to ask honest, straightforward questions. Pardon me if I caused some offense. |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 22:07:41
| | [ #20 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| |
| Status: Offline |
|
|