16-bit Assembler multi-file Intel Assembler compiler masm5.0 calling a subroutine library that is a static library of custom functions WINDOWS

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.