简体   繁体   中英

How to prevent assembler compiling 16 bit applications?

I'm using the Flat Assembler on Windows 7 64 bit. I'm trying to compile a simple program, but it's compiling as a 16 bit program. Some programs seems to compile fine, but after searching for a while for a hello world example, the program doesn't run.

org 0x100

        mov  dx, msg      ; the address of or message in dx
        mov  ah, 9        ; ah=9 - "print string" sub-function
        int  0x21         ; call dos services

        mov  ah, 0x4c     ; "terminate program" sub-function
        int  0x21         ; call dos services
        msg  db 'Hello, World!', 0x0d, 0x0a, '$'

What should I do to prevent it from compiling as a 16 bit program?

You are making DOS COM file. It's apriory 16-bit 'cause DOS is real-mode OS. To get 32-bit executable you need to use PE - portable executable format - Windows executable format. You can find info about it in the Internet; FASM implementation of it - Win programming or PE format

But you can't simple take your program and make it 32-bit, 'cause you are using "int 0x21" - it's system call for DOS

The quoted source is DOS program (in .com file format) and as a such is properly compiled by FASM as DOS .com executable file.

In order to get 32bit program, well you have to write it first... I can't teach you to write 32bit programs - it is too long for answer format. But you can read the FASM programming manual (you got one in the downloaded FASM package) and check the examples provided.

Also helpful is to read the FASM message board there is a big amount of examples and helpful people.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM