.enable substitution .disable display ; POKE.BLD - (POKE.TSK) Modify a byte anywhere in physical memory ; Copyright (C) 1995 John Otis Lene Comeau ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; .; You should have received a copy of the GNU General Public License .; along with this program; if not, write to the Free Software .; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. .; .; A copy of the GNU General Public License is appended to the end of .; this command file. .; .; John Lene-Comeau, ICT, POB 100632, Ft. Lauderdale, FL 33310-0632 .; jcomeau@world.std.com or CompuServe: 70641,57 .; .;Build file using IND under RSX11M 4.0 or later .;Invoke as: @POKE.BLD .; After finished: INS POKE .; Usage: POKE memory-address [+ or - n] , byte-value [/keyword] .; (comma must be present, spaces need not be) .; only reliable if EQ &7 .; Otherwise, error number is (&377)/20, where: .; 0 - syntax error occurred in first parse .; 1 - syntax error in switches .; 2 - invalid memory address .; 3 - illegal (nonexistent physical) address .; 4 - no such (device, task, or partition) .; 5 - task swapped out (only under 11M, ignore link error for TS.OUT on M+) .; 6 - device is resident (not loadable, though POKE accepts more than OPE) .; type HELP OPEnregister for keyword information .;2/3/95 Most of this code stolen from my PEEK.BLD - jlc .;1/30/95 GCML$ uses too much space, replaced with GMCR$ .; Significant difference: GMCR$ returns the whole command line, whereas .; GCML$ clips the command word. .;Found bug: GMCR$ is supposed to upcase the string, but under P/OS it didn't, .; so I added a call to $CVTUC when GCML$ isn't used. .;2/2/95: x01.00 - alpha release, use at your own risk. I haven't crashed yet! .setf debug .if p1 eq "DEBUG" .sett debug .;Developed on a P/OS system with bootlegged RSX Macro assembler, so copied .; [ZZPRIVDEV] to [2,54]... .;If you want to actually link this to run under a normal P/OS system, .; change all library references to [ZZPRIVDEV] .sets sysuic .ift debug .if eq "P/OS" .sets sysuic "[2,54]" .sets lbruic "[1,1]" .ift debug .if eq "P/OS" .sets lbruic "[2,54]" .sets sysstb "lb:'sysuic'rsx11m.stb" .ift debug .if eq "P/OS" .sets sysstb "lb0:'sysuic'pos.stb" .gosub macbld .gosub tkbbld ;Assembling POKE.MAC... .if ne "DCL" .ifnins mac mac poke .if ne "DCL" .ifins mac mac poke=poke .if eq "DCL" mac poke ;Linking POKE.TSK... link @poke.tkb .exit .; .macbld: ;Building MACRO-11 source... .open poke.mac .ift debug .data debug=1 .enable data .title POKE - Modify a byte anywhere in physical memory ;Author John Comeau, jcomeau@world.std.com ;Environment RSX-11M V4.0 or greater ; uses same syntax and most options of the MCR OPEnregister command ;When building, link /PR:5 with defaults (IO page access) .enable mcl ;let MAC do the work of macro lookups ; ;note: OPE requires the task to be fixed, but POKE does not. POKE will, ; however, return an error if the task is not currently in memory. ; .title JLCMACS - macros for commonly needed tasks ;author: John Comeau, ET Ft. Lauderdale ; .macro push arg mov arg,-(sp) .endm push ; .macro pop arg mov (sp)+,arg .endm pop ; .macro symbol text,number ;make a unique symbol with letters + number text''number: .endm symbol ; .macro getsym text,number,dest ;get symbol into destination mov #text''number,dest .endm getsym ; .macro msgptr dest ;load last message symbol into destination getsym msg,\msgnum,dest .endm msgptr ; .macro message string .iif ndf msgnum, msgnum=0 .save ;current program section .pdata data ;switch to data section msgnum=msgnum+1 ;update message number symbol msg,\msgnum .asciz |string| .even ;so any word data later doesn''t get byte-aligned .restore ;back to previous program section .endm message ; .macro print string,p1,p2,p3,p4,p5,p6,p7,p8,p9 message <%2R -- string> c=0 ;arg count ror -(sp) ;save carry flag on stack push r2 ;save working registers push r1 push r0 push $dsw ;save status word .irp arg, .if nb arg push arg ;push any parameters c=c+1 .endc .endr push tskbuf+2 ;taskname in radix-50 push tskbuf ;two words mov sp,r2 ;save parameter list location msgptr r1 ;point to string add #-132.,sp ;output buffer mov sp,r0 ;place address in r0 call $edmsg ;call system formatting routine mov sp,r0 ;get address of formatted text again .iif ndf qioefn, qioefn=1 .iif ndf tiodev, tiodev=5 ;use TI: if not otherwise specified .mcall qiow$s qiow$s #io.wvb,#tiodev,#qioefn,,,, add #132.,sp ;adjust SP for output buffer add #+4,sp ;and for parameter list + rad50 taskname pop $dsw ;restore status word pop r0 ;restore registers pop r1 pop r2 rol (sp)+ ;restore carry flag .endm print ; .macro stopfor p1,p2,p3,p4,p5,p6,p7,p8,p9 ;to allow use of flag names rather than having to calculate bitmask separately .mcall stlo$s,stse$s .narg argc ;which macro to use depends on arg count .if eq argc-1 ;if only one arg... stse$s #p1 ;...easy as pie .iff mask=0 ;start off with blank bitmask .irp flag, .if nb flag bit=1 .rept flag - 1 ;for example, for flag 1, don''t repeat at all bit=bit*2 .endr mask=mask!bit .endc .endr stlo$s 0,#mask ;assume group 0 flags .endc .endm stopfor ;exits here if 9 args ; .macro waitfor p1,p2,p3,p4,p5,p6,p7,p8,p9 ;to allow use of flag names rather than having to calculate bitmask separately ; copied from my STOPFOR macro .mcall wtlo$s,wtse$s .narg argc ;which macro to use depends on arg count .if eq argc-1 ;if only one arg... wtse$s #p1 ;...easy as pie .iff mask=0 ;start off with blank bitmask .irp flag, .if nb flag bit=1 .rept flag - 1 ;for example, for flag 1, don''t repeat at all bit=bit*2 .endr mask=mask!bit .endc .endr wtlo$s 0,#mask ;assume group 0 flags .endc .endm waitfor ;exits here if 9 args ; .iif ndf id, id=1 ;program number using this error number convention ; ;error macros require subroutines similar to the following: ;accerr: ; bcc 99$ ;return if no error ; print ; sec ;refresh error flag ;99$: return ;back to caller ; .macro error label .iif ndf errnum, errnum=0 ;inc error number after each ERROR macro sec ;set error flag call label ;not really a call but a jump, used in conj w/ABORT errnum=errnum+1 .endm error ; ;alternate form ERRCHK - if C flag not set, return, otherwise same as ERROR ; Why would anyone use such a thing? Why not just BCS to the error routine? ; In my experience, as programs are changed the error routines go out of the ; 128-word branch limit, and then schlock rewrites have to be done. Using a ; CALL to an error checking routine means no rewrites, since you have the full ; virtual address space. .macro errchk label .iif ndf errnum, errnum=0 ;inc error number after each ERROR macro call label errnum=errnum+1 .endm errchk ; .macro abort severity pop r4 ;get PC from CALL used to get here print ,r4,$dsw exst$s #!!severity .endm abort ; .macro begin label ;use before every routine or subroutine .if nb label ;if label not already tagged label: .endc .enable lsb ;local symbol block, allows you to .PSECT all over the ;place without losing sight of local labels .endm begin ; .macro end label ;end every routine or subroutine with this .dsable lsb ;end the local symbol block .endm end ; .macro prginit label ;initialization common to JLC type programs .enable mcl ;enable automatic lookup of macros .pcode code .if nb label label:: .iff main:: .endc .idata impure tskbuf: .blkw 16. ;buffer for GTSK$ data .pcode code .mcall gtsk$s gtsk$s #tskbuf ;get our task''s data .enable lsb ;don''t need to use BEGIN macro for routine MAIN .endm prginit ; .macro jret label ;to pacify the idiots who insist on a common ;return point from each subroutine return ;just return from here, don''t tell anybody .endm jret ; ; .list me ;show full expansion of macro .macro incl arg,?skip ;Two methods are used: ADD #1,DEST followed by ADC DEST+2, and ; INC DEST ;BNE .+2; INC DEST+2 ;The second is faster (using LSI-11 timing, 4.90+4.90+3.50=13.30 usec ; with no rollover, vs. 4.20+1.40+4.90+4.90+4.90=20.3 usec for the ADD, ADC.) ;When it rolls over, the first method is slower by 2.8 usec due to the extra ; INC (all figures assuming mode 6 for DEST), but since this happens only ; 1/65535 of the time, this is negligible. So, defining JLC makes the INCL ; macro about 35% faster. .if df jlc inc arg ;inc the low word bne skip ;if it rolled over, it set the Z flag .iff add #1,arg ;increment by one, set carry on rollover .endc ;If it is a mode 1 argument, for example (R2), the following word ; must be expressed as 2(R2) and not (R2)+2. .ntype argtyp,arg .if ne 7- ;if NOT one of the PC modes .if eq 10- ;mode 1, (ER) .if df jlc inc 2''arg skip: .iff adc 2''arg .endc .mexit .endc .endc .if ne 60- ;anything but mode 6, E(ER), or E if PC mode .error ;arg cannot be used with INCL macro .iff .if df jlc inc 2+arg skip: .iff adc 2+arg .endc .endc .endm incl ; .macro swstk$ label ;in case macro not in system MLB''s emt 376 ;trap to $EMSST in DRDSP .word label .endm swstk$ ; cr=13. ;carriage return lf=10. ;line feed space=32. ;" " tab=9. ;^I esc=27. ; character dcs=144. ;P csi=155. ;[ st=156 ;\ invert=2 ;inverse video switch ticks=1 ;mrkt$ constants seconds=2 minutes=3 hours=4 msgnum=0 ;reinitialize these, because MAC inc''ed them as it read in this file errnum=0 ; .library "lb:'lbruic'exemc.mlb" hwddf$ ;define KISAR6 and other neat hardware stuff dcbdf$ ;device control block defs tcbdf$ ;task control block defs pcbdf$ ;partition control block defs hdrdf$ ;task header defs .idata impure .if df gcml cmdblk: gcmlb$ 1,,,5 .iff cmdblk: gmcr$ .ift prompt: .ascii "POKE>" prlen=.-prompt .even .endc ;gcml opertr: .blkw 1 number: .blkw 2 ;holds converted number from command line numbr2: .blkw 2 ;holds second converted number retval: .word ex$err ;error code, bad unless overwritten pokval: .blkw 2 ;byte value to be stored in memory .if df debug ;place known values here for debugging dbgval:: .byte 222,333 dbgpar: .blkw 6 ;store debug message parameters .endc ;debug .pcode code ; prginit ;use JLC program structure (such as it is) .if df gcml gcml$ #cmdblk,#prompt,#prlen ;get the command line .iff dir$ #cmdblk .iftf errchk 60$ ;quit on error .ift mov cmdblk+g.cmld+2,r0 ;point to retrieved command line mov cmdblk+g.cmld,r1 ;length of command .iff mov #cmdblk+g.mcrb,r0 ;point to retrieved command line movb $dsw,r1 ;length of command push r0 ;now save while we upcase the string push r1 ;... mov r1,r2 ;copy length into R2 mov r0,r1 ;copy output address=input address call $cvtuc ;convert to uppercase in place pop r1 ;restore registers... pop r0 ;... .endc ;gcml ; .if df debug ; mov r0,r2 ;copy buffer address ; add r1,r2 ;point past end of command line ; clrb (r2) ;make ASCIZ ; print ,r0,r1 ; .endc ;debug .if ndf gcml call skipcmd ;skip the command word if using GMCR$ .endc ;gcml .if df debug mov #1,90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail .endc ;debug mov #number,r3 ;supply buffer address for system routine call getnum ;get an octal ASCII number errchk 60$ ;error if none found .if df debug inc 90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail .endc ;debug mov #opertr,r3 ;address of word register for operator call getopr ;get plus or minus sign preceding next number bcs 20$ ;continue if none found errchk 70$ ;quit if end of input line mov #numbr2,r3 ;supply register address for longword call getnum ;get next number bcs 20$ ;continue if none found .if df debug inc 90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail .endc ;debug tst opertr ;see if operator is plus or minus call join ;then add or subtract as necessary 20$: call getsep ;get comma as separator errchk 60$ ;error if not found .if df debug inc 90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail .endc ;debug mov #pokval,r3 ;buffer address for system routine call getnum ;get an octal ASCII number errchk 60$ ;error if none found .if df debug inc 90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail mov pokval,dbgpar ;store word to be printed at exit mov pokval+2,dbgpar+2 .endc ;debug cmp #0,pokval ;anything in high word? errchk 60$ ;error if so cmp #255.,pokval+2 ;low word more than byte value? errchk 60$ ;error if so call getswt ;get switch if any .if df debug inc 90$ ;number of this command line word call 80$ ;show the programmer call 82$ ;also show command tail .endc ;debug 30$: call poke ;modify the byte at that location 50$: .if df debug cmpb retval,#ex$suc ;error in processing? beq 45$ 40$: movb retval,r1 ;get low byte of RETVAL ash #-4,r1 ;shift out severity nybble bic #177760,r1 ;clear all but low 4 bits print ,r1 45$: mov #dbgpar,r2 print ,(r2),2(r2),4(r2),6(r2),8.(r2) .endc ;debug exst$s retval ;exit with error status 60$: bcs 50$ ;for error checking, exits on error return ;otherwise returns 70$: beq 50$ ;quit on Z set return ;otherwise return .if df debug 80$: print ,90$ return 82$: print ,r1,r0 return 90$: .blkw 1 .endc ;debug end main ; begin join ;add or subtract the two numbers as determined by the operator ; in the command line bmi 10$ ;subract if minus add numbr2+2,number+2 ;add low words together adc number ;add in carry bit if any add numbr2,number ;then add high words jret 20$ ;return 10$: sub numbr2+2,number+2 ;subtract 2nd number from first sbc number ;subtract borrow if any sub numbr2,number ;then subtract high words 20$: return end join ; begin getnum ;Call with address of longword register for storage of converted number ; Returns C clear on success, C set on any kind of error call skipsp errchk 60$ ;error if no input past white space clr r4 ;init number of digits found mov #90$,r5 ;use local buffer for temp storage 10$: cmpb (r0),#''0 ;is it less than ASCII zero? blo 20$ ;skip if so cmpb #''7,(r0) ;ASCII 7 or less? blo 20$ ;skip if not cmp r4,#10. ;maximum? beq 10$ ;skip if so movb (r0)+,(r5)+ ;else store this digit inc r4 ;up the digit counter dec r1 ;dec command-line char count beq 20$ ;escape loop if no more input br 10$ ;loop till non-digit found 20$: tst r4 ;anything transferred before non-digit found? errchk 60$ ;error if not cmp r4,#8. ;more than 8 digits stored? (22-bit address) errchk 70$ ;error if so blt 30$ ;continue if less cmpb 90$,#''1 ;high digit 1 or 0? errchk 70$ ;error if higher, won''t fit in 22 bits 30$: mov #90$,r5 ;point to digit buffer again call .od2ct ;convert to binary return ;with carry flag as system routine leaves it 50$: sec ;set error flag 59$: return 60$: bne 59$ ;error if Z set, else return 64$: tst (sp)+ ;toss address of error check br 50$ ;set error flag and return 70$: ble 59$ ;error if past limit, else return br 64$ ;toss return address, set carry, return to GETNUM caller 90$: .blkb 10. end getnum ; begin skipsp ;returns with Z set if no more input line to process tst r1 ;any input left? beq 9$ ;return if not 1$: cmpb (r0),#space ;is it a space? beq 10$ ;skip it if so cmpb (r0),#tab ;how about ^I? beq 10$ ;skip any white space 9$: return 10$: inc r0 ;to next character dec r1 ;dec char count beq 9$ ;return if zero br 1$ ;loop back around end skipsp ; begin getsep ;get next non-whitespace char and verify that it is a comma call skipsp ;skip any leading whitespace beq 40$ ;error if EOL cmpb (r0),#'', ;comma? bne 40$ ;error if not inc r0 ;else modify globals for position... dec r1 ;...and command line length return 40$: sec ;set error flag return end getsep ; .if ndf gcml ;if using GCML$, command word isn''t passed begin skipcmd call skipsp ;skip any preceding spaces beq 40$ ;return if no command line ;we assume that the first char of the command name is alphabetic... ; subsequent chars can be any non-whitespace 8$: cmpb (r0),#''A ;less than A? (GCML$ by default uppercases command) blo 40$ ;return if so cmpb #''Z,(r0) ;past Z? blo 40$ ;return if so 10$: inc r0 ;else move on to next dec r1 ;count down characters beq 40$ ;return if end cmpb (r0),#space ;is it a space? beq 40$ ;return if so cmpb (r0),#tab ;^I? beq 40$ ;return if so br 10$ ;loop till white space or end of line 40$: return end skipcmd .endc ;gcml ; begin getr50 call skipsp ;skip any preceding spaces beq 40$ ;return if no command line mov r0,r5 ;copy current location for checking later mov r1,r4 ;copy char count, system routine overwrites R1 mov #1,r1 ;convert dots to R50 call $cat5 ;convert next 3 chars to RAD50 mov r1,r3 ;copy it into R3 mov r1,r2 ;also into R2 in case of error bcs 30$ ;skip ahead on error mov #1,r1 ;convert dots to R50 call $cat5 ;try for 3 more mov r3,r2 ;put first R50 word in R2 bcs 30$ ;skip ahead on error mov r1,r3 ;copy where calling routine expects to find it br 40$ ;successful return 30$: dec r0 ;here if carry set, meaning R0 advanced 1 too far sub r5,r0 ;see how many chars were converted sub r0,r4 ;modify char count by that amount cmp r0,#3 ;more than 1 word''s worth? bgt 38$ ;skip if so clr r3 ;else clear 2nd word 38$: add r5,r0 ;restore value of pointer 40$: mov r4,r1 ;restore R1 cmp r0,r5 ;did we advance at all? beq 50$ ;error if not return ;with carry clear from CMP instruction 50$: clr r2 ;clear both return words clr r3 ;... sec ;set carry flag return end getr50 ; begin getopr ;returns CS and 0 in OPERTR if no operator found, -1 if "-", and 1 if "+" ;returns Z set if end of line found call skipsp ;skip any white space clr opertr ;assume no operator cmpb (r0),#''- ;minus sign? beq 20$ ;return with -1 if so cmpb (r0),#''+ ;plus sign? bne 30$ ;return with carry set if not inc opertr ;return with 1 inc r0 ;also advance pointer dec r1 ;dec char count 10$: clc ;no error return 20$: com opertr ;make zero into minus 1 inc r0 ;advance pointer dec r1 ;dec char count br 10$ 30$: sec ;indicate no operator found return end getopr ; begin getequ ;returns with carry clear if "=" or ":" found, otherwise carry set call skipsp ;skip any white space cmpb (r0),#''= ;equals sign? beq 10$ ;return with CC if so cmpb (r0),#'': ;colon? bne 20$ ;return with CS if not 10$: inc r0 ;also advance pointer dec r1 ;dec char count return 20$: sec return end getequ ; begin getswt ;check for / followed by alphanumeric; if found, return 1st two alphanumerics ; in R4, but advance R0 pointer to first non-alphanumeric ;Return 0 in R4 if no switch found, carry set if "/" found but less than two ; alphanumerics .if df debug print .endc ;debug clr r4 ;assume no switch present call skipsp ;skip any white space beq 4$ ;return if no more input cmpb (r0),#''/ ;switch? beq 5$ ;continue if so 4$: sec ;set error flag return ;return 5$: inc r0 ;advance to next char dec r1 ;decrement character count beq 40$ ;return if end of line 8$: cmpb (r0),#''0 ;numeric? bcs 40$ ;bad if less cmpb #''9,(r0) ;numeric? bcc 20$ ;skip the char if so cmpb (r0),#''A ;less than A? (GCML$ by default uppercases command) blo 40$ ;bad if so cmpb #''Z,(r0) ;past Z? blo 40$ ;bad if so 20$: tstb r4 ;is R4 full yet? bne 5$ ;loop if not bisb (r0)+,r4 ;else load char into it swab r4 ;swap the bytes dec r1 ;update char count beq 40$ ;return if end of input br 8$ ;loop back around 40$: tstb r4 ;R4 full yet? bne 50$ ;good if so, just return sec ;else set error flag first (TSTB cleared it) 50$: return end getswt ; begin getdev ;Check for two alphabetics followed by ":"; return CC if found, with the chars ; in R3, otherwise CS. call skipsp ;skip any white space beq 40$ ;return if no more input clr r3 ;assume no device mnemonic present 10$: cmpb (r0),#''A ;less than A? (GCML$ by default uppercases command) blo 40$ ;bad if so cmpb #''Z,(r0) ;past Z? blo 40$ ;bad if so 20$: bisb (r0)+,r3 ;else load char into it swab r3 ;swap the bytes dec r1 ;update character count beq 40$ ;return if end of input tstb r3 ;device mnemonic stored? beq 10$ ;loop back if not cmpb (r0),#'': ;followed by colon? bne 40$ ;return carry set if not inc r0 ;else move the pointer past it dec r1 ;update char count return 40$: sec ;indicate error return end getdev ; begin poke ;Sneak into kernel state to modify the byte. Success indicated only by EX$SUC ; written into low byte of RETVAL, cannot depend on C flag! bis #<1*20>,retval ;show syntax error in command line if fails here tst r4 ;any switch? beq 60$ ;skip if not cmp r4,#"KN ;switch /KNL? beq 60$ ;skip ahead and poke the byte call getequ ;get equals sign or colon preceding switch value bcs 90$ ;quit if not found cmp r4,#"DR ;/DRV? beq 50$ ;skip if device driver offset 10$: push r4 ;save switch call getr50 ;fetch Radix-50 value into R2-R3 pop r4 ;restore switch bcs 90$ ;quit if not found mov number,r0 ;high word of address mov number+2,r1 ;low word cmp r4,#"PA ;/PAR? beq 40$ ;go on if so cmp r4,#"TA ;/TASK? bne 90$ ;quit if not callr pokeTA ;else jump to TAsk-specific POKE routine ;here for /PAR=parname switch 40$: callr pokePA ;jump to PAR-specific POKE routine ;here for /DRV switch 50$: callr pokeDR ;jump to driver-specific POKE routine ;here to directly address physical memory 60$: callr pokeKN ;jump to 22-bit addressing POKE routine 90$: return end poke ; begin safety .if ndf pr7 .library "lb:[1,1]exemc.mlb" .mcall hwddf$ hwddf$ ;define hardware stuff .endc ;ndf pr7 ;Set up safety net on bus timeouts in case of an invalid address clc ;carry must be clear for TR4ROU to be useful push @#ps ;save PSW mov #pr7,@#ps ;raise ourselves to IPL7, lock out everything else push @#4 ;;;save trap routine at absolute location 4 mov #tr4rou,@#4 ;;;set our own trap routine for bus timeouts push 4(sp) ;push return address call @(sp)+ ;coroutine "call" back to caller mov (sp)+,4(sp) ;when it comes back, store return addr up here... bcc 10$ ;skip if carry was not set by trap bis #1,2(sp) ;else set carry accordingly in saved PSW 10$: pop @#4 ;restore SST routine for trap 4 pop @#ps ;restore PSW and return return tr4rou: bis #1,2(sp) ;set carry flag in saved PSW on stack rti ;return to instruction after one that caused trap end safety ; begin pokeTA ;This could be sped up by using the active task queue, but then inactive ; fixed tasks would not be able to be accessed. ; On entry, RETVAL contains EX$ERR with error number of 1 in high nybble add #20,retval ;modify error number to 2 to mean invalid address tst r0 ;is anything in high word of size? bne 60$ ;quit if so, illegal address 10$: ashc #-6,r0 ;make 32-word block value in R1 ;programmer''s note: by using ASHC instead of ASH, we avoid having to clear ; replicated sign bit, since R0''s high bit must be clear, but R1''s may not be mov number+2,r0 ;virtual address within task bic #177700,r0 ;mask out bias bits bis #140000,r0 ;place in APR6 20$: swstk$ 90$ ;synchronize with system processes mov @#$tskhd,r5 ;get pointer to TCB chain 40$: cmp t.nam+2(r5),r3 ;is this the task? bne 80$ ;on to next if not cmp t.nam(r5),r2 ;make sure it''s the same bne 80$ ;on to next if not add #<3*20>,retval ;error 5 for TS.OUT bit #ts.out,t.stat(r5) ;task swapped out? bne 60$ ;return if so sub #<3*20>,retval ;error 2 for invalid address mov t.pcb(r5),r4 ;get PCB address beq 60$ ;quit if not there mov @#kisar6,r2 ;else save current kernel APR mov p.rel(r4),@#kisar6 ;physical address of partition mov p.hdr(r4),r3 ;pointer to task header in pool bne 46$ ;continue if header is in pool (11M, not +) mov #140000,r3 ;11M+ puts header pointers in APR6 46$: mov h.wnd(r3),r3 ;now point to window blocks beq 58$ ;quit if not there tst (r3)+ ;word following # of window blocks is start of first beq 58$ ;quit if 0 window blocks, something fishy here mov w.blvr(r3),r3 ;get the offset (0 if nonprived task) ash #-6,r3 ;shift it over to PAR bias... bic #176000,r3 ;clear replicated sign bit sub r3,r1 ;and subtract from precalculated bias bcs 58$ ;quit if borrow occurred, illegal address 48$: cmp t.tksz(r5),r1 ;must now check size limit blos 58$ ;quit if out of range 50$: add r1,@#kisar6 ;add bias of desired address add t.off(r5),@#kisar6 ;add offset from start of partition movb pokval+2,(r0) ;poke the byte movb #ex$suc,retval ;store success indication 58$: mov r2,@#kisar6 ;restore APR6 before leaving Exec state 60$: return 80$: mov t.tcbl(r5),r5 ;get next TCB in list bne 40$ ;loop if not end of list bic #360,retval ;clear current error number bis #<4*20>,retval ;set error number for no such task 90$: return end pokeTA ; begin pokeDR ; On entry, RETVAL contains EX$ERR with error number of 1 in high nybble call getdev ;get device mnemonic from input line into R3 bcs 60$ ;quit if not there mov number,r0 ;high word of address mov number+2,r1 ;low word ashc #-6,r0 ;make 32-word block value in R1 mov number+2,r0 ;offset address within partition bic #177700,r0 ;mask off PAR bits bis #140000,r0 ;place in APR6 range 20$: swstk$ 60$ ;switch to kernel state mov @#$devhd,r5 ;point to first DCB in linked list 40$: cmp d.nam(r5),r3 ;is this the requested device? bne 80$ ;skip to next if not add #<5*20>,retval ;error 6 for resident driver (non-loadable) mov d.pcb(r5),r4 ;get PCB of loadable driver partition beq 60$ ;return if not a loadable driver bic #<4*20>,retval ;error 2 for invalid address cmp p.size(r4),r1 ;address within partition memory limits? bcs 60$ ;return if not push @#kisar6 ;save Kernel APR6 mapping mov p.rel(r4),@#kisar6 ;map to the device''s subpartition add r1,@#kisar6 ;add bias of desired address movb pokval+2,(r0) ;poke the byte movb #ex$suc,retval ;store success indication pop @#kisar6 ;restore APR6 before leaving Exec state 60$: return 80$: mov d.lnk(r5),r5 ;link to next device bne 40$ ;loop if not end of list bic #360,retval ;clear current error number bis #<4*20>,retval ;set error number for no such device return end pokeDR ; begin pokeKN ; On entry, RETVAL contains EX$ERR with error number of 1 in high nybble mov number+2,r1 ;low word of requested address mov number,r0 ;high word ashc #-6,r0 ;get number of 32-word blocks mov number+2,r0 ;get address again... bic #177700,r0 ;this time block APR bias bis #140000,r0 ;place in APR6 range bis #<3*20>,retval ;error number 3=nonexistent memory swstk$ 80$ ;to system state push @#kisar6 ;place calculated APR into 6 mov r1,@#kisar6 ;load calculated PAR call safety ;set up safety net first movb pokval+2,(r0) ;poke the byte call @(sp)+ ;take down the safety net and get results back bcs 70$ ;quit if address was no good movb #ex$suc,retval ;store success indication 70$: pop @#kisar6 ;restore APR6 so RSX doesn''t go schizo 80$: return end pokeKN ; begin pokePA ;Return byte from addressed offset within a named partition ; On entry, RETVAL contains EX$ERR with error number of 1 in high nybble ashc #-6,r0 ;make 32-word block value in R1 mov number+2,r0 ;virtual address within task bic #177700,r0 ;clear PAR bias bits bis #140000,r0 ;place in APR6 add #20,retval ;error 2 for invalid address specified 20$: swstk$ 60$ ;for safe access to executive databases mov @#$parhd,r5 ;get first partition in linked list 40$: cmp p.nam+2(r5),r3 ;is this the named partition? bne 80$ ;skip if not cmp p.nam(r5),r2 ;make sure bne 80$ ;try next in list cmp p.size(r5),r1 ;is address within partition size? ;If p.size holds 200, that''s good for addresses through 17776... so the size ; value must be at least one MORE than the shifted address (use BLOS) blos 60$ ;return if not push @#kisar6 ;save current APR6 mov p.rel(r5),@#kisar6 ;physical address of partition=new APR6 add r1,@#kisar6 ;add in bias of desired address add #20,retval ;error 3 for illegal address call safety ;set up safety net movb pokval+2,(r0) ;poke the byte call @(sp)+ ;take down net and check for error bcs 50$ ;quit if nonexistent memory movb #ex$suc,retval ;store success indication 50$: pop @#kisar6 ;restore APR6 before leaving Exec state 60$: return 80$: mov p.lnk(r5),r5 ;link to next partition in list bne 40$ ;loop if not end of list bic #360,retval ;clear current error number bis #<4*20>,retval ;set error number for no such partition return end pokePA ; .end main .disable data .close .return .; .tkbbld: ;Building Link file... .open poke.tkb .enable data poke/pr:5,poke,poke=poke 'sysstb'/ss / task=...pok // .disable data .close .return .; GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.