a186@mindlink.UUCP (Harvey Taylor) (07/24/89)
Some time ago somebody was wondering about what CreatePort in Amiga.Lib _really_does. Included below is a disassembly I did with Metascope & a stub program. This method is extendable to any other functions there you are interested in... <-Harvey * * _Createport in Amiga.lib * | _CreatePort | MOVEM.L D2-D5/A2,-(A7) * Save some regs | MOVE.L $18(A7),D3 * Name | MOVE.B $1F(A7),D2 * Priority | MOVEQ #-1,D5 * Any Signal | MOVE.L D5,-(A7) | JSR _AllocSignal | MOVE.B D0,D1 | MOVEQ #0,D0 * clear top | MOVE.B D1,D0 | MOVE.L D0,D4 * copy sigbit | MOVEQ #-1,D1 | CMP.L D0,D1 * any sigbit? | ADDQ.L #4,A7 | BNE.S .L8 * If ok: | MOVEQ #0,D0 * Signal error | BRA.S .L1 * exit | .L8 | MOVE.L #$10001,-(A7) * MEMF_CLEAR|MEMF_PUBLIC | PEA $22 * Size | JSR _AllocMem | MOVEA.L D0,A2 * COPY BASE | MOVE.L A2,D5 | ADDQ.L #8,A7 * FIX STACK | BNE.S .L7 * IF OK: | MOVE.L D4,-(A7) * ELSE | JSR _FreeSignal * FREE SIGNAL | MOVEQ #0,D0 | ADDQ.L #4,A7 | BRA.S .L1 * EXIT | .L7 | MOVE.L D3,$A(A2) * INSERT LN.NAME | MOVE.B D2,9(A2) * INSERT LN.PRI | MOVE.B #4,8(A2) * INSERT LN.TYPE = NT_MSGPORT | CLR.B $E(A2) * CLEAR MP.FLAGS | MOVE.B D4,$F(A2) * INSERT MP.SIGBIT | CLR.L -(A7) | JSR _FindTask | MOVE.L D0,$10(A2) * INSERT MP.SIGTASK | TST.L D3 * IS THERE A NAME? | ADDQ.L #4,A7 | BEQ.S .L6 * IF NO: | MOVE.L A2,-(A7) * If a Name Use AddPort() | JSR _AddPort | BRA.S .L12 | .L6 | PEA $14(A2) * If no name use NewList | JSR _NewList | .L12 | ADDQ.L #4,A7 | MOVE.L A2,D0 * RETURN D0 = BASE OF MSGPORT | .L1 | MOVEM.L (A7)+,D2-D5/A2 * restore regs | RTS * * * "Like some creature from a horror film, the IC that Bill Gates called `brain damaged' refuses to die." - RE Aug/89 Harvey Taylor Meta Media Productions /// uunet!van-bc!rsoft!mindlink!Harvey_Taylor /// a186@mindlink.UUCP >X/
a186@mindlink.UUCP (Harvey Taylor) (07/26/89)
Okay Andy... In Msg-ID: <3856@cps3xx.UUCP>, Joe Porkka jap@frith.cl.msu.edu asks: | | Simple question for CBM folk: What is the difference between | the CreatPort.c source in the 1.3RKM Vol. 2 and the | CreatePort() in amiga.lib ? | Then, In Msg-ID: <472@glyph.UUCP>, Andy Heffernan comments: | | In article <409@mindlink.UUCP> a186@mindlink.UUCP (Harvey Taylor) writes: | > | > Some time ago somebody was wondering about what CreatePort | > in Amiga.Lib _really_does. [etc.] | | Err, gee... | I flip to page B-5 of my 1986 Exec book, and there's the C code staring | back at me (albeit sideways). | Perhaps you missed the original posting, but the question still arises do you trust the manual? Myself I am enough of a curmudgeon to want to check ... When in doubt, disassemble! <-Harvey PS. Thanks for the response anyway. It's nice to know our postings get past ubc. "Democracy means to us Indian people, `I am going to steal your land'." - Bernard Omniyak (Chief of the Lubicon) Harvey Taylor Meta Media Productions uunet!van-bc!rsoft!mindlink!Harvey_Taylor a186@mindlink.UUCP
nichiren@glyph.UUCP (Andy Heffernan) (07/26/89)
In article <409@mindlink.UUCP> a186@mindlink.UUCP (Harvey Taylor) writes: > > Some time ago somebody was wondering about what CreatePort > in Amiga.Lib _really_does. Included below is a disassembly > I did with Metascope & a stub program. This method is extendable > to any other functions there you are interested in... Err, gee... I flip to page B-5 of my 1986 Exec book, and there's the C code staring back at me (albeit sideways). CreatePort() does (or did): AllocSignal AllocMem a MsgPort Initialize MsgPort with passed name, pri, and signal, task, etc. AddPort if passed name is non-NULL (public port) NewList if private port That's it! ><-Harvey -- ------------------------------------------------------------------------- Andy Heffernan uunet!glyph!nichiren [1222 - 1282] ------------------------------------------------------------------------- "Dogpile on the rabbit! Dogpile on the rabbit!"
gxr2848@ultb.UUCP (G.X. Roberts) (10/19/89)
Hi Netland, I have a question for all you fellow techies. I would like to create my own MsgPort via the Exec. However, I want to do it in assembler I know that the CreatePort() function exists, but only in the link library. (ie. it's not a REAL rom routine.) So, I am trying to get its equivalent. I am currently doing something like the following: 1) Allocate a hunk of memory MP_SIZE big. 2) set the LN_NAME to point to my name. 3) set the LN_PRI to 0 4) Call AddPort() I >THINK< this is the correct way of going about it. However I'm not sure, and I don't have an Exec manual handy for the source to CreatePort(), and this part of the code is a strong suspect for a bug that I have. What I'd like is one of the following: a) confirmation that this method is right, b) an example of how to do this (C or ASM), or c) source to CreatePort() from the Exec manual I really doubt c) is legal, so I'm not too concerned about that. a) or b) would solve my problem just as well. ANY help/suggestions would be appreciated! E-mail or post, as you feel appropriate. Thanks in advance, Greg Roberts II -- --- Internet: gxr2848@ultb.isc.rit.edu BITNET: gxr2848@RITVAX Talking to a mirror: "I am you, and what I see is me." (Pink Floyd)
mks@cbmvax.UUCP (Michael Sinz - CATS) (10/20/89)
In article <1448@ultb.UUCP> gxr2848@ultb.UUCP (G.X. Roberts ) writes: > > Hi Netland, > I have a question for all you fellow techies. I would like to > create my own MsgPort via the Exec. However, I want to do it in assembler > I know that the CreatePort() function exists, but only in the link > library. (ie. it's not a REAL rom routine.) So, I am trying to get > its equivalent. I am currently doing something like the following: > > 1) Allocate a hunk of memory MP_SIZE big. This works best if you make sure it is MEMF_PUBLIC | MEMF_CLEAR > > 2) set the LN_NAME to point to my name. If your program exits without removing the port, is important to allocate memory for and copy the name. > 3) set the LN_PRI to 0 You also need to allocate a signal (if you are to be able to signal the task on receipt of a message. If you use signals you need to set the mp_Flags to PA_SIGNAL If you do not use signals you will need to set it to PA_IGNORE You also need to set ln_Type to NT_MSGPORT. You need to set the mp_SigTask to your task structure. (A pointer) Now you can AddPort() Note that if your port is not to be public (that is for other tasks to find) it would be best to just do a NewList() of the mp_MsgList (the message list header for the port) > > 4) Call AddPort() > [deteted rest] /----------------------------------------------------------------------\ | /// Michael Sinz -- CATS/Amiga Software Engineer | | /// PHONE 215-431-9422 UUCP ( uunet | rutgers ) !cbmvax!mks | | /// | |\\\/// When people are free to do as they please, | | \XX/ they usually imitate each other. | \----------------------------------------------------------------------/
pl@etana.tut.fi (Lehtinen Pertti) (10/20/89)
From article <1448@ultb.UUCP>, by gxr2848@ultb.UUCP (G.X. Roberts): > > Hi Netland, > I have a question for all you fellow techies. I would like to > create my own MsgPort via the Exec. However, I want to do it in assembler > I know that the CreatePort() function exists, but only in the link > library. (ie. it's not a REAL rom routine.) So, I am trying to get > its equivalent. I am currently doing something like the following: > I would very likely use CreatePort() anyway, that doesn't cost too much and I don't have to worry doing things right. -- pl@tut.fi ! All opinions expressed above are Pertti Lehtinen ! purely offending and in subject Tampere University of Technology ! to change without any further Software Systems Laboratory ! notice
gilham@csl.sri.com (Fred Gilham) (10/24/89)
Here is some code from the speeddir code by Bryce Nesbit from fish disk 75. I know there is other stuff out there, some kind of executive support code for assembly language, but I don't remember where it is. This code will give an idea of how things are supposed to work, but perhaps it would not be as helpful as it could be unless one has the Rom Kernel Manual. Other helpful examples might be found in the example libraries (I think one is called mylib or something like that) on the fish disks. Note that you need to be able to link in all the kernel calls (say, from small.lib). That is, the code uses things like jsrlib AllocMem AllocMem is a reference to a rom kernel call. This reference will get resolved if you link in small.lib or amiga.lib. Otherwise, you have to replace Allocmem with the right (negative) number. ----------------------------- jsrlib MACRO xref _LVO\1 jsr _LVO\1(a6) ENDM jmplib MACRO xref _LVO\1 jmp _LVO\1(a6) ENDM ; ; port=CREATEPORTE(),exec ; d0 a6 ; z=error ; ;FUNCTION: Create a nameless message port, 0 priority. ;RESULT: The port pointer or Z=1 if an error occured. ;REGISTERS: A6 must contain exec! ;EXAMPLE: bsr CREATEPORTE ; beq.s noport ;Not enough memory (or signals) ; ;xref CREATEPORTE CREATEPORTE move.l a2,-(a7) move.l #MEMF_PUBLIC+MEMF_CLEAR,d1 moveq #MP_SIZE,d0 jsrlib AllocMem move.l d0,a2 tst.l d0 beq.s cp_nomemory moveq #-1,d0 jsrlib AllocSignal ;d0=return moveq #-1,d1 cmp.l d0,d1 ;-1 indicates bad signal bne.s cp_sigok move.l a2,a1 moveq #MP_SIZE,d0 jsrlib FreeMem cp_nomemory move.l (a7)+,a2 moveq #0,d0 rts cp_sigok move.b d0,MP_SIGBIT(a2) move.b #PA_SIGNAL,MP_FLAGS(a2) move.b #NT_MSGPORT,LN_TYPE(a2) clr.b LN_PRI(a2) suba.l a1,a1 ;a1=0/Find this task jsrlib FindTask ;[d0=this task] move.l d0,MP_SIGTASK(a2) lea MP_MSGLIST(a2),a0 ;Point to list header NEWLIST a0 ;Init new list macro move.l a2,d0 move.l (a7)+,a2 ;cc's NOT affected rts ; ;DELETEPORTE(port),exec ; a1 a6 ; ;FUNCTION: Deletes the port by first setting some ; fields to illegal values then calling FreeMem. ;RESULT: none ;REGISTERS: A6 must contain exec! ; ;xref DELETEPORTE DELETEPORTE move.l a1,-(a7) moveq #-1,d0 move.b d0,LN_TYPE(a1) move.l d0,MP_MSGLIST+LH_HEAD(a1) moveq #0,d0 ;Clear upper 3/4 of d0 move.b MP_SIGBIT(a1),d0 jsrlib FreeSignal move.l (a7)+,a1 moveq #MP_SIZE,d0 jmplib FreeMem
Patrick_John_Horgan@cup.portal.com (11/24/89)
Remember, if the code doing the "CreatePort()" is going to be reentrent, then you'll have to allocate memory for the name and copy it even if you're not going to leave the port laying around.