The following is a 16-bit assembly to create a static library and invoke a function in the static library
; multi-file assembly format
; The compilation method (used here is MASM 5.0, if it is another compiler, it may not compile)
; First, the method of compiling
; 1, MASM main.asm generate the. obj file
; 2, MASM lib.asm generate the. obj file
; 3, link main.obj lib.obj generate. exe file
; second, the method of compiling
; 1, MASM main.asm generate the. obj file
; 2, MASM 16lib.asm generate the. obj file
3. lib 16lib.lib 16lib.obj. lib files generated by. obj files, which are static library files that can be used as function libraries
; 4, link main.obj 16lib.lib. exe file generated by. obj. lib Two files
;=======================================
;(main.asm)
. Model Small
. Stack 100h
.386
. Data
MSG db "In my world! You know? ", 0
. Code
Extrn Int21h_40h:far; Refer to external functions, note: masm5.0 uses EXTRN, less an e character
Main PROC
mov ax, @data
MOV Ds,ax
Push di
MOV Di,offset MSG
Call int21h_40h
Pop di
MOV ax,4c00h
int 21h Main
Endp
END Main
;==================================
;(16lib.asm)
. Model Small
. stack. Data
. Code
public int21h_40h; Define external functions
; ********ms-dos Interrupt int 21h function call ***********************
;--------int 21h function number 40h case-------------
; Description: Display a string on standard output
; input parameters: di = string Address
; output parameter: None
int21h_40h proc Far
XOR cx,cx
MOV dx,di; Save the parameters before the loop, because the back loop will change the DI
Here is also the parameter of function 40h
L1:
; Calculate string length
CMP byte ptr[di],0
Je L2
Inc CX
Inc di
JMP L1
L2:
; Display string to standard output device
MOV ah,40h
MOV bx,1
int 21h
Ret
int21h_40h ENDP
End
16-bit Assembler multi-file Intel Assembler compiler masm5.0 calling a subroutine library that is a static library of custom functions WINDOWS