home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
dosfunc.asm
< prev
next >
Wrap
Assembly Source File
|
1990-10-21
|
7KB
|
258 lines
; DOSFUNC.ASM
;
; by Ralph Davis
; modified by Rick Spence
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC DOSFUNC
EXTRN __TR_HTOI:FAR ; Library C function (hex-to-integer)
EXTRN __TR_ITOD:FAR ; Library C function (integer-to-double)
EXTRN __TR_HEXASM:FAR ; Produces hex string
PARMS_IN STRUC
BP_OLD DW ?
RET_ADDR DD ?
IN_PARM DD ?
FLAG_PARM DD ?
PARMS_IN ENDS
;****************************************
DOSFUNC_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:DOSFUNC_TEXT
;----------------------------------------
DOSFUNC PROC FAR ; DOS INT 21H interface
JMP SHORT GO
PCOUNT DW 0 ; Counts parameters passed
SAVE_COUNT DW 8 ; Saves count
THIS_PARM DB 4 DUP (?),0 ; Holds current parameter
; Register values passed
AX_IN DW ?
BX_IN DW ?
CX_IN DW ?
DX_IN DW ?
SI_IN DW ?
DI_IN DW ?
DS_IN DW ?
ES_IN DW ?
; Register return values
AX_OUT DW ?
BX_OUT DW ?
CX_OUT DW ?
DX_OUT DW ?
SI_OUT DW ?
DI_OUT DW ?
DS_OUT DW ?
ES_OUT DW ?
; Parameter pointer table
PARM1_PTR DW ?
DW ?
PARM2_PTR DW ?
DW ?
PARM3_PTR DW ?
DW ?
PARM4_PTR DW ?
DW ?
PARM5_PTR DW ?
DW ?
PARM6_PTR DW ?
DW ?
PARM7_PTR DW ?
DW ?
PARM8_PTR DW ?
DW ?
REG_AX DW PARM1 ; Jump table
REG_BX DW PARM2
REG_CX DW PARM3
REG_DX DW PARM4
REG_SI DW PARM5
REG_DI DW PARM6
REG_DS DW PARM7
REG_ES DW PARM8
GO: PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
CLD
XOR AX,AX
MOV CS:PCOUNT,AX ; Initialize parameter counter to 0
MOV CX,16 ; Initialize parameter pointer table
PUSH CS ; (all zeroes)
POP ES
MOV DI,OFFSET CS:PARM1_PTR
REP STOSW
GET_PARM: LDS SI,[BP].IN_PARM
MOV DI,OFFSET CS:THIS_PARM
CALL CONV_PARM ; CONV_PARM adds 4 to SI
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
CALL CONV_PARM
INC CS:PCOUNT
INT 21H
PUSHF
MOV CS:ES_OUT,ES
MOV CS:DS_OUT,DS
MOV CS:DI_OUT,DI
MOV CS:SI_OUT,SI
MOV CS:DX_OUT,DX
MOV CS:CX_OUT,CX
MOV CS:BX_OUT,BX
MOV CS:AX_OUT,AX
MOV CX,CS:SAVE_COUNT
RET_PARM: MOV SI,CX
DEC SI
SHL SI,1
XOR AX,AX
PUSH AX
PUSH CS:[AX_OUT][SI]
CALL __TR_HEXASM
ADD SP,4
SHL SI,1
MOV ES,CS:[PARM1_PTR][SI+2] ; Destination string pointer
MOV DI,CS:[PARM1_PTR][SI]
MOV DS,DX ; Source string pointer
MOV SI,AX
PUSH CX
MOV CX,4
REP MOVSB
POP CX
LOOP RET_PARM
JMP SHORT EXIT
ERROR_EXIT:
STC ; DOS uses Carry flag for error signal
EXIT: LDS SI,[BP].FLAG_PARM
POPF
PUSHF
POP AX
MOV [SI],AX
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
POP ES
POP DS
POP BP
RET
DOSFUNC ENDP
;----------------------------------------------------
CONV_PARM PROC NEAR
MOV BX,CS:PCOUNT
PUSH BX
SHL BX,1
SHL BX,1
MOV CS:PARM1_PTR[BX],SI
MOV CS:PARM1_PTR[BX+2],DS
PUSH CX
MOV CX,4
; DS:SI points to instring--ES:DI points to THIS_PARM
REP MOVSB
SUB DI,4
PUSH DX
PUSH SI ; at this point, SI points to next parm
PUSH ES ; pass location
PUSH DI
CALL __TR_HTOI ; AX now holds integer value
POP DI
POP ES
POP SI
POP DX
POP CX
POP BX ; Retrieve PCOUNT
SHL BX,1 ; PCOUNT becomes offset into
; jump table
CALL CS:[REG_AX][BX]
RET
CONV_PARM ENDP
;--------------------------------------------
PARM1 PROC NEAR
MOV CS:AX_IN,AX
RET
PARM1 ENDP
;----------------------------------------------------
PARM2 PROC NEAR
MOV CS:BX_IN,AX
RET
PARM2 ENDP
;----------------------------------------------------
PARM3 PROC NEAR
MOV CS:CX_IN,AX
RET
PARM3 ENDP
;----------------------------------------------------
PARM4 PROC NEAR
MOV CS:DX_IN,AX
RET
PARM4 ENDP
;----------------------------------------------------
PARM5 PROC NEAR
MOV CS:SI_IN,AX
RET
PARM5 ENDP
;----------------------------------------------------
PARM6 PROC NEAR
MOV CS:DI_IN,AX
RET
PARM6 ENDP
;----------------------------------------------------
PARM7 PROC NEAR
MOV CS:DS_IN,AX
RET
PARM7 ENDP
;----------------------------------------------------
PARM8 PROC NEAR
MOV BX,CS:BX_IN
MOV CX,CS:CX_IN
MOV DX,CS:DX_IN
MOV SI,CS:SI_IN
MOV DI,CS:DI_IN
CMP CS:DS_IN,0
JE PARM8_ES
PARM8_DS: MOV DS,CS:DS_IN
PARM8_ES: CMP AX,0
JE PARM8_RET
MOV ES,AX
PARM8_RET: MOV AX,AX_IN
RET
PARM8 ENDP
;----------------------------------------------------
DOSFUNC_TEXT ENDS
;****************************************************
END