home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
rettig.zip
/
TRSOURCE.EXE
/
POKEBYTE.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-22
|
3KB
|
106 lines
; POKEBYTE.ASM
;
; by Ralph Davis
; modified by Leonard Zerman
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC POKEBYTE
INCLUDE EXTENDA.MAC
EXTRN __TR_HTOI:FAR ; Internal TR.LIB routines
EXTRN _TR_POKE_PARMS:FAR
DGROUP GROUP _DATA
;*****************************************************
_DATA SEGMENT WORD PUBLIC 'DATA'
;
; Saves input segment and offset
;
SEG_ADDR DW ?
OFF_ADDR DW ?
;
_DATA ENDS
;*****************************************************
;*****************************************************
POKEBYTE_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:POKEBYTE_TEXT,DS:_DATA
;-----------------------------------------------------
;
; POKEBYTE(segment, offset, value)
;
; pokes value as 1-byte integer
;
; segment = SPACE(4) && hexadecimal string
; offset = number < 65536 or hexadecimal string
; value = number or hexadecimal string
;
; Returns: .F. if less than three parameters passed
; .T. otherwise
;
;--------------
POKEBYTE PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
PUSH BX
PUSH DX
PUSH SI
CALL _TR_POKE_PARMS ; returns segment address in DX,
; offset in AX
JL POKEBYTE_ERR ; Sign flag set means less than 2 parms
PUSH DS ; Save caller's DS
MOV BX,_DATA ; Point DS to our data segment
MOV DS,BX
MOV SEG_ADDR,DX
MOV OFF_ADDR,AX
POP DS
GET_PTYPE 3 ; find out if parameter is character
; or numeric
AND AX,CHARACTER ; Is it a hexadecimal string?
JNZ POKEBYTE_HEX ; yes
GET_INT 3 ; no, pick it up as integer in AX
MOV BX,AX ; and move it to BX
JMP SHORT POKE_BYTE_4
POKEBYTE_HEX:
GET_CHAR 3 ; Get parameter as char *
PUSH DX ; Call _TR_HTOI
PUSH AX
CALL __TR_HTOI ; AX now contains parameter as integer
MOV BX,AX ; save it in BX
ADD SP,4 ; Discard parameters PUSHed onto stack
POKE_BYTE_4:
MOV AX,_DATA ; Point to our data segment
MOV DS,AX
MOV AX,OFF_ADDR ; restore offset address
MOV SI,SEG_ADDR ; restore segment
MOV DS,SI
MOV SI,AX ; DS:SI now points to requested byte
MOV [SI],BL ; poke it
MOV AX,1 ; Return .T. for successful poke
JMP SHORT POKEBYTE_EXIT ; and we're done
POKEBYTE_ERR:
MOV AX,0 ; return .F. for error condition
POKEBYTE_EXIT:
POP SI
POP DX
POP BX
POP ES
POP DS
POP BP
RET_LOGICAL AX ; return .T. or .F. to caller
RET
POKEBYTE ENDP
;------------------------------------------------
POKEBYTE_TEXT ENDS
;************************************************
END