| Poster | Thread |
startup-sequence.bat
|  |
Re: Amiga Library Structure Posted on 10-May-2012 22:31:03
| | [ #21 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @Franko
Well, at least I don't end each of my sentence with a smiley to hypocritically pretend I'm being nice when I'm in fact smearing my interlocutor.
I'm a nice guy so I'm going to pretend that you are not being extremely rude but you may want to take a long hard look at yourself. |
|
| Status: Offline |
|
|
Franko
|  |
Re: Amiga Library Structure Posted on 10-May-2012 22:45:33
| | [ #22 ] |
|
|
 |
Elite Member  |
Joined: 29-Jun-2010 Posts: 2809
From: Unknown | | |
|
| |
| Status: Offline |
|
|
tonyw
 |  |
Re: Amiga Library Structure Posted on 11-May-2012 0:11:05
| | [ #23 ] |
|
|
 |
Elite Member  |
Joined: 8-Mar-2003 Posts: 2779
From: Sydney (of course) | | |
|
| @startup-sequence.bat
More modern OSes maintain a list of all resources that a program opens, uses and closes. Thus, when that program exits, libraries can be closed, memory released, etc, if the program crashes, the programmer is lazy or the program has not done its homework.
AmigaOS does not track resources in user programs, thus the OS can not clean up after a lazy program. We expect every man to do his duty.
_________________ cheers tony
Hyperion Support Forum: http://forum.hyperion-entertainment.biz/index.php |
|
| Status: Offline |
|
|
Hypex
 |  |
Re: Amiga Library Structure Posted on 11-May-2012 15:30:05
| | [ #24 ] |
|
|
 |
Elite Member  |
Joined: 6-May-2007 Posts: 5279
From: Greensborough, Australia | | |
|
| @Belxjander
That was quite extensive. But you forgot this: 
struct Library{ struct Node lib_Node; UBYTE lib_Flags; UBYTE lib_ABIVersion; /* ABI exported by library */ UWORD lib_NegSize; /* number of bytes before library */ UWORD lib_PosSize; /* number of bytes after library */ UWORD lib_Version; /* major */ UWORD lib_Revision; /* minor */ APTR lib_IdString; /* ASCII identification */ ULONG lib_Sum; /* the checksum itself */ UWORD lib_OpenCnt; /* number of current opens */}; /* Warning: size is not a longword multiple! */
Okay OS4 version but you get my point.  |
|
| Status: Offline |
|
|
Hypex
 |  |
Re: Amiga Library Structure Posted on 11-May-2012 15:35:54
| | [ #25 ] |
|
|
 |
Elite Member  |
Joined: 6-May-2007 Posts: 5279
From: Greensborough, Australia | | |
|
| @NutsAboutAmiga
I think this is a bad example:
1.) It uses a move.l to put a zero in D0 instead of a moveq. 2.) It doesn't check the result. An address register move doesn't affect CCs. And relying on the system is to test the result for you is a bad assumption. 3.) It later then uses a moveq.  4.) It doesn't cache ExecBase but that wasn't the worse IMO.  Last edited by Hypex on 11-May-2012 at 03:38 PM.
|
|
| Status: Offline |
|
|
Hypex
 |  |
Re: Amiga Library Structure Posted on 11-May-2012 15:37:32
| | [ #26 ] |
|
|
 |
Elite Member  |
Joined: 6-May-2007 Posts: 5279
From: Greensborough, Australia | | |
|
| @startup-sequence.bat
What is opened must be closed. The only main exception would be a resource.
And BTW those three lines send up as only three instructions.  |
|
| Status: Offline |
|
|
Belxjander
|  |
Re: Amiga Library Structure Posted on 11-May-2012 16:17:28
| | [ #27 ] |
|
|
 |
Regular Member  |
Joined: 4-Jan-2005 Posts: 463
From: Chiba prefecture Japan | | |
|
| @Hypex
I was giving overview... but thank you for the reminder of the details...can't ever slip over those without being sure to specify them all now ;) |
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 15-May-2012 18:19:58
| | [ #28 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8607
From: Norway | | |
|
| @Hypex
The example was something I found googleing for hello world and assembler, just added comments add fixed some major mistakes, like not setting the D0 value at all.
http://helloworldsite.he.funpic.de/hello.htm
A better example probably use the LVO values:
; Hello World in 68000 Assembler for dos.library (Amiga)
_LVOOpenLibrary EQU -552 _LVOCloseLibrary EQU -414 _LVOOutput EQU -60 _LVOWrite EQU -48 _LVOWriteChars EQL -142
move.l 4,a6 ; get exec lib base address move.l #DOS,a1 ; library name moveq #0,d0 ; library verson jsr _LVOOpenLibrary(a6) ; Call IEXEC::OpenLibrary tst.l d0 ; d0 should of been set, if the open lib succeeded. This is testing if d0, is set to 0 beq.s .Out ; if openlibrary failed quit move.l d0,a6 ; move D0 to A6 to use DOS.library
move.l #HelloWorld,d1 ; string to write jsr _LVOPutStr(a6) ; call IDOS::PutStr
move.l a6,a1 ; library to close (dos.library) move.l 4,a6 ; get exec.library jsr _LVOCloseLibrary(a6) ; call IEXEC::CloseLibrary .Out rts
DOS dc.b 'dos.library',0 HelloWorld dc.b 'Hello World!',$A,0
http://cd.textfiles.com/amigaformat/aformat-01-19960509/Demos/Secal/Inc/lvos/
Last edited by NutsAboutAmiga on 15-May-2012 at 09:21 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 07:09 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 07:02 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 06:58 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 06:53 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 06:44 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 06:44 PM. Last edited by NutsAboutAmiga on 15-May-2012 at 06:42 PM.
_________________ 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 19-May-2012 16:16:25
| | [ #29 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @NutsAboutAmiga
You should use lea DOS(pc), a1, not move.l #DOS, a1. I'm pretty sure the former will result in a single 16bit instruction word, whereas that move would require a whopping 6 bytes of machine code!
As a result, depending on the specific cpu it may take as much as a 2 fewer cycles to fetch the instruction. Furthermore, it would take less space in the instruction cache.
Also, when loading the executable, by using a PC relative addressing mode, it's one less address relocation that the os needs to perform!
Lastly, if some day amiga os implements memory protection, having position independent code is useful to have so you can map the same library images at different addresses in different processes, so it's a good habit to take.
Plus if you're going to write assembly code, you may as well squeeze out every possible cycle. Who would want to use a poorly optimized hello world? |
|
| Status: Offline |
|
|
Belxjander
|  |
Re: Amiga Library Structure Posted on 19-May-2012 16:20:55
| | [ #30 ] |
|
|
 |
Regular Member  |
Joined: 4-Jan-2005 Posts: 463
From: Chiba prefecture Japan | | |
|
| @startup-sequence.bat
the Amiga OS *already* impliments a dynamic memory layout... so your suggested improvements at this time are dissengenious as to "more modern" features...
as for "memory protection" would you be dealing with blocking reads or only blocking writes?
|
|
| Status: Offline |
|
|
startup-sequence.bat
|  |
Re: Amiga Library Structure Posted on 19-May-2012 16:37:08
| | [ #31 ] |
|
|
 |
Member  |
Joined: 6-Apr-2012 Posts: 16
From: Unknown | | |
|
| @Belxjander
You post suggests a lack of understanding of mine. I suggest re-reading my previous post repeatedly until you acquire wisdom or faint from thirst, whichever comes first. |
|
| Status: Offline |
|
|
Deniil715
 |  |
Re: Amiga Library Structure Posted on 19-May-2012 18:31:30
| | [ #32 ] |
|
|
 |
Elite Member  |
Joined: 14-May-2003 Posts: 3590
From: Sweden | | |
|
| @startup-sequence.bat
Quote:
| You post suggests a lack of understanding of mine. I suggest re-reading my previous post repeatedly until you acquire wisdom or faint from thirst, whichever comes first. |
Hahaha 
AmigaOS 4 does have memory protection, but not task based such yet. Free and non-mapped mem and null pages are read&write&execute protected and const data such as litteral C "strings" are write protected and executable code can only be executed, not read or written which means self-modifying code will cause an exception.
Garbage collection is kind of difficult to implement due to AmigaOS' inherent shared library and memory model. It is allowed for one task to open a library or allocate memory and then quit and let another task to close and free it later._________________ >Amiga Classic and OS4 developer for OnyxSoft. >A1-XE/G4, Radeon9250, Sweex 5.1, SII680 -Don't hesitate to contact me about my programs, but please use e-mail instead of PM. E-mails are more likely to be read in time, and easier for me to keep track of. |
|
| Status: Offline |
|
|
RodTerl
|  |
Re: Amiga Library Structure Posted on 19-May-2012 19:56:20
| | [ #33 ] |
|
|
 |
Cult Member  |
Joined: 6-Sep-2004 Posts: 521
From: Rossendale | | |
|
| Um, so the exec, memory protection basis of AOS is like having a security guard at the entrance to the factory complex, whose only job is to punch you in and out again, instead of being given a seperate area full of area monitors and remotely operated locks to cubicles, lifts, doors, bathrooms, TV, vending machines, and the commitees bar?
How hard would it be to build this totally seperate room for AOS, as long as every program has to do an OS call to be able to do anything? If a resource is requested, doesnt that mean it is already tracked, even if teh result is just NULL instead of a guy with a clipboard and access code?
_________________ The older and more respected a scientist is, the longer it takes to prove him wrong. |
|
| Status: Offline |
|
|
NutsAboutAmiga
|  |
Re: Amiga Library Structure Posted on 19-May-2012 20:12:25
| | [ #34 ] |
|
|
 |
Elite Member  |
Joined: 9-Jun-2004 Posts: 8607
From: Norway | | |
|
| @RodTerl
First of all you get a bunch of angry users whit hay forks, screaming this and that crashes or does not work.
It will be complex to do that, because now programs just execute library routines whit out thinking about instant variables whit in the library, for this work every library has to task switch to the library in order to allow writing and reading instant variables, other operating systems do this whit a interrupt and this taken care of some how, also many programs allocate wrong memory for arguments and pass pointers to local variables to system libraries and devices.
Last edited by NutsAboutAmiga on 19-May-2012 at 08:29 PM. Last edited by NutsAboutAmiga on 19-May-2012 at 08:13 PM.
_________________ Software developer and forum troll. Please check out my software: Excalibur, Basilisk 2, AmigaInputAnywhere. |
|
| Status: Offline |
|
|