nsw@cord.UUCP (Neil Weinstock) (01/29/89)
[ The line eater is written in COBOL ]
I wonder if y'all can help me out. I'm trying to write a very simple vblank
server, and can't quite put all the pieces together. Installing the server is
no problem, it's just the assembly language bit that's holding me up. I haven't
done any 68K assembly before, and the references I have (RKMs, Manx manual)
aren't really much of a help.
Anyway, all I want the server to do is this:
/* C representation of simple VBLANK server */
extern long sig;
extern struct Task *t1;
int toggle = 0;
server_routine() {
toggle = 1 - toggle;
if (toggle) Signal(t1,sig);
return;
}
That's it. I figure the whole thing should be 10 or 15 lines long, max.
I think I understand how to get A4 loaded at the beginning, but the Signal()
call has got me stumped. Oh yeah, I'm using Manx 3.6, small code and data,
32 bit ints.
Any help would be most appreciated.
/.- -- .. --. .- .-. ..- .-.. . ... .- -- .. --. .- .-. ..- .-.. . ...\
/ Neil Weinstock | att!cord!nsw | "One man's garbage is another \
\ AT&T Bell Labs | nsw@cord.att.com | man's prune danish." - Harv Laser /
\.- -- .. --. .- .-. ..- .-.. . ... .- -- .. --. .- .-. ..- .-.. . .../
billk@pnet01.cts.com (Bill W. Kelly) (01/30/89)
Re: Signalling a task from assembly. There may be a nicer way to do this w/ Manx's assembler (they might already have some _LVO's defined for you) but this will work: _LVOSignal EQU $febc ;maybe you can XREF _LVOSignal ? move.l thetask,a1 move.l thesignalls,d0 move.l $4,a6 ;get execbase jsr _LVOSignal(a6) ;Signal(thetask, thesignals) So... this will work. You may be able to XREF _LVOSignal and XREF ExecBase. Also, I believe d0-d1/a0-a1 may be used as scratch regs. by library routines. (or it may be d0-d3/a0-a1, so be careful...) Good Luck, Bill -- Bill W. Kelly billk@pnet01.cts.com {nosc ucsd hplabs!hp-sdd}!crash!pnet01!billk crash!pnet01!billk@nosc.mil
jesup@cbmvax.UUCP (Randell Jesup) (01/31/89)
In article <3777@crash.cts.com> billk@pnet01.cts.com (Bill W. Kelly) writes: >Also, I believe d0-d1/a0-a1 may be used as scratch regs. by library routines. >(or it may be d0-d3/a0-a1, so be careful...) Oh, when writing vblank routines, currently you must not assume the value of a0 on entry, but MUST set a0 == _custom on exit! Especially note this, people writing in C. -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup
aaron@madnix.UUCP (Aaron Avery) (01/31/89)
In article <676@cord.UUCP> nsw@cord.UUCP (Neil Weinstock) writes: >server_routine() { > toggle = 1 - toggle; > if (toggle) Signal(t1,sig); > return; >} > >That's it. I figure the whole thing should be 10 or 15 lines long, max. >I think I understand how to get A4 loaded at the beginning, but the Signal() >call has got me stumped. Oh yeah, I'm using Manx 3.6, small code and data, >32 bit ints. I think the following will get you pretty close: public _toggle,_t1,_sig,_geta4,_LVOSignal server_routine movem.l a4/a6,-(sp) jsr _geta4 ;get a4 for variable access not.w _toggle(a4) ;forgot toggle's type - this assumes a short beq.s 1$ ;toggle now off, don't signal move.l _t1(a4),a1 move.l _sig(a4),d0 ;Signal takes its arguments in a1 and d0 move.l 4,a6 ;moves SysBase into a6 jsr _LVOSignal(a6) ;not sure SysBase must go in a6, habit 1$ movem.l (sp)+,a4/a6 moveq #0,d0 ;continue server chain rts I'm just used to putting SysBase into a6 - may not matter. Be sure that the program which installed this routine hangs around until it's removed from the server chain. Otherwise, accessing toggle may tromp on something, not to mention that calling geta4() may call never-never land if the code's not there anymore. To simplify the source a bit: if you set 'near code' and 'near data', you shouldn't have to use _var(a4), and just use _var to access things. -- Aaron Avery, ASDG Inc. "A mime is a terrible thing to waste." -- Robin Williams ARPA: madnix!aaron@cs.wisc.edu {uunet|ncoast}!marque! UUCP: {harvard|rutgers|ucbvax}!uwvax!astroatc!nicmad!madnix!aaron
jesup@cbmvax.UUCP (Randell Jesup) (02/01/89)
In article <449@madnix.UUCP> aaron@madnix.UUCP (Aaron Avery) writes: > move.l 4,a6 ;moves SysBase into a6 > jsr _LVOSignal(a6) ;not sure SysBase must go in a6, habit ... >I'm just used to putting SysBase into a6 - may not matter. It does. Library calls require the library base in A6. (If they don't break without it now, they may well in the future.) Almost all CBM supplied libraries currently break without the lib base in A6. -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup
aaron@madnix.UUCP (Aaron Avery) (02/01/89)
In article <5854@cbmvax.UUCP> jesup@cbmvax.UUCP (Randell Jesup) writes: > Oh, when writing vblank routines, currently you must not assume the >value of a0 on entry, but MUST set a0 == _custom on exit! Especially note >this, people writing in C. Interesting. So, does this mean that just preserving a0 isn't sufficient? That's what you imply, since you can't assume that a0 points to _custom on entry. -- Aaron Avery, ASDG Inc. "A mime is a terrible thing to waste." -- Robin Williams ARPA: madnix!aaron@cs.wisc.edu {uunet|ncoast}!marque! UUCP: {harvard|rutgers|ucbvax}!uwvax!astroatc!nicmad!madnix!aaron
ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (02/02/89)
In article <5854@cbmvax.UUCP> jesup@cbmvax.UUCP (Randell Jesup) writes: > Oh, when writing vblank routines, currently you must not assume the >value of a0 on entry, but MUST set a0 == _custom on exit! > ^^^^^^^^^^^^^^^^^^^^^^^^^ When did this become true? Is this required for handlers, servers, or both? I have a VBlank server in "Onion" that sets D0 to 0 on exit, and it's worked great (so far). _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape INET: well!ewhac@ucbvax.Berkeley.EDU \_ -_ Recumbent Bikes: UUCP: pacbell > !{well,unicom}!ewhac O----^o The Only Way To Fly. hplabs / (pronounced "AE-wack") "Work FOR? I don't work FOR anybody! I'm just having fun." -- The Doctor
jesup@cbmvax.UUCP (Randell Jesup) (02/03/89)
In article <10569@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes: >In article <5854@cbmvax.UUCP> jesup@cbmvax.UUCP (Randell Jesup) writes: >> Oh, when writing vblank routines, currently you must not assume the >>value of a0 on entry, but MUST set a0 == _custom on exit! >> ^^^^^^^^^^^^^^^^^^^^^^^^^ > When did this become true? Is this required for handlers, servers, >or both? Only for graphics vblank servers, and it became true in 1.0, I think. > I have a VBlank server in "Onion" that sets D0 to 0 on exit, and it's >worked great (so far). D0=0, fine. It's A0 I was referring to. This is all caused by a bug in the graphics vblank server - it assumes A0 = _custom, and (sometimes) wipes A0 before exit. Handlers are allowed to assume things like a0 == _custom, as specified in exec, but servers aren't. A quote from Carl Sassenrath's new book, "Guru's Guide to the Commodore Amiga: Meditation #1 - Interrupts" (a must buy for anyone doing Amiga programming!): "there is also a problem that can occur when adding a server to the VERTB chain at a priority higher than 9. The graphics library interrupt server (at priority 10) incorrectly assumes that the A0 register contains a pointer to the custom chips. If your server runs at higher priority, it will need to exit with the correct value in A0." There's a small ad in the back of some AmigaWorld issues for it. It's published by Sassenrath Research, PO Box 1510, Ukiah, CA 95482. I don't remember the price, and it runs about 100 (information and example packed) pages. Can you tell I like it? (and I have access to the source) :-) -- Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup