home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / toy_os / part03 / five.a < prev    next >
Text File  |  1994-09-05  |  4KB  |  179 lines

  1. ^    register names
  2.  R0     EQU    0
  3.  R1     EQU    1
  4.  R2     EQU    2
  5.  R3     EQU    3
  6.  R4     EQU    4
  7.  R5     EQU    5
  8.  R6     EQU    6
  9.  R7     EQU    7
  10.  R8     EQU    8
  11.  R9     EQU    9
  12.  R10    EQU    10
  13.  R11    EQU    11
  14.  R12    EQU    12
  15.  R13    EQU    13
  16.  R14    EQU    14
  17.  R15    EQU    15
  18. ^    SVC operations
  19.  DMPSYS EQU    1
  20.  FORK   EQU    2
  21.  WAIT   EQU    3
  22.  GETSEM EQU    4
  23.  P      EQU    5
  24.  V      EQU    6
  25.  KILL   EQU    7
  26. ^
  27.  CARD   EQU    1
  28.  PRINT  EQU    2
  29.  DISK   EQU    3
  30. ^
  31. ^    This program tests the I/O
  32. ^    operations of vm_unt.
  33. ^
  34.         MAPPED
  35.         ENTRY  START
  36. ^
  37. ^    First test simple I/O operations.
  38. ^
  39.  START  SVC    R0,,0,GETSEM
  40.         SVC    R1,,SUB1,FORK
  41.         SVC    R2,,SUB2,FORK
  42.         SVC    ,,,WAIT
  43. ^
  44. ^    Now test the completion codes
  45. ^    returned by I/O opertions.
  46. ^
  47.         SVC    R1,,SUB3,FORK
  48.         SVC    ,,,WAIT
  49. ^
  50. ^    now test a few packet errors.
  51. ^
  52.         SVC    R1,,SUB4,FORK
  53.         SVC    ,,,WAIT
  54. ^
  55. ^    Finally, see what happens to
  56. ^    processes which are killed while
  57. ^    waiting for I/O.
  58. ^
  59.         READ   ,,PAC8
  60.         LOADI  R0,,0
  61.         SVC    R1,,0,GETSEM
  62.         SVC    R2,,0,GETSEM
  63.         SVC    R3,,SUB5,FORK
  64.         SVC    R2,,,P
  65.         SVC    ,,,DMPSYS
  66.         SVC    R3,,,KILL
  67.         HALT
  68. ^
  69. ^    Process SUB1 reads two cards from
  70. ^    the cardreader, modifies the secon
  71. ^    card slightly, and writes the cards
  72. ^    out on the disk. Process SUB2 then
  73. ^    reads the cards from disk, modifies
  74. ^    the second card again, and prints
  75. ^    the cards on the printer. The
  76. ^    cards which are output should be
  77. ^    identical to the two input cards
  78. ^    except that the 'o' on the second
  79. ^    card is changed to a '2'.
  80. ^
  81. ^
  82.  SUB1   READ   ,,PAC1
  83.         LOAD   R15,,BUF+46b
  84.         LOADI  R14,,1
  85.         ADD    R15,R14
  86.         STORE  R15,,BUF+46b
  87.         WRITE  ,,PAC2
  88.         SVC    R0,,,V
  89.         HALT
  90. ^
  91.  SUB2   SVC    R0,,,P
  92.         READ   ,,PAC2
  93.         LOAD   R15,,BUF+46b
  94.         LOADI  R14,,1
  95.         ADD    R15,R14
  96.         STORE  R15,,BUF+46b
  97.         WRITE  ,,PAC3
  98.         HALT
  99. ^
  100. ^
  101. ^    Process SUB3 tries to read two
  102. ^    cards from the cardreader. The
  103. ^    first read should be successful,
  104. ^    but the second should return an
  105. ^    end-of-file completion code.
  106. ^
  107.  SUB3   READ   ,,PAC4
  108.         LOAD   R15,,PAC4+1
  109.         BRPOS  R15,,ERROR
  110.         BRNEG  R15,,ERROR
  111.         READ   ,,PAC4
  112.         LOAD   R15,,PAC4+1
  113.         LOADI  R14,,4
  114.         SUBT   R15,R14
  115.         BRPOS  R15,,ERROR
  116.         BRNEG  R15,,ERROR
  117.         HALT
  118.  ERROR  IOPR
  119. ^
  120. ^
  121. ^    Process SUB4 tries three write
  122. ^    operrations with invalid I/O
  123. ^    packets. The first uses a non-
  124. ^    existent device, the second
  125. ^    references an unused page, and
  126. ^    the third tries to write to the
  127. ^    cardreader.
  128. ^
  129. ^
  130.  SUB4   WRITE  ,,PAC5
  131.         WRITE  ,,PAC6
  132.         WRITE  ,,PAC7
  133.         HALT
  134. ^
  135. ^    process SUB5 increments the
  136. ^    count stored in R0 and then
  137. ^    forks itself recursively. It
  138. ^    then adds the count to the
  139. ^    card image stored in BUF and
  140. ^    prints the cards on the printer.
  141. ^    Several copies of SUB5 will
  142. ^    probably be waiting for I/O
  143. ^    when the KILL request from the
  144. ^    main process is executed. The
  145. ^    exact number of card images
  146. ^    printed will depend on your
  147. ^    scheduling policies and is not
  148. ^    important.
  149. ^
  150.  SUB5   LOADI  R15,,1
  151.         ADD    R0,R15
  152.         SVC    R3,,SUB5,FORK
  153.         LOAD   R15,,BUF+13
  154.         ADD    R15,R0
  155.         STORE  R15,,BUF+13
  156.         WRITE  ,,PAC9
  157.         SVC    R2,,,V
  158.         SVC    R1,,,P
  159.         IOPR
  160. ^
  161. ^
  162.         SETPC  1000b
  163.  BUF    RES    100b
  164. ^
  165.  PAC1   DATA   CARD,0,BUF,2,0
  166. ^
  167.  PAC2   DATA   DISK,0,BUF,2,13b
  168. ^
  169.  PAC3   DATA   PRINT,0,BUF,2,0
  170. ^
  171.  PAC4   DATA   CARD,999,BUF,1,0
  172. ^
  173.  PAC5   DATA   CARD+DISK,0,BUF,1,13b
  174.  PAC6   DATA   DISK,0,BUF,5,13b
  175.  PAC7   DATA   CARD,0,BUF,1,0
  176. ^
  177.  PAC8   DATA   DISK,0,BUF,2,0
  178.  PAC9   DATA   PRINT,0,BUF,2,0
  179.