Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile multiple files together with ml in assembly x86?

I'm working in x86 assembly in 16bits. I have three files that need to share 'variables between them' - basically, the data segment. When I compile them, as in the following:

ml file1.asm,file2.asm,file3.asm io.lib

They cannot access each other's variables How do I share a data segment, and thus variables between the files? Thank you!

like image 951
Yuval Karmi Avatar asked Dec 16 '25 14:12

Yuval Karmi


1 Answers

Just about like in C, you create a header (usually given the extension ".inc") that contains external declarations for what's contained in another file, as in:

;file def_data.asm:
.586P
.model flat, c

.data
     myword dd ?

end 

; file def_data.inc:
externdef myword:dword

; file use_data.asm:
.586P
.model flat, c

include def_data.inc

.code
myproc proc
    mov eax, myword
myproc endp
    end
like image 58
Jerry Coffin Avatar answered Dec 19 '25 06:12

Jerry Coffin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!