home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume44
/
toy_os
/
part03
/
five.a
< prev
next >
Wrap
Text File
|
1994-09-05
|
4KB
|
179 lines
^ register names
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
^ SVC operations
DMPSYS EQU 1
FORK EQU 2
WAIT EQU 3
GETSEM EQU 4
P EQU 5
V EQU 6
KILL EQU 7
^
CARD EQU 1
PRINT EQU 2
DISK EQU 3
^
^ This program tests the I/O
^ operations of vm_unt.
^
MAPPED
ENTRY START
^
^ First test simple I/O operations.
^
START SVC R0,,0,GETSEM
SVC R1,,SUB1,FORK
SVC R2,,SUB2,FORK
SVC ,,,WAIT
^
^ Now test the completion codes
^ returned by I/O opertions.
^
SVC R1,,SUB3,FORK
SVC ,,,WAIT
^
^ now test a few packet errors.
^
SVC R1,,SUB4,FORK
SVC ,,,WAIT
^
^ Finally, see what happens to
^ processes which are killed while
^ waiting for I/O.
^
READ ,,PAC8
LOADI R0,,0
SVC R1,,0,GETSEM
SVC R2,,0,GETSEM
SVC R3,,SUB5,FORK
SVC R2,,,P
SVC ,,,DMPSYS
SVC R3,,,KILL
HALT
^
^ Process SUB1 reads two cards from
^ the cardreader, modifies the secon
^ card slightly, and writes the cards
^ out on the disk. Process SUB2 then
^ reads the cards from disk, modifies
^ the second card again, and prints
^ the cards on the printer. The
^ cards which are output should be
^ identical to the two input cards
^ except that the 'o' on the second
^ card is changed to a '2'.
^
^
SUB1 READ ,,PAC1
LOAD R15,,BUF+46b
LOADI R14,,1
ADD R15,R14
STORE R15,,BUF+46b
WRITE ,,PAC2
SVC R0,,,V
HALT
^
SUB2 SVC R0,,,P
READ ,,PAC2
LOAD R15,,BUF+46b
LOADI R14,,1
ADD R15,R14
STORE R15,,BUF+46b
WRITE ,,PAC3
HALT
^
^
^ Process SUB3 tries to read two
^ cards from the cardreader. The
^ first read should be successful,
^ but the second should return an
^ end-of-file completion code.
^
SUB3 READ ,,PAC4
LOAD R15,,PAC4+1
BRPOS R15,,ERROR
BRNEG R15,,ERROR
READ ,,PAC4
LOAD R15,,PAC4+1
LOADI R14,,4
SUBT R15,R14
BRPOS R15,,ERROR
BRNEG R15,,ERROR
HALT
ERROR IOPR
^
^
^ Process SUB4 tries three write
^ operrations with invalid I/O
^ packets. The first uses a non-
^ existent device, the second
^ references an unused page, and
^ the third tries to write to the
^ cardreader.
^
^
SUB4 WRITE ,,PAC5
WRITE ,,PAC6
WRITE ,,PAC7
HALT
^
^ process SUB5 increments the
^ count stored in R0 and then
^ forks itself recursively. It
^ then adds the count to the
^ card image stored in BUF and
^ prints the cards on the printer.
^ Several copies of SUB5 will
^ probably be waiting for I/O
^ when the KILL request from the
^ main process is executed. The
^ exact number of card images
^ printed will depend on your
^ scheduling policies and is not
^ important.
^
SUB5 LOADI R15,,1
ADD R0,R15
SVC R3,,SUB5,FORK
LOAD R15,,BUF+13
ADD R15,R0
STORE R15,,BUF+13
WRITE ,,PAC9
SVC R2,,,V
SVC R1,,,P
IOPR
^
^
SETPC 1000b
BUF RES 100b
^
PAC1 DATA CARD,0,BUF,2,0
^
PAC2 DATA DISK,0,BUF,2,13b
^
PAC3 DATA PRINT,0,BUF,2,0
^
PAC4 DATA CARD,999,BUF,1,0
^
PAC5 DATA CARD+DISK,0,BUF,1,13b
PAC6 DATA DISK,0,BUF,5,13b
PAC7 DATA CARD,0,BUF,1,0
^
PAC8 DATA DISK,0,BUF,2,0
PAC9 DATA PRINT,0,BUF,2,0