home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / OUTP.ASM < prev    next >
Assembly Source File  |  1992-09-28  |  4KB  |  116 lines

  1. ; File......: OUTP.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   28 Sep 1992 00:49:46  $
  4. ; Revision..: $Revision:   1.3  $
  5. ; Log file..: $Logfile:   C:/nanfor/src/outp.asv  $
  6. ; This function is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   C:/nanfor/src/outp.asv  $
  13. ;  
  14. ;     Rev 1.3   28 Sep 1992 00:49:46   GLENN
  15. ;  Ted Means corrected a small bug.
  16. ;  
  17. ;     Rev 1.2   15 Aug 1991 23:07:08   GLENN
  18. ;  Forest Belt proofread/edited/cleaned up doc
  19. ;  
  20. ;     Rev 1.1   14 Jun 1991 19:54:52   GLENN
  21. ;  Minor edit to file header
  22. ;  
  23. ;     Rev 1.0   01 Apr 1991 01:03:46   GLENN
  24. ;  Nanforum Toolkit
  25. ;  
  26.  
  27.  
  28. ;  $DOC$
  29. ;  $FUNCNAME$
  30. ;      FT_OUTP()
  31. ;  $CATEGORY$
  32. ;      DOS/BIOS
  33. ;  $ONELINER$
  34. ;      Write a byte to a specified I/O port
  35. ;  $SYNTAX$
  36. ;     FT_OUTP( <nPort>, <nValue> ) -> lResult
  37. ;  $ARGUMENTS$
  38. ;      <nPort> is the port from which to retrieve the byte.
  39. ;
  40. ;      <nValue> is the value between 0 and 255 to write to the port.
  41. ;  $RETURNS$
  42. ;     .T. if all parameters were valid and the byte was written to
  43. ;         the port.
  44. ;     .F. if invalid parameters were passed.
  45. ;  $DESCRIPTION$
  46. ;     It may sometimes be useful to write a byte to a port without having
  47. ;     to resort to C or assembler.  This function allows you to do so.
  48. ;
  49. ;     The source code is written to adhere to Turbo Assembler's IDEAL mode.
  50. ;     To use another assembler, you will need to rearrange the PROC and
  51. ;     SEGMENT directives, and also the ENDP and ENDS directives (a very
  52. ;     minor task).
  53. ;  $EXAMPLES$
  54. ;     lOk := FT_OUTP( 100, 0 )   // send a Chr(0) to port 100 (064h)
  55. ;  $SEEALSO$
  56. ;     FT_INP()
  57. ;  $END$
  58. ;
  59.  
  60.  
  61.          IDEAL
  62.  
  63. Public   FT_OUTP
  64.  
  65. Extrn    __ParInfo:Far
  66. Extrn    __ParNI:Far
  67. Extrn    __RetL:Far
  68.  
  69. Segment  _NanFor   Word      "CODE"
  70.          Assume    CS:_NanFor
  71.  
  72. Proc     FT_OUTP   Far
  73.  
  74.          Xor       AX,AX                     ; Request param count
  75.          Push      AX                        ; Put request on stack
  76.          Call      __ParInfo                 ; Get param count
  77.          Add       SP,2                      ; Realign stack
  78.          Cmp       AX,2                      ; At least two params?
  79.          JNB       GetTypes                  ; If so, continue
  80. BadParam:Xor       AX,AX                     ; Set return value to false
  81.          Jmp       Short Exit                ; Quit
  82.  
  83. GetTypes:Mov       CX,2                      ; Specify param count
  84. Top:     Push      CX                        ; Put param # on stack
  85.          Call      __ParInfo                 ; Get param type
  86.          Pop       CX                        ; Realign stack and restore CX
  87.          Test      AX,2                      ; Numeric?
  88.          JZ        BadParam                  ; No, so abort
  89.          Loop      Top                       ; Go to top of loop
  90.  
  91.          Mov       AX,1                      ; Specify first param
  92.          Push      AX                        ; Put param # on stack
  93.          Call      __ParNI                   ; Get value
  94.          Add       SP,2                      ; Realign stack
  95.          Cmp       AX,255                    ; Value valid?
  96.          JA        BadParam                  ; No, so abort
  97.          Push      AX                        ; Save value for later
  98.  
  99.          Mov       AX,2                      ; Specify first param
  100.          Push      AX                        ; Put param # on stack
  101.          Call      __ParNI                   ; Get value
  102.          Add       SP,2                      ; Realign stack
  103.          Pop       DX
  104.          Out       DX,AL                     ; Write a byte to the port
  105.          Mov       AX,1                      ; Set return value to true
  106.  
  107. Exit:    Push      AX                        ; Put return value on stack
  108.          Call      __RetL                    ; Return it to Clipper app
  109.          Add       SP,2                      ; Realign stack
  110.          Ret
  111. Endp     FT_OUTP
  112. Ends     _NanFor
  113. End
  114. 
  115.