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.
Cseg SEGMENT
Public Getspace
Getspace PROC FAR
Assume Cs:cseg
PUSH BP
MOV BP,SP
MOV bx,[bp]+6
MOV di,[bx]+2
MOV cx,8
MOV AL, '
CLD
REP STOSB
MOV bx,[bp]+8
MOV si,[bx]+2
MOV Ax,[si]
and AL,0DFH
CMP al,41h
Jge Ckver
JMP EXITSPC
Ckver:
PUSH AX
MOV ah,30h
INT 21H
Xchg Al,ah
SPACE20:
POP DX
XOR dl,40h
MOV ah,36h
INT 21H
CMP AX,0FFFFH
JE EXITSPC
XOR DX,DX
MUL CX
Xchg BX,CX
MUL CX
PUSH AX
PUSH DX
ENDSPC:
MOV bx,[bp]+6
MOV di,[bx]+2
ADD di,7
POP DX
POP AX
Hextodec:
MOV si,10
PUSH AX
MOV AX,DX
XOR DX,DX
DIV SI
POP CX
PUSH AX
MOV AX,CX
DIV SI
POP SI
OR dl,30h
MOV BYTE PTR [di],dl
DEC DI
Xchg Dx,si
OR Ax,ax
JNZ Hextodec
EXITSPC:
POP BP
RET 4
Ret
Getspace ENDP
Cseg ENDS
End