Path: utzoo!attcan!uunet!husc6!mailrus!iuvax!pur-ee!j.cc.purdue.edu!ain From: ain@j.cc.purdue.edu (Pat-bob White) Newsgroups: comp.sources.amiga Subject: Xoper (sources 1 of 2) Keywords: utility, process, monitor Message-ID: <7971@j.cc.purdue.edu> Date: 17 Oct 88 00:10:17 GMT Organization: PUCC Land, USA Lines: 1536 Approved: akl@j.cc.purdue.edu (Rob Tillotson) Submitted by: Guenther Werner Summary: A system monitor utility Poster Boy: Rob Tillotson (akl@j.cc.purdue.edu) Archive Name: sources/amiga/volume5/xoper.s.1.Z Tested NOTES: This is a very good system monitor utility, written completely in assembly language. It allows you to inspect the status of just about every possible bit of the system, and also allows you to do such things as signaling tasks, opening and closing libraries, freeing task resources, and other dangerous but useful things. The source was originally one 77k assembly file; it has been split into two parts. Simply concatenate them together to produce the original source. ======================================== # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # Xoper.a.1 # This archive created: Thu Oct 13 13:44:56 1988 # By: Rob Tillotson (Bored Students Anonymous) cat << \SHAR_EOF > Xoper.a.1 ****************************************** * Xoper 1.1 Copyright (C) Werner Gunther * * Written for the A68K Assembler * * (Fish 110) by Charlie Gibbs and * * Brian R. Anderson * * * ****************************************** ;DEBUG SET 1 XDEF _SysBase sysbase equ 4 CALL MACRO xref _LVO\1 move.l \2,a6 jsr _LVO\1(a6) ENDM LIBCALL MACRO xref _\1 jsr _\1 ENDM ADDCMD MACRO cmdnum set cmdnum+1 dc.b \1,0 ENDM ;Program startup. If called from DOS we ;use segment splitting to detach ;from our DOS-task. ;A0 points to parameter area, ;D0 holds its length. start move.l a0,parmtxt move.b d0,d5 lea dosname(PC),a1 move.l sysbase,a0 lea 378(a0),a0 move.l a0,-(a7) CALL FindName,sysbase move.l d0,dosbase move.l 0(a7),a0 lea gfxname(PC),a1 CALL FindName,sysbase move.l d0,gfxbase move.l (a7)+,a0 lea intuiname(PC),a1 CALL FindName,sysbase move.l d0,intuibase move.l d0,a0 move.l $38(a0),a0 move.w 12(a0),d0 sub.w #550,d0 move.w d0,window_l move.l sysbase,a4 move.l 276(a4),a4 tst.l $ac(a4) bne.s notwb lea $5c(a4),a0 CALL WaitPort,sysbase lea $5c(a4),a0 CALL GetMsg,sysbase move.l d0,wbmsg move.w #$740a,in notwb: IFND DEBUG lea newname,a1 CALL FindTask,sysbase tst.l d0 bne oops ENDC tst.l wbmsg beq.s fromdos jmp mainprg fromdos lea in,a3 clr.l d7 move.b d5,d7 move.l parmtxt,a4 trans move.b (a4)+,(a3)+ dbf d7,trans cmpi.b #1,d5 bne.s starttask move.w #$740a,in starttask: IFND DEBUG lea start(PC),a1 suba.l #4,a1 move.l 0(a1),d3 move.l d3,myseg clr.l 0(a1) CALL Forbid,sysbase move.l #newname,d1 clr.l d2 move.l #3500,d4 CALL CreateProc,dosbase clr.l d1 CALL Exit,dosbase oops suba.l a0,a0 CALL DisplayBeep,intuibase CALL Forbid,sysbase move.l wbmsg,d0 beq.s leave move.l d0,a1 CALL ReplyMsg,sysbase clr.l d0 leave rts dosname dc.b 'dos.library',0 intuiname dc.b 'intuition.library',0 gfxname dc.b 'graphics.library',0 EVEN main CODE xoper ENDC mainprg move.l sysbase,a0 move.l a0,_SysBase move.l 276(a0),a0 move.l a0,mytask move.l #newname,10(a0) pea 0 pea 0 LIBCALL CreatePort lea 8(a7),a7 move.l d0,replyport cmp.w #'-b',in bne.s restart move.w #$740a,in bra instback ;This code just opens a CON: Window. Position ;and size are taken from window_l,window_t, ;window_w,window_h. restart move.l mytask(PC),a0 clr.l 26(a0) lea fname,a0 move.l #'con:',0(a0) clr.b 4(a0) lea buffer,a1 lea window_l(PC),a2 move.l #3,d4 rest1 move.l #2,d3 clr.l d0 move.w (a2)+,d0 bsr longdec bsr strcat move.w #$2f00,buffer bsr strcat dbf d4,rest1 lea windowname(PC),a1 bsr strcat move.l a0,d1 move.l #1005,d2 CALL Open,dosbase(PC) move.l d0,fileptr lsl.l #2,d0 move.l d0,a4 move.l 8(a4),conmsg ;get a pointer to our window move.l #buffer,d0 lsr.l #2,d0 move.l d0,dp_Arg1 move.l conmsg,a0 move.l #25,dp_Type bsr cons1 lea buffer,a0 move.l 28(a0),window clr.l ptr ;show a list. The string entered from keyboard is stored ;in 'in'.Every character is interpreted as one command ;i.e. 'rip' means 'resources'+'interrupts'+'ports'. showwhat bsr raw bsr clearscr tst.b morefl beq.s swh1 ;if is enabled we need to know how many lines can ;fit into our window move.l #getwin,d2 move.l fileptr,d1 moveq.l #4,d3 CALL Write,dosbase(PC) move.l fileptr,d1 move.l #9,d3 move.l #buffer,d2 CALL Read,dosbase(PC) lea buffer,a0 lea 5(a0),a0 bsr isdec subq.b #1,d2 move.b d2,rows clr.b row ;search the command to be executed. If none is found, ;show a help message swh1 clr.l d7 input lea in,a0 move.b 0(a0,d7),d0 addq.b #1,d7 cmpi.b #' ',d0 beq.s input cmpi.b #10,d0 beq nomore or.b #32,d0 cmpi.b #'q',d0 beq exit lea params(PC),a0 clr.l d1 i1 cmp.b 0(a0,d1),d0 beq.s foundp addq.b #1,d1 cmpi.b #parmnum,d1 bne.s i1 move.l #usetxt,d0 move.b #1,mnflag bsr putnam clr.b mnflag bra nomore foundp lsl.b #2,d1 lea subs(PC),a0 move.b #1,mnflag jsr 0(a0,d1) clr.b mnflag bra.s input ;wait for 'timeout' seconds for a kepress nomore move.l #prompt,d2 move.l fileptr,d1 moveq.l #7,d3 CALL Write,dosbase(PC) bsr con move.b timeout,d6 halt move.l #1000000,d4 bsr getkey move.l mytask(PC),a0 move.l 26(a0),d1 and.l #$1000,d1 bne exit tst.l d0 bne.s cli subq.b #1,d6 bne.s halt clr.l d4 bsr getkey tst.l d0 bne.s cli bra showwhat getkey move.l fileptr,d1 moveq.l #1,d3 move.l #null,d2 CALL Write,dosbase(PC) move.l d4,d2 move.l fileptr,d1 CALL WaitForChar,dosbase(PC) rts ;read the string from keyboard search and execute ;the command, if any. cli bsr readline lea dummy,a0 subq.b #1,d0 cl2 subq.b #1,d0 bmi.s cl1 cmp.b #' ',0(a0,d0) beq.s cl2 cl1 addq.b #1,d0 move.b #10,0(a0,d0) bsr kllblnks cmpi.b #10,0(a0) beq showwhat lea in,a1 lea commds(PC),a2 clr.b d2 tstcmd move #-1,d1 tc2 addq #1,d1 move.b 0(a0,d1),d3 or.b #32,d3 tst.b 0(a2,d1) beq.s foundcmd cmp.b 0(a2,d1),d3 beq.s tc2 nocmd tst.b (a2)+ bne.s nocmd addq.b #1,d2 cmpi.b #cmdnum,d2 bne tstcmd bra.s nm1 foundcmd cmpi.b #'*',d3 beq.s okcmd cmpi.b #' ',d3 bne.s nocmd okcmd clr.b procnum adda.w d1,a0 bsr kllblnks and.l #$ff,d2 lsl #2,d2 lea cmdaddr(PC),a1 clr.b printed jsr 0(a1,d2) tst.b morefl beq nomore tst.b printed beq nomore move.l #10,d3 move.l fileptr,d1 move.l #waittxt,d2 CALL Write,dosbase(PC) bsr readline move.l #4,d3 move.l fileptr,d1 move.l #thisline,d2 CALL Write,dosbase(PC) bra nomore nm1 lea buffer,a2 nm2 move.b (a1)+,(a2)+ cmp.b #10,-1(a1) bne.s nm2 lea in,a1 nm0 move.b (a0)+,(a1)+ dbf d0,nm0 lea dummy,a2 lea buffer,a1 nm3 move.b (a1)+,(a2)+ cmp.b #10,-1(a1) bne.s nm3 bra showwhat subs bra showtask bra showaddr bra showdevs bra showlibs bra showres bra showresi bra showmem bra showprt bra showint cmdaddr bra settime bra taskpri bra info bra pri bra flush bra freeze bra warm bra signal bra break bra alert bra lastalert bra hold bra stopall bra clear bra cancel bra moretst bra taskports bra hunks bra devices bra openlib bra closelib bra currentdir bra cd bra mypri bra openfiles bra locks bra unlock bra screens bra windows bra closescreen bra closewindow bra fonts bra windowfonts bra lockdrive bra freedrive ;------ Task-Structures----- showaddr clr.b tasktyp bra.s startask showtask move.b #1,tasktyp startask move.l #infoh1,d0 bsr putstr move.l 4,a6 move.l #cpu2,d0 btst #1,297(a6) bne.s cpupr move.l #cpu1,d0 btst #0,297(a6) bne.s cpupr move.l #cpu0,d0 cpupr jsr putstr move.l 4,a6 btst #2,297(a6) beq.s no881 move.l #cpu3,d0 bsr putstr no881 move.l #20,d1 bsr tab move.l #infoh3,d0 bsr putstr move.l _SysBase(PC),a6 move.l 280(a6),d0 move.l 284(a6),d1 move.l oldidl,d3 move.l d0,oldidl sub.l d3,d0 move.l olddisp,d3 move.l d1,olddisp sub.l d1,d3 move.l d3,-(a7) sub.l d3,d0 neg.l d3 lsl.l #2,d3 move.l d3,d1 lsl.l #3,d3 move.l d3,d2 lsl.l #1,d3 add.l d2,d3 add.l d1,d3 move.l d0,d1 move.l d3,d0 bsr div move.l d0,d3 bsr bytedec move.l #infoh4,d0 bsr putnam move.l #infoh2,d0 bsr putstr move.l (a7)+,d0 neg.l d0 clr.l d3 bsr longdec move.l #27,d1 bsr tab move.l #infoh6,d0 bsr putstr move.l 4,a4 move.l 284(a4),d0 bsr longdec move.l #nxtline,d0 bsr putstr move.l #nxtline,d0 bsr putstr lea theader(PC),a0 tst.b tasktyp bne.s phedder lea t2header(PC),a0 phedder bsr puthead bsr getaskdat lea buffer,a5 pt1 tst.b entries beq pt2 move.l 0(a5),a4 move.l a4,d0 bsr hexa tst.b tasktyp beq.s pt12 clr.l d0 move.b 8(a4),d0 bsr gettype pt12 clr.l d0 move.b 9(a5),d0 subq.b #1,d0 mulu #10,d0 move.l #status,d1 add.l d1,d0 bsr putstr tst.b tasktyp bne.s pt13 move.l 18(a4),d0 bsr hex8 move.l #ganzlongnix,d0 cmp.b #4,9(a5) beq.s pt14 bsr putstr bra.s pt15 pt14 move.l 22(a4),d0 bsr hex8 pt15 move.l 26(a4),d0 bsr hex8 move.l 54(a4),a1 move.l 0(a1),d0 cmp.b #2,9(a5) bne.s pt16 move.l #*,d0 pt16 bsr hexa bra pt4 pt13 move.b 10(a5),d3 bsr plusmins clr.b d3 cmpi.b #13,8(a5) bne.s noproc move.b 11(a5),d3 bsr bytedec bra.s pt4 noproc move.l #nix,d0 bsr putstr pt4 move.l 4(a5),d0 bsr putnam lea 12(a5),a5 subq.b #1,entries bra pt1 pt2 rts putlist move.l 0(a4),a4 tst.l 0(a4) beq.s endlist bsr putdata bra.s putlist endlist rts putdata move.l a4,0(a5) move.l 10(a4),4(a5) move.b 8(a4),8(a5) move.b 15(a4),9(a5) move.b 9(a4),10(a5) move.b 143(a4),11(a5) lea 12(a5),a5 addq.b #1,entries rts gettype and.l #$f,d0 mulu #11,d0 add.l #type,d0 bra putstr getaskdat move.w #$4000,$dff09a lea buffer,a5 clr.b entries move.l _SysBase(PC),a4 move.l 276(a4),a4 bsr putdata move.l _SysBase(PC),a4 lea 406(a4),a4 bsr putlist move.l _SysBase(PC),a4 lea 420(a4),a4 bsr putlist lea stplist(PC),a4 bsr putlist move.w #-$4000,$dff09a rts *-------- mem-hunks ------------ showmem lea mheader(PC),a0 bsr puthead move.l _SysBase(PC),a5 lea 322(a5),a5 clr.l d5 mem1 move.l 0(a5),a5 tst.l 0(a5) beq.s mem2 move.l 20(a5),d0 bsr hexa move.l 24(a5),d0 bsr hexa move.l 28(a5),d0 add.l d0,d5 moveq #1,d3 bsr longdec move.b 15(a5),d3 bsr bytedec move.b 9(a5),d3 bsr plusmins move.l 10(a5),d0 bsr putnam bra.s mem1 mem2 move.l #infoh6,d0 bsr putstr move.l #15,d1 bsr tab move.l d5,d0 bsr longdec move.l #nxtline,d0 bra putstr *--------- interrupts ------------ showint lea iheader(PC),a0 bsr puthead lea intnames(PC),a5 lea inttyp(PC),a4 move.l #15,d5 move.l _SysBase(PC),a3 lea 84(a3),a3 si0 tst.b 0(a4) bne.s si4 move.l 8(a3),a2 bra.s si5 si4 move.l 0(a3),a2 si5 cmp.l #0,a2 beq.s nxtint tst.b 0(a4) beq.s si1 si2 move.l 0(a2),a2 tst.l 0(a2) beq.s nxtint si1 move.l a2,d0 bsr hexa move.l 14(a2),d0 bsr hexa move.l 18(a2),d0 bsr hexa move.b 9(a2),d0 move.l a3,-(a7) bsr plusmins move.l (a7)+,a3 move.l a5,d0 bsr putstr move.l 10(a2),d0 tst.l d0 bne.s prtintnam move.l #ganzlongnix,d0 prtintnam bsr putnam tst.b 0(a4) bne.s si2 tst.l 0(a2) beq.s nxtint move.l 0(a4),a4 bra si1 nxtint lea 1(a4),a4 lea 12(a5),a5 lea 12(a3),a3 dbf d5,si0 rts *--------- resident ------------ showresi lea rheader(PC),a0 bsr puthead move.l _SysBase(PC),a5 move.l 300(a5),a5 r1 tst.l 0(a5) beq r2 move.l 0(a5),a4 move.l a4,d0 bsr hexa move.b 13(a4),d3 bsr plusmins move.b 10(a4),d0 bsr bin move.b 11(a4),d3 bsr bytedec move.b 12(a4),d0 bsr gettype move.l 14(a4),d0 bsr putnam lea 4(a5),a5 bra r1 r2 rts *--------- ports ------------- showprt lea pheader(PC),a0 bsr puthead move.l _SysBase(PC),a4 add.l #392,a4 lea buffer,a5 clr.l d5 CALL Forbid,_SysBase(PC) sp2 move.l 0(a4),a4 tst.l 0(a4) beq.s sp20 bsr getpdata bra.s sp2 sp20 tst.b tports beq.s sp15 sp1 move.w #$4000,$dff09a move.l _SysBase(PC),a4 move.l 276(a4),a4 lea 92(a4),a4 bsr getpdata move.l _SysBase(PC),a2 lea 406(a2),a2 sp11 move.l 0(a2),a2 tst.l 0(a2) beq.s sp14 lea 92(a2),a4 cmp.b #13,8(a2) bne.s sp11 bsr getpdata bra sp11 sp14 move.l _SysBase(PC),a2 lea 420(a2),a2 sp12 move.l 0(a2),a2 tst.l 0(a2) beq.s sp13 lea 92(a2),a4 cmp.b #13,8(a2) bne.s sp12 bsr getpdata bra sp12 sp13 move.w #-$4000,$dff09a sp15 CALL Permit,_SysBase(PC) lea buffer,a5 sp3 tst.b d5 beq sp6 move.l 0(a5),d0 bsr hexa move.l 4(a5),d0 bsr putstr move.l #23,d1 bsr tab move.b 8(a5),d0 and.l #3,d0 mulu #9,d0 add.l #mp_flags,d0 bsr putstr move.b 9(a5),d0 bsr bin move.b 14(a5),d3 bsr bytedec move.l #ganzlongnix,d0 move.l 10(a5),a3 cmp.l #0,a3 beq.s sp8 move.l 10(a3),d1 move.l d1,d2 andi.l #$ff000000,d2 bne.s sp8 move.l d1,d0 sp8 bsr putnam lea 16(a5),a5 subq.b #1,d5 bra sp3 sp6 rts getpdata move.l a4,0(a5) move.l 10(a4),4(a5) move.b 14(a4),8(a5) move.b 15(a4),9(a5) move.l 16(a4),10(a5) clr.b d0 movea.l 20(a4),a3 sp10 movea.l 0(a3),a3 cmpa.l #0,a3 beq.s sp9 addq.b #1,d0 bra.s sp10 sp9 move.b d0,14(a5) lea 16(a5),a5 addq.b #1,d5 rts *-------- resources ------------ showres lea lheader(PC),a0 bsr puthead1 lea resnam(PC),a0 bsr puthead2 move.l _SysBase(PC),d5 add.l #336,d5 bsr show rts *--------- devices ------------- showdevs lea lheader(PC),a0 bsr puthead1 lea devnam(PC),a0 bsr puthead2 move.l _SysBase(PC),d5 add.l #350,d5 bsr show rts *-------- libraries ------------- showlibs lea lheader(PC),a0 bsr puthead1 lea libnam(PC),a0 bsr puthead2 move.l _SysBase(PC),d5 add.l #378,d5 show lea buffer,a5 clr.b entries CALL Forbid,_SysBase(PC) move.l d5,a4 sl1 move.l 0(a4),a4 tst.l 0(a4) beq.s sl2 addq.b #1,entries move.l a4,0(a5) move.l 10(a4),4(a5) move.b 33(a4),8(a5) move.b 21(a4),9(a5) move.b 23(a4),10(a5) move.b 14(a4),11(a5) lea 12(a5),a5 bra.s sl1 sl2 CALL Permit,_SysBase(PC) lea buffer,a5 dl3 tst.b entries beq.s sl4 move.l 0(a5),d0 bsr hexa move.b 8(a5),d3 bsr bytedec move.b 9(a5),d3 bsr bytedec move.b 10(a5),d3 bsr bytedec move.b 11(a5),d0 bsr bin move.l 4(a5),d0 bsr putnam lea 12(a5),a5 subq.b #1,entries bra.s dl3 sl4 rts ;find the first entry in the device-list ;returns a1 = pointer to first entry devinfo move.l dosbase(PC),a1 move.l 34(a1),a1 move.l 24(a1),a1 adda.l a1,a1 adda.l a1,a1 move.l 4(a1),a1 rts ;unlock a file unlock bsr readhex tst.b d7 beq syntax move.l d0,remembr move.l d0,-(a7) move #-1,d6 bsr of44 tst.l remembr beq.s ul1 move.l #unlerr,d0 bsr putnam bra ul4 ul1 move.l #unl1,d0 bsr putstr move.l 0(a7),d0 bsr getpath move.l #unltxt2,d0 bsr putstr bsr readline ori.b #$20,dummy cmp.b #'y',dummy bne.s ul5 move.l 0(a7),d1 CALL UnLock,dosbase ul5 bsr freefinfo ul4 lea 4(a7),a7 rts ;---------- Show all Locks------------ locks clr.l d6 bra.s of33 ;---------- Open Files----------- openfiles moveq #1,d6 of33 lea ofheader(PC),a0 bsr puthead of44 bsr allocfinfo bsr devinfo move.l a1,a3 of1 adda.l a3,a3 adda.l a3,a3 cmp.l #2,4(a3) bne of2 move.l 40(a3),d0 lsl.l #2,d0 move.l d0,a4 clr.l d3 move.b (a4)+,d3 subq #1,d3 lea buffer,a5 of22 move.b (a4)+,(a5)+ dbf d3,of22 move.b #':',(a5)+ clr.b 0(a5) cmp.l #'RAM ',buffer bne.s of5 cmp.l #'Disk',buffer+4 bne.s of5 move.l #$4d3a0000,buffer+2 of5 move.l #buffer,d1 move.l #-2,d2 CALL Lock,dosbase(PC) tst.l d0 bne.s of6 move.l #buffer,d0 bsr putstr move.l #nomount,d0 bsr putnam bra of2 of6 move.l d0,-(a7) lsl.l #2,d0 move.l d0,a5 of4 move.l 0(a5),d0 cmp.l #50,d0 ble of3 move.l d0,d5 lsl.l #2,d5 move.l d5,a5 move.l d0,d5 tst d6 bpl.s of45 cmp.l remembr(PC),d0 bne.s of3 clr.l remembr move.l (a7)+,d1 CALL UnLock,dosbase(PC) rts of45 move.l 8(a5),d4 bsr getfinfo move.l finfoptr,a4 tst.l d6 beq.s of8 bmi.s of8 tst.l 4(a4) bpl of4 of8 move.l d5,d0 bsr hexa move.l #access,d0 cmp #-2,d4 beq.s of7 add.l #8,d0 of7 bsr putstr tst.l 4(a4) bmi.s of9 move.l #longnix,d0 bsr putstr bra of10 of9 move.l 124(a4),d0 bsr longdec of10 move.l d5,d0 bsr getpath bra of4 move.l #nxtline,d0 bsr putstr of3 move.l (a7)+,d1 CALL UnLock,dosbase(PC) of2 move.l 0(a3),a3 cmpa.l #0,a3 bne of1 bsr freefinfo rts ;---------- Dos Devices ---------- devices lea ddheader(PC),a0 bsr puthead bsr devinfo dev1 adda.l a1,a1 adda.l a1,a1 clr.b d6 tst.l 4(a1) bne dev2 move.l 40(a1),d0 bsr putbcpl move.l #10,d1 bsr tab cmp.l #20,28(a1) ble dev9 moveq #1,d6 move.l 28(a1),a3 adda.l a3,a3 adda.l a3,a3 cmp.l #20,8(a3) ble dev9 move.l 8(a3),a2 adda.l a2,a2 adda.l a2,a2 move.l 12(a2),d3 movem.l a1-a3,-(a7) bsr bytedec movem.l (a7)+,a1-a3 moveq #1,d3 move.l 20(a2),d0 bsr longdec move.l 40(a2),d0 beq.s devs20 addq #1,d0 sub.l 36(a2),d0 devs20 bsr longdec move.l 44(a2),d0 bsr longdec bra.s dev8 dev9 move.l #notfile,d0 bsr putstr dev8 tst.l 8(a1) beq.s dev6 move.l #devload,d0 bra.s dev5 dev6 move.l #devnload,d0 dev5 bsr putstr tst.b d6 beq.s dev7 move.l 4(a3),d0 bne.s dev4 dev7 move.l 16(a1),d0 bne.s dev4 tst.l 8(a1) beq.s dev11 move.l 8(a1),a3 move.l -82(a3),d0 bsr putstr bra dev11 dev4 bsr putbcpl dev11 move.l #nxtline,d0 bsr putstr dev2 move.l 0(a1),a1 cmpa.l #0,a1 bne dev1 rts ; Check if a named dos-device is mounted ; name in 'buffer'. ; Result: d0 = 0(false) anything else(true). finddev bsr devinfo fdev1 adda.l a1,a1 adda.l a1,a1 clr.b d6 tst.l 4(a1) bne.s fdev2 move.l 40(a1),a2 lea buffer,a0 bsr strbcmp tst d0 bne.s fdev3 fdev2 move.l 0(a1),a1 cmpa.l #0,a1 bne.s fdev1 fdev3 rts ; Re-assign a drive to dos freedrive clr.l dp_Arg1 bra ldr3 ; Inhibit a disk drive lockdrive move.l #1,dp_Arg1 ldr3 bsr getstr andi.w #$dfdf,buffer cmp.w #'DF',buffer bne syntax bsr finddev bne.s ldr1 ldr2 move.l #buffer,d0 bsr putstr move.l #nomount,d0 bra putnam ldr1 move.l #buffer,d1 CALL DeviceProc,dosbase(PC) tst.l d0 beq.s ldr2 move.l d0,a0 move.l #31,dp_Type bra cons1 ;display the current directory of all processes, ;except Workbench.(Worbench pr_CurrentDir is not a lock) currentdir lea wbname(PC),a1 CALL FindTask,_SysBase(PC) move.l d0,wbaddr lea cdheader(PC),a0 bsr puthead bsr allocfinfo bsr getaskdat lea buffer,a5 cd2 tst.b entries beq.s cd6 cmp.b #13,8(a5) bne.s cd5 move.l wbaddr(PC),d0 cmp.l 0(a5),d0 beq.s cd5 move.l 4(a5),d0 bsr putstr move.l #15,d1 bsr tab move.l 0(a5),a4 move.l 152(a4),d0 bne.s cd1 move.l #syst,d0 bsr putnam bra.s cd5 cd1 bsr getpath cd5 subq.b #1,entries lea 12(a5),a5 bra.s cd2 cd6 bsr freefinfo rts ;Change the current directory setting of a process cd move.l a0,-(a7) lea wbname(PC),a1 CALL FindTask,_SysBase(PC) move.l d0,wbaddr move.l (a7)+,a0 bsr getstr move.l a0,-(a7) move.l #buffer,d1 move.l #-2,d2 CALL Lock,dosbase(PC) move.l (a7)+,a0 tst.l d0 bne cd16 move.l #dnotf,d0 bra putnam cd16 move.l d0,remembr move.l a0,-(a7) bsr allocfinfo move.l remembr(PC),d0 bsr getfinfo move.l finfoptr,a5 move.l (a7)+,a0 tst.l 4(a5) bpl.s cd11 move.l #notdir,d0 bsr putnam bra cd18 cd11 bsr nodenam moveq.l #2,d7 lea TRuNode(PC),a4 bsr findnam tst.b d7 beq.s cd15 move.l d0,a5 cmp.b #13,8(a5) beq.s cd15 bsr syntax bra cd18 cd15 cmp.l wbaddr,d0 bne.s cd13 move.l #wberr,d0 bsr putnam bra cd12 cd13 move.l 152(a5),d1 move.l remembr,152(a5) move.l d1,remembr cd12 tst.l remembr beq.s cd14 move.l #unltxt,d0 bsr putstr move.l remembr(PC),d0 bsr getpath move.l #unltxt2,d0 bsr putstr bsr readline ori.b #$20,dummy cmp.b #'y',dummy bne.s cd14 cd18 move.l remembr(PC),d1 beq.s cd14 CALL UnLock,dosbase(PC) cd14 bsr freefinfo cd10 rts ;get all screen pointers. ;result: d5=number of screens ; buffer+100 holds pointers. getscr lea scrheader(PC),a0 bsr puthead getscr2 move.l intuibase(PC),a2 move.l 60(a2),a2 lea buffer+100,a1 move.w #$4000,$dff09a clr.l d5 sr1 move.l a2,(a1)+ move.l 0(a2),a2 addq.l #1,d5 cmpa.l #0,a2 bne.s sr1 subq #1,d5 move.w #-$4000,$dff09a rts ;display screen addresses and titles screens bsr getscr moveq #1,d6 lea buffer+100,a1 sr2 move d6,d3 bsr bytedec move.l 0(a1),d0 bsr hexa move.l (a1)+,a2 move.l 22(a2),d0 bsr putnam addq #1,d6 dbf d5,sr2 rts ;display window addresses and titles windows clr.b bool windows1 bsr getscr tst.b bool beq.s wn20 move.l d5,-(a7) lea fohead(PC),a0 bsr puthead move.l (a7)+,d5 wn20 lea buffer+100,a4 wn2 move.l #onscr,d0 bsr putstr move.l (a4)+,a2 move.l 22(a2),d0 bsr putnam move.l 4(a2),a1 clr d6 wn1 cmpa.l #0,a1 beq.s wn3 addq #1,d6 move.l d6,d3 bsr bytedec move.l a1,d0 bsr hexa move.l 32(a1),d0 bsr putnam tst.b bool beq.s wn21 move.l a1,-(a7) move.l 50(a1),a1 move.l 52(a1),a1 bsr fontdata move.l (a7)+,a1 wn21 move.l 0(a1),a1 bra.s wn1 wn3 dbf d5,wn2 rts ;close a specified screen closescreen bsr getscr2 moveq #1,d6 cmp.b #'$',0(a0) bne.s cs1 bsr readhex tst d7 beq syntax move.l d0,d4 clr.l d6 cs1 lea buffer+100,a2 cs5 tst d6 bne.s cs2 cmp.l (a2)+,d4 beq.s cs3 bra.s cs4 cs2 move.l (a2)+,a1 move.l 22(a1),a1 bsr strcmp tst d0 beq.s cs3 cs4 dbf d5,cs5 move.l #scnofound,d0 bra putnam cs3 move.l -4(a2),a0 CALL CloseScreen,intuibase(PC) rts ;close a specified window closewindow bsr getscr2 moveq #1,d6 cmp.b #'$',0(a0) bne.s cw1 bsr readhex tst d7 beq syntax move.l d0,d4 clr.l d6 cw1 lea buffer+100,a2 cw5 move.l (a2)+,a4 move.l 4(a4),a4 cw6 cmpa.l #0,a4 beq.s cw4 tst d6 bne.s cw2 cmp.l a4,d4 beq.s cw3 bra.s cw7 cw2 move.l 32(a4),a1 bsr strcmp tst d0 beq.s cw3 cw7 move.l 0(a4),a4 bra.s cw6 cw4 dbf d5,cw5 move.l #winnofound,d0 bra putnam cw3 move.l a4,a0 clr.l d0 CALL ModifyIDCMP,intuibase(PC) move.l a4,a0 CALL CloseWindow,intuibase(PC) rts ;display windows and associated fonts windowfonts move.b #1,bool bra windows1 ;display loaded font names and definitions fonts lea fohead(PC),a0 bsr puthead move.l gfxbase(PC),a1 move.l $8c(a1),a1 fo1 tst.l 0(a1) beq.s fo3 bsr fontdata move.l 0(a1),a1 bra fo1 fo3 rts fontdata move.l a1,d0 bsr hexa move.w 30(a1),d3 bsr bytedec move.w 20(a1),d3 bsr bytedec move.w 24(a1),d3 bsr bytedec move.l #romfnt,d0 btst #1,23(a1) beq.s fod1 move.l #diskfnt,d0 fod1 bsr putstr move.b 32(a1),d3 bsr bytedec move.b 33(a1),d3 bsr bytedec move.l 10(a1),d0 bra putnam ;set update rate settime bsr getnum tst.b d7 beq syntax tst.w d2 bne.s st1 move.b #1,d2 st1 move.b d2,timeout rts syntax move.l #synerr,d0 bra putnam ;copy a string from input to 'buffer' ;a0 = pointer to string getstr lea buffer,a5 gst2 cmp.b #' ',0(a0) beq.s gst1 cmp.b #10,0(a0) beq.s gst1 move.b (a0)+,(a5)+ bra.s gst2 gst1 clr.b 0(a5) bra kllblnks ;read in a nodename or a processname nodenam bsr isdec move.b d2,procnum nodenam2 bsr kllblnks move.l a0,a5 gno1 cmp.b #10,(a0)+ bne.s gno1 move.b #0,-1(a0) rts ;modify a task's priority taskpri bsr getnum tst.b d7 beq syntax move.b d2,newpri bsr nodenam moveq.l #2,d7 lea TRuNode(PC),a4 bsr findnam tst.b d7 beq.s tp1 move.l d0,a1 move.b newpri,d0 CALL SetTaskPri,_SysBase(PC) tp1 rts ;set the priority of our task mypri bsr getnum tst.b d7 beq syntax move.l _SysBase(PC),a1 move.l 276(a1),a1 move.l d2,d0 CALL SetTaskPri,_SysBase(PC) rts ;cancel a task or a process. The theory is quite simple: ;(Process->ReturnAddr)-4 points to the return address on ;the stack. Task->SPReg points to the next instruction ;to be executed. We just need a ; *(Task->SPReg) = *(Process->ReturnAddr-4). ;BUT: If the process has been started from Dos (CLI) and ;the process is doing disk I/O, the CLI will respond with ;a GURU #87000004 (AsyncPKT=unexpected packed received). ;Thats why the calling CLI is also canceled. ;Workbench tasks are unloaded after the Startup-Message has ;been replied. How in hell do we reply them ? And if the process ;has been started by a user-task we get into real trouble. cancel clr.l remembr clr.l remembr2 clr.b bool bsr nodenam testagain moveq.l #1,d7 lea TReNode(PC),a4 bsr findnam move.l a5,pointer tst.b d7 bne.s canok move.l #stperr,d0 bra putnam canok move.l d0,a1 cmp.b #1,8(a1) bne.s isproc CALL RemTask,_SysBase(PC) rts isproc clr.l d5 tst.l $ac(a1) beq.s wascreproc move.l $80(a1),a2 adda.l a2,a2 adda.l a2,a2 move.l 12(a2),d1 bne.s wascreproc move.l $ac(a1),a2 adda.l a2,a2 adda.l a2,a2 move.l 60(a2),d5 tst.l 40(a2) beq dosreturn move.l 28(a2),remembr move.l 56(a2),remembr2 bra dosreturn wascreproc tst.b bool bne.s unload move.b #2,bool move.l #canerr1,d0 bsr putstr bsr readline ori.b #$20,dummy cmp.b #'y',dummy bne.s andagain move.b #1,bool andagain move.l pointer(PC),a5 bra testagain unload cmp.b #1,bool bne.s dosreturn move.l a1,-(a7) CALL UnLoadSeg,dosbase(PC) move.l (a7)+,a1 dosreturn move.w #$4000,$dff09a move.l 54(a1),a3 move.l #endtask,0(a3) move.l #2,106(a1) move.l mytask(PC),108(a1) cmp.b #4,15(a1) bne.s doswait move.l a1,d4 CALL Remove,_SysBase(PC) move.l d4,a1 lea 406(a6),a0 CALL AddHead,_SysBase(PC) move.l d4,a1 doswait move.w #-$4000,$dff09a tst.l d5 SHAR_EOF # End of shell archive exit 0