home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / INP.ASM < prev    next >
Assembly Source File  |  1991-08-16  |  3KB  |  100 lines

  1. ; File......: INP.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   15 Aug 1991 23:06:50  $
  4. ; Revision..: $Revision:   1.2  $
  5. ; Log file..: $Logfile:   E:/nanfor/src/inp.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:   E:/nanfor/src/inp.asv  $
  13. ;  
  14. ;     Rev 1.2   15 Aug 1991 23:06:50   GLENN
  15. ;  Forest Belt proofread/edited/cleaned up doc
  16. ;  
  17. ;     Rev 1.1   14 Jun 1991 19:54:34   GLENN
  18. ;  Minor edit to file header
  19. ;  
  20. ;     Rev 1.0   01 Apr 1991 01:03:22   GLENN
  21. ;  Nanforum Toolkit
  22. ;  
  23.  
  24.  
  25. ;  $DOC$
  26. ;  $FUNCNAME$
  27. ;      FT_INP()
  28. ;  $CATEGORY$
  29. ;      DOS/BIOS
  30. ;  $ONELINER$
  31. ;      Retrieve a byte from a specified I/O port
  32. ;  $SYNTAX$
  33. ;      FT_INP( <nPort> ) -> nValue
  34. ;  $ARGUMENTS$
  35. ;     <nPort> is the port from which to retrieve the byte.  If it is
  36. ;     invalid in any way, the function will return zero.
  37. ;  $RETURNS$
  38. ;     The byte retrieved.
  39. ;  $DESCRIPTION$
  40. ;     It may sometimes be useful to read a byte from a port without having
  41. ;     to resort to C or assembler.  This function allows you to do so.
  42. ;
  43. ;     The source code is written to adhere to Turbo Assembler's IDEAL mode.
  44. ;     To use another assembler, you will need to rearrange the PROC and
  45. ;     SEGMENT directives, and also the ENDP and ENDS directives (a very
  46. ;     minor task).
  47. ;  $EXAMPLES$
  48. ;     byte := FT_INP( 100 )   // read a byte from port 100 (064h)
  49. ;  $SEEALSO$
  50. ;     FT_OUTP()
  51. ;  $END$
  52. ;
  53.  
  54.  
  55.          IDEAL
  56.  
  57. Public   FT_Inp
  58.  
  59. Extrn    __ParInfo:Far
  60. Extrn    __ParNI:Far
  61. Extrn    __RetNI:Far
  62.  
  63. Segment  _NanFor   Word      "CODE"
  64.          Assume    CS:_NanFor
  65.  
  66. Proc     FT_Inp    Far
  67.  
  68.          Xor       AX,AX                     ; Request param count
  69.          Push      AX                        ; Put request on stack
  70.          Call      __ParInfo                 ; Get param count
  71.          Add       SP,2                      ; Realign stack
  72.          Or        AX,AX                     ; Zero params?
  73.          JZ        Exit                      ; If not, exit
  74.  
  75.          Mov       AX,1                      ; Specify first param
  76.          Push      AX                        ; Put param # on stack
  77.          Call      __ParInfo                 ; Get param type
  78.          Add       SP,2                      ; Realign stack
  79.          Test      AX,2                      ; Numeric?
  80.          JNZ       GetParam                  ; Yes, so continue
  81.          Xor       AX,AX                     ; Set return value to zero
  82.          JMP       Short Exit                ; Quit
  83.  
  84. GetParam:Mov       AX,1                      ; Specify first param
  85.          Push      AX                        ; Put param # on stack
  86.          Call      __ParNI                   ; Get value
  87.          Add       SP,2                      ; Realign stack
  88.          Mov       DX,AX                     ; Move port # to DX
  89.          In        AL,DX                     ; Get a byte from the port
  90.          Mov       AH,0                      ; Clear high byte
  91.  
  92. Exit:    Push      AX                        ; Put return value on stack
  93.          Call      __RetNI                   ; Return it to Clipper app
  94.          Add       SP,2                      ; Realign stack
  95.          Ret
  96. Endp     FT_Inp
  97. Ends     _NanFor
  98. End
  99.