home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_05 / v7n5070a.txt < prev    next >
Text File  |  1989-05-29  |  13KB  |  444 lines

  1.                            F I G U R E   1
  2.  
  3.  
  4.  
  5.                 no data value          integer     character pointer
  6.                   returned             returned        returned
  7.  
  8. status       fdelete    sdelete         fclear          accept
  9. returned     fpost      spend           fcreate         gblock
  10.              pcreate    spost           finquiry        pend
  11.              pextend    tcreate         fpend           qaccept
  12.              post       tdelete         qinquiry        qpend
  13.              qcreate    tpriority       screate
  14.              qecreate   tresume         sinquiry
  15.              qjam       tsuspend        tinquiry
  16.              qpost      waitc
  17.              rblock
  18.  
  19. no status    lock       tdelay          getc            ------
  20. returned     putc       tslice          gtime
  21.              stime      unlock
  22.                            F I G U R E   1 0
  23.  
  24.  
  25.  
  26. ####################################################
  27. # NAME
  28. #       sc_fpend  -  pend on event flag group
  29. #
  30. # SYNOPSIS
  31. #       int sc_fpend(efgid,timeout,flags,andor,status)
  32. #               int efgid       event flag group id number
  33. #               int timeout     timeout value (ticks)
  34. #               int flags       event flags mask
  35. #               int andor       and/or indicator
  36. #               int *status     return status ptr
  37. #
  38. # DESCRIPTION
  39. #       The sc_fpend call pends for one or more events
  40. #       on the specified event flag group, and returns
  41. #       the event flag group that readied the caller.
  42. #       If the andor indicator is AND, all specified
  43. #       event flags must have a value of one simul-
  44. #       taneously.  If the andor indicator is OR, any
  45. #       of the specified event flags ready the task.
  46. #
  47. # RETURNS
  48. #       event flag group
  49. #
  50. # RETURN CODES
  51. #       RET_OK          successful return
  52. #       ER_TMO          timeout
  53. #       ER_ID           event flag group id error
  54. #       ER_DEL          event flag group is deleted
  55. ####################################################
  56.  
  57.  
  58.         set     VRTX,0          # set VRTX trap number
  59.         set     FCODE,0x19      # set VRTX function code
  60.  
  61.  
  62.         text
  63.         global  sc_fpend
  64. sc_fpend:
  65.         mov.l   %d2,-(%sp)      # save registers
  66.         mov.l   %d3,-(%sp)      
  67.         mov.l   %d4,-(%sp)
  68.  
  69.         mov.l   (16,%sp),%d1    # put event flag group id into d1
  70.         mov.l   (20,%sp),%d2    # put timeout into d2
  71.         mov.l   (24,%sp),%d3    # put event flags mask into d3
  72.         mov.l   (28,%sp),%d4    # put and/or indicator into d4
  73.         mov.l   &FCODE,%d0      # put function code into d0
  74.  
  75.         trap    &VRTX           # call VRTX
  76.         
  77.         mov.l   (32,%sp),%a0    # place return status code into
  78.         mov.l   %d0,(%a0)       #       desired address
  79.         mov.l   %d2,%d0         # return event flag group value
  80.  
  81.         mov.l   (%sp)+,%d4      # restore registers
  82.         mov.l   (%sp)+,%d3
  83.         mov.l   (%sp)+,%d2
  84.         rts
  85.                            F I G U R E   1 1
  86.  
  87.  
  88.  
  89. ####################################################
  90. # NAME
  91. #       sc_pend  -  pend for message from mailbox
  92. #
  93. # SYNOPSIS
  94. #       char *sc_pend(boxadr,timeout,status)
  95. #               char *boxadr    mailbox address
  96. #               int timeout     timeout value
  97. #               int *status     return status ptr
  98. #
  99. # DESCRIPTION
  100. #       The sc_pend call obtains a 32-bit nonzero
  101. #       message from the specified mailbox.
  102. #
  103. # RETURNS
  104. #       message
  105. #
  106. # RETURN CODES
  107. #       RET_OK          successful return
  108. #       ER_TMO          timeout occurred
  109. ####################################################
  110.  
  111.  
  112.         set     VRTX,0          # set VRTX trap number
  113.         set     FCODE,0x09      # set VRTX function code
  114.  
  115.  
  116.         text
  117.         global  sc_pend
  118. sc_pend:
  119.         mov.l   (4,%sp),%a0     # put mailbox address into a0
  120.         mov.l   (8,%sp),%d1     # put timeout value into d1
  121.         mov.l   &FCODE,%d0      # put function code into d0
  122.  
  123.         trap    &VRTX           # call VRTX
  124.         
  125.         mov.l   (12,%sp),%a0    # place return status code into
  126.         mov.l   %d0,(%a0)       #       desired address
  127.         mov.l   %d1,%a0         # return message
  128.  
  129.         rts
  130.                            F I G U R E   1 2
  131.  
  132.  
  133.  
  134. ####################################################
  135. # NAME
  136. #       sc_putc  -  put character
  137. #
  138. # SYNOPSIS
  139. #       sc_putc(c)
  140. #               int c           character
  141. #
  142. # DESCRIPTION
  143. #       The sc_putc call specifies the next character
  144. #       to transmit to the supported i/o device.
  145. #
  146. ####################################################
  147.  
  148.  
  149.         set     VRTX,0          # set VRTX trap number
  150.         set     FCODE,0x0e      # set VRTX function code
  151.  
  152.  
  153.         text
  154.         global  sc_putc
  155. sc_putc:
  156.         mov.l   (4,%sp),%d1     # put message into d1
  157.         mov.l   &FCODE,%d0      # put function code into d0
  158.  
  159.         trap    &VRTX           # call VRTX
  160.  
  161.         rts
  162.                            F I G U R E   1 3
  163.  
  164.  
  165.  
  166. ####################################################
  167. # NAME
  168. #       sc_getc  -  get character
  169. #
  170. # SYNOPSIS
  171. #       int sc_getc()
  172. #
  173. # DESCRIPTION
  174. #       The sc_getc call obtains the next character
  175. #       from the supported i/o device.
  176. #
  177. # RETURNS
  178. #       next character
  179. ####################################################
  180.  
  181.  
  182.         set     VRTX,0          # set VRTX trap number
  183.         set     FCODE,0x0d      # set VRTX function code
  184.  
  185.  
  186.         text
  187.         global  sc_getc
  188. sc_getc:
  189.         mov.l   &FCODE,%d0      # set function code
  190.         trap    &VRTX           # call VRTX
  191.         
  192.         clr.l   %d0             
  193.         mov.b   %d1,%d0         # return received char
  194.         
  195.         rts
  196.                            F I G U R E   2
  197.  
  198.  
  199.  
  200.         /*******************************/
  201.         /* TEST FUNCTION RETURN VALUES */
  202.         /*******************************/
  203. main()
  204. {
  205.         void f_noret();         /* no return value */
  206.         int f_int();            /* integer return */
  207.         char *f_charpt();       /* char pointer return */
  208.         register int intval;    
  209.         register char *ptrval;
  210.  
  211.  
  212.                 /* store junk */
  213.         intval = 1;                     mov.l   &1,%d2
  214.         ptrval = (char *)5000;          mov.l   &5000,%a2
  215.  
  216.                 /* call "procedure" */
  217.         f_noret();                      jsr     f_noret
  218.  
  219.                 /* call int function */
  220.         intval = f_int();               jsr     f_int
  221.                                         mov.l   %d0,%d2
  222.  
  223.                 /* call char ptr function */
  224.         ptrval = f_charpt();            jsr     f_charpt
  225.                                         mov.l   %a0,%a2
  226. }                                       rts
  227.                            F I G U R E   3
  228.  
  229.  
  230.  
  231.         /**************************/
  232.         /* TEST PARAMETER PASSING */
  233.         /**************************/
  234. main()
  235. {
  236.         void f_test();          /* test function */
  237.         int status;             /* status return */
  238.         register int intval;
  239.         register char *chptr;
  240.  
  241.  
  242.         f_test(intval, chptr, &status); mov.l   &status,(%sp)
  243.                                         mov.l   %a2,-(%sp)
  244.                                         mov.l   %d2,-(%sp)
  245.                                         jsr     f_test
  246.                                         add.l   &12,%sp
  247. }                                       rts
  248.  
  249.  
  250.  
  251. void f_test(p1, p2, stat)
  252.         int p1;
  253.         char *p2;
  254.         int *stat;
  255. {
  256.         *stat = 17;                     mov.l   (12,%sp),%a0
  257.                                         mov.l   &17,(%a0)
  258. }                                       rts
  259.                            F I G U R E   4
  260.  
  261.  
  262.  
  263. #  status returned, no data returned
  264. #
  265. #  C INTERFACE:
  266. #       void syscall();
  267. #       int intval, status;
  268. #
  269. #       syscall(intval, &status);
  270. #
  271. #  ASSEMBLY INTERFACE:
  272. #       INPUT:  d0      function code
  273. #               d1      integer input parameter
  274. #       OUTPUT: d0      status code
  275.  
  276.  
  277.         mov.l   (4,%sp),%d1     # put input parameter into d1
  278.         mov.l   &FCODE,%d0      # put function code into d0
  279.  
  280.         trap    &VRTX           # call VRTX
  281.         
  282.         mov.l   (8,%sp),%a0     # place return status code into
  283.         mov.l   %d0,(%a0)       #       desired address
  284.  
  285.         rts
  286.                            F I G U R E   5
  287.  
  288.  
  289.  
  290. #  status returned, integer data value returned
  291. #
  292. #  C INTERFACE:
  293. #       int syscall();
  294. #       int intval1, intval2, status;
  295. #       int dataval;
  296. #
  297. #       dataval = syscall(intval1, intval2, &status);
  298. #
  299. #  ASSEMBLY INTERFACE:
  300. #       INPUT:  d0      function code
  301. #               d1      integer input parameter
  302. #               d2      integer input parameter
  303. #       OUTPUT: d0      status code
  304. #               d2      integer result
  305.  
  306.  
  307.         mov.l   %d2,-(%sp)      # save register
  308.  
  309.         mov.l   (8,%sp),%d1     # put input parameter1 into d1
  310.         mov.l   (12,%sp),%d2    # put input parameter2 into d2
  311.         mov.l   &FCODE,%d0      # put function code into d0
  312.  
  313.         trap    &VRTX           # call VRTX
  314.         
  315.         mov.l   (16,%sp),%a0    # place return status code into
  316.         mov.l   %d0,(%a0)       #       desired address
  317.         mov.l   %d2,%d0         # return integer data value
  318.  
  319.         mov.l   (%sp)+,%d2      # restore register
  320.         rts
  321.                            F I G U R E   6
  322.  
  323.  
  324.  
  325. #  status returned, character pointer data value returned
  326. #
  327. #  C INTERFACE:
  328. #       char *syscall();
  329. #       char *adrval;
  330. #       int intval, status;
  331. #       char *dataval;
  332. #
  333. #       dataval = syscall(adrval, intval, &status);
  334. #
  335. #  ASSEMBLY INTERFACE:
  336. #       INPUT:  d0      function code
  337. #               d1      integer input parameter
  338. #               a0      char pointer input parameter
  339. #       OUTPUT: d0      status code
  340. #               d1      char pointer result
  341.  
  342.  
  343.         mov.l   (4,%sp),%a0     # put address parameter into a0
  344.         mov.l   (8,%sp),%d1     # put integer parameter into d1
  345.         mov.l   &FCODE,%d0      # put function code into d0
  346.  
  347.         trap    &VRTX           # call VRTX
  348.         
  349.         mov.l   (12,%sp),%a0    # place return status code into
  350.         mov.l   %d0,(%a0)       #       desired address
  351.         mov.l   %d1,%a0         # return message
  352.  
  353.         rts
  354.                            F I G U R E   7
  355.  
  356.  
  357.  
  358. #  no status returned, no data value returned
  359. #
  360. #  C INTERFACE:
  361. #       void syscall();
  362. #       int intval;
  363. #
  364. #       syscall(intval);
  365. #
  366. #  ASSEMBLY INTERFACE:
  367. #       INPUT:  d0      function code
  368. #               d1      integer input parameter
  369. #       OUTPUT: d0      status code (always indicates success)
  370.  
  371.  
  372.         mov.l   (4,%sp),%d1     # put integer parameter into d1
  373.         mov.l   &FCODE,%d0      # put function code into d0
  374.  
  375.         trap    &VRTX           # call VRTX
  376.  
  377.         rts
  378.                            F I G U R E   8
  379.  
  380.  
  381.  
  382. #  no status returned, integer data value returned
  383. #
  384. #  C INTERFACE:
  385. #       int syscall();
  386. #       int dataval;
  387. #
  388. #       dataval = syscall();
  389. #
  390. #  ASSEMBLY INTERFACE:
  391. #       INPUT:  d0      function code
  392. #       OUTPUT: d0      status code (always indicates success)
  393. #               d1      integer result
  394.  
  395.  
  396.         mov.l   &FCODE,%d0      # set function code
  397.         trap    &VRTX           # call VRTX
  398.         
  399.         mov.l   %d1,%d0         # return integer result
  400.         
  401.         rts
  402.                            F I G U R E   9
  403.  
  404.  
  405.  
  406. ####################################################
  407. # NAME
  408. #       sc_post  -  post message to mailbox
  409. #
  410. # SYNOPSIS
  411. #       sc_post(boxadr,msg,status)
  412. #               char *boxadr    mailbox address
  413. #               char *msgadr    message
  414. #               int *status     return status ptr
  415. #
  416. # DESCRIPTION
  417. #       The sc_post call posts a 32-bit nonzero
  418. #       message to the specified mailbox.
  419. #
  420. # RETURN CODES
  421. #       RET_OK          successful return
  422. #       ER_MIU          mailbox in use
  423. #       ER_ZMW          zero message
  424. ####################################################
  425.  
  426.  
  427.         set     VRTX,0          # set VRTX trap number
  428.         set     FCODE,0x08      # set VRTX function code
  429.  
  430.  
  431.         text
  432.         global  sc_post
  433. sc_post:
  434.         mov.l   (4,%sp),%a0     # put mailbox address into a0
  435.         mov.l   (8,%sp),%d1     # put message into d1
  436.         mov.l   &FCODE,%d0      # put function code into d0
  437.  
  438.         trap    &VRTX           # call VRTX
  439.         
  440.         mov.l   (12,%sp),%a0    # place return status code into
  441.         mov.l   %d0,(%a0)       #       desired address
  442.  
  443.         rts
  444.