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

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