home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / rettig / source / peekchar.asm < prev    next >
Assembly Source File  |  1990-10-21  |  2KB  |  75 lines

  1. ; PEEKCHAR.ASM
  2. ;
  3. ; by Ralph Davis
  4. ; modified by Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8.          PUBLIC   PEEKCHAR
  9.  
  10.          EXTRN    _TR_PEEK_PARMS:FAR
  11.  
  12.          INCLUDE  EXTENDA.MAC
  13.  
  14. DGROUP GROUP _DATA
  15. ;*****************************************************
  16. _DATA  SEGMENT  WORD PUBLIC 'DATA'
  17.  
  18. ;
  19. NULL_STR    DB       0
  20. CHAR_BUFF   DB       ?,0              ; Buffer for return of character
  21. ;
  22. _DATA  ENDS
  23. ;*****************************************************
  24.  
  25. ;*****************************************************
  26. PEEKCHAR_TEXT SEGMENT BYTE PUBLIC 'CODE'
  27.          ASSUME   CS:PEEKCHAR_TEXT, DS:PEEKCHAR_TEXT
  28. ;-----------------------------------------------------
  29. ;
  30. ;     PEEKCHAR(segment, offset)
  31. ;
  32. ;        segment = SPACE(4)  && hexadecimal string
  33. ;        offset  = number < 65536 or hexadecimal string
  34. ;
  35. ;        Returns:  one-byte string at segment:offset
  36. ;----------------
  37. PEEKCHAR PROC FAR
  38.  
  39.          PUSH     BP
  40.          MOV      BP,SP
  41.          PUSH     SI
  42.          PUSH     DI
  43.          PUSH     DS
  44.          PUSH     ES
  45.          CALL     _TR_PEEK_PARMS
  46.          JL       PEEKCHAR_ERR       ; Sign flag set means less than 2 parms
  47.          MOV      DS,SI              ; DS:SI now points to one-byte string 
  48.          MOV      SI,AX
  49.          MOV      DX,_DATA           ; Point ES:DI to memory location we
  50.          MOV      ES,DX              ;   will use to return character
  51.          MOV      DI,OFFSET CHAR_BUFF
  52.          MOV      AX,DI                 ; DX:AX now has address to
  53.                                         ; return to caller
  54.          MOVSB                          ; Place the character in 
  55.                                         ; the return buffer
  56.          JMP      SHORT PEEKCHAR_EXIT   ; and we're done
  57. PEEKCHAR_ERR:
  58.          MOV      DX,_DATA              ; return null string for error
  59.          MOV      AX,OFFSET NULL_STR
  60. PEEKCHAR_EXIT:
  61.          POP      ES
  62.          POP      DS
  63.          POP      DI
  64.          POP      SI
  65.          POP      BP
  66.          RET_CHAR DX,AX          ; return char * to caller
  67.          RET
  68.          
  69. PEEKCHAR ENDP
  70. ;------------------------------------------------
  71. PEEKCHAR_TEXT    ENDS
  72. ;************************************************
  73.          END
  74.  
  75.