home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / fj / question / unix / 505 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  3.2 KB

  1. Path: sparky!uunet!ccut!wnoc-tyo-news!lkbreth!utnet-news!news.u-tokyo.ac.jp!enterprise!mech.t.u-tokyo.ac.jp!mech!t20258
  2. From: t20258@mech.t.u-tokyo.ac.jp (Eiji Inoue)
  3. Newsgroups: fj.questions.unix
  4. Subject: UNIX System call on 68
  5. Message-ID: <T20258.92Nov7114702@bacula.mech.t.u-tokyo.ac.jp>
  6. Date: 7 Nov 92 02:47:02 GMT
  7. Sender: news@mech.t.u-tokyo.AC.JP (News Operator)
  8. Distribution: fj
  9. Organization: Dept. of Mechanical Engineering, Univ. of Tokyo, Japan.
  10. Lines: 78
  11. Nntp-Posting-Host: bacula
  12.  
  13.  
  14.   $@=i$a$F!"Ej9F$7$^$9!#(J
  15.   $@$+$J$j!"5$?'$NJQ$o$C$?<ALd$+$bCN$l$^$;$s$,!"$3$N!"(JNG$@$KE,$5$J$$;~$O!"$I$3$GJ9$1(J$@$PNI$$$+65$($F2<$5$$!#(J
  16.  
  17. $@!V<ALd!W(J
  18.     $@:#!"#6#8#0#0#0$N%"%;%s%V%i!<$N%=!<%9$r0\?"$7$h$&$H$7$F$$$k$N$G$9(J$@$,!"(J
  19. $@$=$NCf$K!"(JUNIX$@$N(Jsystem call($@$"$k$$$O(Jfunction call$@$H$$$&$Y$-$J$N$+$J!K(J
  20. $@$,$"$C$F!"(Jdestination $@%7%9(J$@%F%`$O!"2?$N(JBIOS$@$b;}$C$F$J$$$h$&$J$b$N$J$N$G!"(J
  21. $@$=$NF0:n$d!"F/$-$J$I$O!"2?$H$$$&K\!?;qNA$r8+$l$P!"$o$+(J$@$k$N$G$7$g$&$+!)(J
  22. $@0lHL$N(JUNIX$@$NK\$G$O!"(Jsystem call$@$H$$$C$F$b!"(JC$@$+$i!"%i%$%V%i%j!<$r8F$V7A(J
  23. $@$G;H$o$l$F$$$k(J$@$N$G!"BP1~$7$F$$$k$+$b$o$+$j$^$;$s$7!":Y$+$$!J(Jstack work
  24. or register etc.$@!K$3$H$O!"$o$+$j$^$;$s!#(J
  25.   $@%=(J$@!<%9$N$[$&$O!"0J2<$NMM$K!";H$o$l$F$$$^$9!#(J
  26.  
  27.     move.l    #3,-(a7)        ; Close all open files
  28.     clr.l    -(a7)            ;   Dummy place holder
  29.     move.l    #20,d3            ;  How many units to close
  30. abor1    moveq    #6,d0            ;  UNIX "close" system call
  31.     trap    #0
  32.     addq.l    #1,4(a7)        ;  Move to next file descriptor
  33.     dbra    d3,abor1
  34.     .
  35.     .
  36.     .
  37.     move.b    InUnit(a0),d0    ; Get file descriptor
  38.     ext.w    d0
  39.         ext.l   d0              ; Turn file descriptor into longword
  40.         move.l  #1024,-(a7)     ;  Third arg: # bytes
  41.         move.l  a0,-(a7)        ;  Second: store buffer
  42.         move.l  d0,-(a7)        ;  First arg is file descriptor
  43.         clr.l   -(a7)           ;  Dummy space holder
  44.         moveq   #3,d0        ;  UNIX READ syscall
  45.         trap    #0
  46.         bcc     getl2           ; On carry set, abort on an I/O error
  47.         jmp     io_err
  48.     .
  49.     .
  50.     .
  51.         move.l  #1,d0           ; Request 1 means "exit"
  52.         clr.l   -(a7)           ;  We will give a return code of 0
  53.         clr.l   -(a7)
  54.         trap    #0
  55.     trap    #1        ; Shouldn't reach here!
  56.     .
  57.     .
  58.     .
  59.     move.l    ounit,a1    ; Build syscall parameters
  60.     move.l    d0,-(a7)    ;  Number of bytes
  61.     move.l    a0,-(a7)    ;  Buffer
  62.     move.l    (a1),-(a7)    ;  File descriptor
  63.     clr.l    -(a7)        ;  Dummy place holder
  64.     move.l    #4,d0        ; A write syscall
  65.     trap    #0        ;  Do the call
  66.     add.l    #16,a7        ; Remove the arguments
  67.     bcc    prst3
  68.     jmp    io_err        ; Complain if the I/O failed
  69.     .
  70.     .
  71.     .
  72.     clr.b    (a1)        ; Trailing NULL
  73.     move.l    a0,d6        ;  update input pointer
  74.     clr.l    -(a7)        ; Mode 0=read
  75.     pea    pad1        ; Pointer to file name
  76.     clr.l    -(a7)        ; dummy space
  77.     moveq    #5,d0        ; Open request
  78.     trap    #0
  79.     bcs    input3
  80.     add.l    #12,a7        ; Get rid of parameters
  81.   $@$3$l$G(J$@!"$[$\$9$Y$F$G$9$,!"2r@b$7$F$b$i$&$K$O!"BgJQ$@$H;W$$$^$9$N$G!"(J
  82. $@$I$N$h$&$J5!G=$,<B8=$5$l$F$$$k$N$+$N<j(J$@$,$+$j$d!">pJs$N$"$k$H$3$m$J$I$r!"(J
  83. $@65$($F2<$5$$!#(J
  84.  
  85. --
  86.                       $@El5~Bg3X(J  $@9)3XIt(J $@5!3#>pJs(J$@9)3X2J;0G/(J   
  87.                              $@0f>e1Q<#(J  Eiji Inoue
  88.                       E-mail: t20258@mech.t.u-tokyo.ac.jp
  89.    
  90.  
  91.