Difference between revisions of "680x0:Opening a library"
Spellcoder (talk | contribs) (Example on how to open a library (ripped from my old tutorial)) |
(No difference)
|
Revision as of 23:32, 31 October 2007
This is a example on how to open a library:
(with the Library Vector Offsets added so you won't need to use any includes yet)
OldOpenLibrary = -408 ; OldOpenLibrary(libName)(A1)
OpenLibrary = -552 ; OpenLibrary(libName,version)(A1,D0)
CloseLibrary = -414 ; CloseLibrary(library)(A1)
move.l $4.w,a6 ; Get the value at position $4 in memory
; This value is the base of exec.library
lea LibName(pc),a1 ; libName must be in A1
moveq #0,d0 ; version must be in D0
jsr OpenLibrary(a6) ; Call the OpenLibrary function
; OldOpenLibrary looks if the library is in memory (or ROM)
; and loads it if nessesary.
; Then it returns the base of graphics.library in d0
move.l d0,libbase ; Store the base
; Closelibrary needs the base of the library
; (the address given to you in D0 by OpenLibrary)
; to close the library
move.l libbase,a1 ; Get the base
jsr CloseLibrary(a6)
rts
libname: dc.b 'dos.library',0
libbase: dc.l $00000000