flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > Compile for DOS on Windows?

Author
Thread Post new topic Reply to topic
cld



Joined: 14 Oct 2016
Posts: 4
Location: NYC
Compile for DOS on Windows?
Hi, I'm running fasm for 32-bit Windows latest version (running in 64-bit Windows). My question is, can I create DOS programs (.COM files) in this environment?

Sorry for the elementary question. I am new to fasm and just started learning assembly language. Tried to search for the answer first, but.... Crying or Very sad

_________________
cld -- rank amateur
Post 14 Oct 2016, 01:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14673
Location: Origae-6
Yes you can assemble .com files. But you can't test DOS programs in 64-bit Windows natively. You'll need an emulator or VM to run the resulting DOS code.
Post 14 Oct 2016, 01:50
View user's profile Send private message Visit poster's website Reply with quote
cld



Joined: 14 Oct 2016
Posts: 4
Location: NYC
Thanks for the info. Yes, I understand I'll need a DOS environment in order to run the DOS code.
Post 14 Oct 2016, 04:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14673
Location: Origae-6
The multiseg.asm example file shows some basic syntax for DOS .exe files:

Code:

; fasm example of writing multi-segment EXE program

format MZ

entry main:start                        ; program entry point
stack 100h                              ; stack size

segment main                            ; main program segment

  start:
        mov     ax,text
        mov     ds,ax

        mov     dx,hello
        call    extra:write_text

        mov     ax,4C00h
        int     21h

segment text

  hello db 'Hello world!',24h

segment extra

  write_text:
        mov     ah,9
        int     21h
        retf

And the comdemo.asm file shows .com code:

Code:

; fasm example of writing 16-bit COM program

        org     100h                    ; code starts at offset 100h
        use16                           ; use 16-bit code

display_text = 9

        mov     ah,display_text
        mov     dx,hello
        int     21h

        int     20h

hello db 'Hello world!',24h

Post 14 Oct 2016, 04:30
View user's profile Send private message Visit poster's website Reply with quote
cld



Joined: 14 Oct 2016
Posts: 4
Location: NYC
revolution, thanks. I will study these examples. Last night I assembled my first little program, to print all 256 Ascii chars to the screen. Very Happy


Code:

        use16
        org 100h

;       mov cx,ffh      ; put 255 in reg CX [counter] <== next line fixes this
        mov cx,100h     ; put 256 in reg CX [counter]
        mov dl,0        ; put 0 in DL
prints:
        mov ah,2        ; print char to screen
        int 21h         ; execute
        inc dl          ; increment DL
        loop prints     ; loop back
;finish
        mov dl,0ah      ; put line feed in DL
        mov ah,2        ; print it to screen
        int 21h         ; execute
        int 20h         ; exit



_________________
cld -- rank amateur


Last edited by cld on 15 Oct 2016, 20:23; edited 1 time in total
Post 15 Oct 2016, 04:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14673
Location: Origae-6

cld wrote:
... print all 256 Ascii chars to the screen.

Code:
        mov cx,ffh      ; put 255 in reg CX [counter]


Oops, looks like you missed the last one. Wink
Post 15 Oct 2016, 04:54
View user's profile Send private message Visit poster's website Reply with quote
cld



Joined: 14 Oct 2016
Posts: 4
Location: NYC
Pesky edge case! Fixed -- thanks!
Post 15 Oct 2016, 20:24
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.