flat assembler
Message board for the users of flat assembler.

Index > Main > My 8-Line program wont run!

Author
Thread Post new topic Reply to topic
quddusaliquddus



Joined: 18 May 2009
Posts: 3
quddusaliquddus
Quote:

DOSSEG
.MODEL SMALL
.STACK 200h
.DATA
.CODE
START:
INT 20
END START


Why?
Post 19 May 2009, 00:01
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2891
Location: [RSP+8*5]
bitRAKE
That isn't FASM syntax - looks like MASM?
Post 19 May 2009, 01:03
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17248
Location: In your JS exploiting you and your system
revolution
In fasm you can just do this:
Code:
int 0x20    
7 of those lines are MASM bloat.
Post 19 May 2009, 03:17
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Or maybe:
Code:
format MZ
stack $200

; int $20 ; Not int $20

mov ax, $4C00
int $21
    

Unless it is OK to generate a COM executable.

[edit]Code corrected according to Japheth's post below[/edit]


Last edited by LocoDelAssembly on 20 May 2009, 16:19; edited 1 time in total
Post 19 May 2009, 03:27
View user's profile Send private message Reply with quote
quddusaliquddus



Joined: 18 May 2009
Posts: 3
quddusaliquddus
Thanks for the replies.

Im new to all things assembly, and I am following an example of x86 assembly language code.

Are there big differences between different assembly compilers?
Post 19 May 2009, 03:35
View user's profile Send private message Reply with quote
quddusaliquddus



Joined: 18 May 2009
Posts: 3
quddusaliquddus
And also - how would I prevent the above-generated program from quitting so quickly?
Post 19 May 2009, 03:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17248
Location: In your JS exploiting you and your system
revolution
Have a look at the "examples" folder in the download zip file. Those files are already in fasm syntax.
Post 19 May 2009, 05:39
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
revolution wrote:
Have a look at the "examples" folder in the download zip file. Those files are already in fasm syntax.
To add to what revolution said: you don't have to understand the whole example! You only have to see the relevant parts (e.g the beginning) to get an idea Wink

_________________
Previously known as The_Grey_Beast
Post 20 May 2009, 00:50
View user's profile Send private message Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Japheth
LocoDelAssembly wrote:
Or maybe:
Code:
format MZ
stack $200

int $20
; Or:
; mov ax, $4C00
; int $21
    

Unless it is OK to generate a COM executable.


Actually, format MZ combined with INT $20 is a bug. Because to terminate a DOS program with INT 20h "requires" CS==PSP segment, which usually is true for .COM files only.
Post 20 May 2009, 10:21
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Corrected, thanks.
Post 20 May 2009, 16:19
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7713
Location: Kraków, Poland
Tomasz Grysztar
Japheth wrote:
Actually, format MZ combined with INT $20 is a bug. Because to terminate a DOS program with INT 20h "requires" CS==PSP segment, which usually is true for .COM files only.

Good that you added "usually", because you can get the same thing with MZ format, too:
Code:
format MZ

segment main
PSP = main - 10h
entry PSP:100h
org 100h

        mov     ah,9
        mov     dx,_hello
        int     21h

        int     20h

_hello db "Hello, guys!",24h    

Actually, this is the kind of "emulation" that fasm does when you specify binary .com file as a stub for PE executable.
Post 20 May 2009, 18:54
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
quddusaliquddus wrote:

My 8-Line program wont run!
Why?
And also - how would I prevent the above-generated program from quitting so quickly?


It seems to be MASM syntax and 7 of the 8 lines don't do anything, there is just 1 ( ONE ) instruction, as pointed above Smile

Also, numbers are decimal by default in FASM so your "INT 20" becomes INT $14 - serial port: http://www.ctyme.com/intr/int-14.htm

INT $20 would be a bad (see above) way to exit, the safest one (see also above) is:

Code:
  mov ax, $4C00
  int $21
    


To prevent from "quitting so quickly", you have to do something before you exit Wink

Also INT $21 is DOS only code, so for DOS examples check the DOS subforum, OTOH for Win32 forget INT $21 and check the Win32 subforum and included examples using format PE Idea
Post 21 May 2009, 13:41
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-2020, Tomasz Grysztar.

Powered by rwasa.