home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NFSRC305.ZIP / ASM / OUTP.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-01  |  4.0 KB  |  114 lines

  1. ; File......: OUTP.ASM
  2. ; Author....: Ted Means
  3. ; CIS ID....: 73067,3332
  4. ;
  5. ; This function is an original work by Ted Means and is placed in the
  6. ; public domain.
  7. ;
  8. ; Modification history:
  9. ; ---------------------
  10. ;
  11. ;     Rev 1.4   17 Jan 1995 03:01:00   TED
  12. ;  Fixed a parameter validation bug.
  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.           Mov       CX,AX                     ; Prepare for later loop
  79.           Cmp       AX,2                      ; At least two params?
  80.           JE        @@Types                   ; If so, continue
  81.  
  82. @@Bogus:  Xor       AX,AX                     ; Set return value to false
  83.           Jmp       Short @@Exit              ; Quit
  84.  
  85. @@Types:  Push      CX                        ; Put param # on stack
  86.           Call      __ParInfo                 ; Get param type
  87.           Pop       CX                        ; Realign stack and restore CX
  88.           Test      AX,2                      ; Numeric?
  89.           JZ        @@Bogus                   ; No, so abort
  90.           Loop      @@Types                   ; Go to top of loop
  91.  
  92.           Mov       AX,1                      ; Specify first param
  93.           Push      AX                        ; Put param # on stack
  94.           Call      __ParNI                   ; Get value
  95.           Add       SP,2                      ; Realign stack
  96.           Push      AX                        ; Save value for later
  97.  
  98.           Mov       AX,2                      ; Specify first param
  99.           Push      AX                        ; Put param # on stack
  100.           Call      __ParNI                   ; Get value
  101.           Add       SP,2                      ; Realign stack
  102.           Pop       DX                        ; Get port back
  103.           Or        AH,AH                     ; Make sure a byte was passed
  104.           JNZ       @@Bogus                   ; If not, return .F.
  105.           Out       DX,AL                     ; Write a byte to the port
  106.           Mov       AX,1                      ; Set return value to true
  107.  
  108. @@Exit:  Push      AX                         ; Put return value on stack
  109.          Call      __RetL                     ; Return it to Clipper app
  110.          Add       SP,2                       ; Realign stack
  111.          RetF
  112. Endp     FT_OUTP
  113. Ends     _NanFor
  114. End