![]() |
![]() |
#1 |
Registered User
![]() Join Date: May 2013
Location: Kleppe / Norway
Posts: 274
|
accessing ROM/libraries from Assembler
I have an assembler book which explains well how to use some parts of
DOS and intuition, but what about other libraries and devices? Meaning which arguments a function takes and where to put them, what you get in return and how that data is formatted? Theres a lot of information out there which is useful if you are using C language, including official ROM kernals, but where do you look if you want to do it in assembler? |
![]() |
![]() |
#2 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,891
|
Have a look at the autodocs
http://amigadev.elowar.com/ The RKM examples have also been reworked in ASM, this could help. http://aminet.net/search?query=Rkm+asm |
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,489
|
That information is all included in the autodocs which come with the official NDK. You can also use tools like FD2PRAGMA (In Aminet) to convert the fd files containing the function definitions to assembler includes.
|
![]() |
![]() |
#4 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,891
|
There is also this forum for help etc
https://developer.amigaos3.net/forum |
![]() |
![]() |
#5 |
Registered User
![]() Join Date: May 2013
Location: Kleppe / Norway
Posts: 274
|
While the NDK contains lots of useful information, I still struggle with getting all the pieces.
I wish to open the timer.device to use the GetSysTime function. The code below was written by alkis in another thread on EAB, and parts of it does what I need prior to running GetSysTime. Can someone please explain the stuff I added as comments to the above? I just want to understand what is going on. Code:
incdir /opt/amiga/gcc6/m68k-amigaos/ndk-include/ include devices/timer.i include exec/execbase.i ;for ThisTask include dos/dosextens.i ;for pr_Result2 include lvo/exec_lib.i include lvo/timer_lib.i ; Create message Port move.l $4.w,a6 move.l ThisTask(a6),a5 ; what is this? arg for CreateMsgPort? ndk does not mention a5. jsr _LVOCreateMsgPort(a6) ; Create IORequest move.l d0,d7 move.l d0,a0 moveq #IOTV_SIZE,d0 jsr _LVOCreateIORequest(a6) move.l d0,a4 ; pointer to iorequest structure? ; Open timer.device move.l d0,a1 lea tdname(pc),a0 moveq #0,d0 moveq #0,d1 jsr _LVOOpenDevice(a6) move.l IO_DEVICE(a4),a6 ; is this the base address for timer library? what is IO_DEVICE def, and does a4 still contain pointer to iorequest? lea eval(pc),a0 lea eval2(pc),a3 jsr _LVOReadEClock(a6) move.l a3,a0 jsr _LVOReadEClock(a6) move.l d0,d6 move.l $4.w,a6 ;Close device move.l a4,a1 jsr _LVOCloseDevice(a6) ;Free IORequest move.l a4,a0 jsr _LVODeleteIORequest(a6) ;Free MsgPort move.l d7,a0 jsr _LVODeleteMsgPort(a6) move.l eval+4,d1 move.l eval2+4,d3 move.l eval,d0 move.l eval2,d2 sub.l d1,d3 subx.l d0,d2 move.l d6,pr_Result2(a5) move.l d3,d0 rts eval: dc.l 0,0 eval2: dc.l 0,0 tdname: TIMERNAME |
![]() |
![]() |
#6 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,094
|
1. a5=ThisTask, probably a leftover. Typically used to check if started from WB or CLI (task->pr_CLI != 0?), but this is not done here.
2. ptr to IORequest struct, yes. 3. timer device (not library) base, yes. Since a device is *not* opened the same way you open a library, it's done via IORequest and OpenDevice() instead (it's filled in upon success). |
![]() |
![]() |
#7 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 730
|
1. a5 is used to save E_freq at pr_Result2(a5) near the end
|
![]() |
![]() |
#8 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,711
|
The NDK alone is not ideal; you should also get the RKRMs if you want complete tutorial-style documentation, the autodocs are more of a quick reference.
|
![]() |
![]() |
#9 |
Registered User
![]() Join Date: May 2013
Location: Kleppe / Norway
Posts: 274
|
Thanks!
|
![]() |
![]() |
#10 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,094
|
|
![]() |
![]() |
#11 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 730
|
Quote:
![]() |
|
![]() |
![]() |
#12 |
Registered User
![]() Join Date: May 2013
Location: Kleppe / Norway
Posts: 274
|
I have tried to implement the code to open timer.device and then run the GetSysTime function, but when running in CLI it fails with a #8000000B when attempting to enter the GetSysTime function. I assume I screw up the _TmrBase somewhat. If I comment out the 2 lines below ;Get System Time the program runs to
completion without crashes/errors. Below is the relevant bits of the program. The SysError calls just print an error message to the console, close the resources and exit. Code:
; ;******************************************************************************************************************* CALLSYS MACRO ;CALL LIBRARY ROUTINES LINKLIB _LVO\1,\2 ;ARG.1: Library function name, with "_LVO" prefix omitted ENDM ;ARG.2: Base address of library ;******************************************************************************************************************* ; Create message Port OpenTimer: CALLSYS CreateMsgPort,_SysBase move.l d0,_MsgPort beq SysError1 ; Create IORequest move.l _MsgPort,a0 moveq #IOTV_SIZE,d0 CALLSYS CreateIORequest,_SysBase move.l d0,a0 move.l IO_DEVICE(a0),_TmrBase move.l d0,_IORequest beq SysError2 ; Open timer.device lea.l TMRName,a0 move.l _IORequest,a1 moveq #0,d0 moveq #0,d1 CALLSYS OpenDevice,_SysBase tst.b d0 bne SysError3 ; Get System Time lea.l _TimeVal,a0 CALLSYS GetSysTime,_TmrBase ;******************************************************************************************************************* _DOSBase: ds.l 1 _IORequest ds.l 1 _MsgPort ds.l 1 _Stdout: ds.l 1 _SysBase: ds.l 1 _TmrBase: ds.l 1 _TimeVal ds.l 16 TMRName: dc.b "timer.device",NULL ;******************************************************************************************************************* |
![]() |
![]() |
#13 |
Registered User
Join Date: Mar 2019
Location: Poland
Posts: 67
|
The timer base in IORequest is initialized after opening the timer device and not after creating io request.
The following code should work: Code:
... CALLSYS CreateIORequest,_SysBase tst.l d0 beq SysError2 move.l d0,_IORequest ; Open timer.device lea.l TMRName,a0 move.l d0,a1 moveq #0,d0 moveq #0,d1 CALLSYS OpenDevice,_SysBase tst.l d0 bne SysError3 move.l _IORequest, a0 move.l IO_DEVICE(a0),_TmrBase ... |
![]() |
![]() |
#14 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,711
|
Devices are trickier than using libraries; everything needs to be done in the right order and handling of I/O requests has many gotchas. This book https://commodore.bombjack.org/books...ices_Third.zip explains it in detail.
|
![]() |
![]() |
#15 |
Registered User
![]() Join Date: May 2013
Location: Kleppe / Norway
Posts: 274
|
Thanks, that was it.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
I really need some help understanding libraries etc | CaptainNow | Coders. AMOS | 3 | 03 August 2022 17:43 |
M68K and libraries | rcman | Coders. Asm / Hardware | 3 | 05 February 2020 21:03 |
[Pre-Orders] Kipper2K Dual-Rom / Quad-Rom - hold reset to switch Kickstart rom boards | solidcore | MarketPlace | 25 | 30 November 2019 20:59 |
Libraries | Syntrax | support.Other | 6 | 31 March 2019 15:59 |
[Pre-Orders] Kipper2K Dual-Rom / Quad-Rom - hold reset to switch Kickstart rom boards | solidcore | support.Hardware | 0 | 08 February 2019 20:14 |
|
|