sseg segment stack
db 128 dup (0)
sseg ends
dseg segment para public 'global'
extrn parambuf:byte
extrn paramnr:word
configpath db 'config.txt',0 ; file name to be open
dseg ends
cseg segment para public 'code'
assume cs:cseg,ds:dseg,ss:sseg
public rdconfig
rdconfig proc near
push ds ; save caller's segment
push es
push bp ; make stack frame
mov bp,sp
mov ax,3d00h ; read only open file
mov dx,offset configpath
int 21h
jnc suc
; don't clear carry if error detected
mov sp,bp
pop bp ; restore stack frame
pop es
pop ds
ret ; leave error code in ax
suc:
mov bx,ax ;we will read the config file
xor ax,ax
mov ah,3fh
mov dx,offset parambuf
mov cx,1024
int 21h
jnc suc1
mov sp,bp
pop bp
pop es
pop ds
ret
suc1:
mov [paramnr],ax ; indicate how many byte we read from config file
clc ; guaratee no error
mov sp,bp
pop bp
pop es
pop ds
ret
rdconfig endp
cseg ends
end