This is the past DOS era of the compilation of source code, although has passed, but for the study of the assembly is still helpful, assembly language is just a basic programmer language, most people can grasp, not necessarily in-depth research.
; Frespace. ASM 10/04/84 GWF
;
;
;
; Call Frespace (AH,AL,BH,BL,CH,CL). CL SHOULD is 0 for default
; Drive 1 for A, 2 for B, 3 for C, etc. The value of the
; The other variables does is not matter. They'll come back
; With a meaningful value.
;
; An EXAMPLE program:
;
; Ten DefInt A-Z
; Color 7,1:cls
; test1=1:ah=0:al=0:bh=0:ch=0:cl=1:test2=2
; INPUT "DRIVE 0=default, 1=a, 2=b, 3=c"; Cl
; Notoginseng PRINT "JUST before call"
; Call Frespace (AH,AL,BH,BL,CH,CL)
; PRINT "JUST after call"
; PRINT "ah="; AH; " Al= "; Al; " Bh= "; BH; " Bl= "; BL; " Ch= "; CH; " Cl= "; CL;
; Ufree!=256*ah+al
; Ubytes!=256*bh+bl
; Usector!=256*ch+cl
; PRINT "ufree!="; ufree!; " Ubytes!= "; ubytes!; " Usector!= "; usector!
; MB frespace!=ufree!*ubytes!*usector!
; frespace!= PRINT ""; frespace!
; PRINT "This SHOULD to be 1", TEST1
; 130 PRINT "This SHOULD to be 2", TEST2
;
Get_spa equ 36h; Get disk free spaces function call
Doscall equ 21h;D os interrupt number
Dgroup Group Datarea
Datarea segment para public ' DATA '
Ah_ret DW? ; Ah to is sent back
Al_ret DW? ; Al to being sent back
Bh_ret DW? ; BH to is sent back
Bl_ret DW? ; BL to is sent back
Ch_ret DW? ; Ch to is sent back
Cl_ret DW? ; Cl to is sent back
Datarea ENDS
;
CSEG segment ' CODE '
Assume Cs:cseg
Public Frespace
frespace proc Far
Push BP; BP from BASIC
MOV bp,sp set base for Parm list
Push DS;D s from basic work area
Push es; es from basic work area
MOV ax,datarea; establish data addressability
MOV Ds,ax now DS are local data
Assume Ds:datarea
;
;
;
;
Push BP
Sub Ax,ax
mov si,ss:[bp+6]; get addr of parameter
mov al,es:[si]; get value of Parm
MOV dx,ax;d l contains the drive number on call
;d h'll be zero
mov Ah,get_spa; Get Space function number
int doscall; Call DOS
; Move the values into local work area to prepare to send back to basic
Xchg Dx,ax must have a word. Want to zero out DH.
Sub Ax,ax; Produce the Zero
Xchg Dx,ax; DX is now zero.
; DH is what we really want as zero.
MOV dl,ah; Want to send back a byte
MOV ah_ret,dx; Prepare to return AH
MOV dl,al; Want to send back a byte
MOV al_ret,dx; Prepare to return AL
MOV dl,bh; Want to send back a byte
MOV bh_ret,dx; Prepare to return BH
MOV dl,bl; Want to send back a byte
MOV bl_ret,dx; Prepare to return BL
MOV dl,ch; Want to send back a byte
MOV ch_ret,dx; Prepare to return CH
MOV dl,cl; Want to send back a byte
MOV cl_ret,dx; Prepare to return CL
; Go back
Pop bp; get back Basic ' s workspace
MOV Ax,cl_ret
MOV si,ss:[bp+6]
mov Es:[si],ax; return cl
MOV Ax,ch_ret
MOV Si,ss:[bp+8]
mov es:[si],ax; return ch
MOV Ax,bl_ret
MOV si,ss:[bp+10]
mov es:[si],ax; return bl
MOV Ax,bh_ret
MOV si,ss:[bp+12]
mov es:[si],ax; return BH
MOV Ax,al_ret
MOV si,ss:[bp+14]
mov Es:[si],ax; return al
MOV Ax,ah_ret
MOV si,ss:[bp+16]
MOV es:[si],ax; return AH
;
Pop es
Pop ds
Pop bp
RET to basic 6 parameters were sent
Frespace ENDP
;-----------------------------------------------------------------------
Cseg ends
End to Assembler