flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > How to write a Hello World! Program in FASM?

Author
Thread Post new topic Reply to topic
zck127



Joined: 16 Jun 2004
Posts: 5
I am trying to write a simple "hello,world" executable program. When I type in the line

entry start

i get an illegal instruction error.

Could someone please submit a simple executable program that works?
Also, I don't understand why the above line of vode doesn'y work.

Thanx in advance for your help.
Post 21 Jun 2004, 04:43
View user's profile Send private message Reply with quote
VitalOne



Joined: 29 Jul 2003
Posts: 54
Location: USA
Code:
; fasm example of writing simple EXE program

format MZ

        push    cs
        pop     ds
        mov     ah,9
        mov     dx,hello
        int     21h

        mov     ax,4C00h
        int     21h

hello db 'Hello world!',24h   
    


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       
    
Post 21 Jun 2004, 05:53
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Why do u need to make the Data Segment equal to the Code Segment ?
Post 21 Jan 2006, 01:12
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 444
Location: BC, Canada
Quote:
How to write a Hello World! Program in FASM?

the fasm DOS package http://flatassembler.net/fasm165.zip
comes with many examples, including more than one hello world type

Slai wrote:
Why do u need to make the Data Segment equal to the Code Segment ?


in the multi-segment example above, the code and data are in different segments, but they do not have to be, just make the data segment register (ds) point to the segment with the data (also in the example above)

_________________
redghost.ca
Post 21 Jan 2006, 06:00
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Plue



Joined: 15 Dec 2005
Posts: 151
zck127 wrote:
I am trying to write a simple "hello,world" executable program. When I type in the line

entry start

i get an illegal instruction error.
Windows executables can have a set entry point. DOS executables simply starts at the start.

_________________
Roses are red
Violets are blue
Some poems rhyme
And some don't.
Post 21 Jan 2006, 21:09
View user's profile Send private message Reply with quote
nvictor



Joined: 17 Feb 2007
Posts: 31
RedGhost wrote:
in the multi-segment example above, the code and data are in different segments, but they do not have to be, just make the data segment register (ds) point to the segment with the data (also in the example above)


I presume the code segment is assumed by the assembler??
Post 18 Feb 2007, 17:48
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Quote:
I presume the code segment is assumed by the assembler??


It will generate one segment for you, as long as you remain below 64 KiB,
there is no problem, you can mix code with data as you want, and keep
the "entry point" at the begin where it comes by default.

"Code vs Data" problem comes from some other compilers and is not
present when using FASM Wink
Post 19 Feb 2007, 13:16
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


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.