flat assembler
Message board for the users of flat assembler.

Index > Windows > Code compiles ".com" but won't execute

Author
Thread Post new topic Reply to topic
xHero



Joined: 11 Jun 2010
Posts: 7
xHero
I wrote a couple small programs from the tutorial I downloaded with FASM. They produce "com" files as I'm sure all of you know. But when I try to run the "com" files I get and error. Below is the code and the error. Thanks!

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h

mov [myMsg+1],'i'
mov ax,word [myMsg+5]
mov word [myMsg+2],ax

mov ah,9
mov dx,myMsg
int 21h
mov ax,4C00h
int 21h

myMsg db 'Hello!',24h


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        org 100h
        jmp displayMsg
        mov [myMsg+1],'i'
        mov ax,word [myMsg+5]
        mov word [myMsg+2],ax

displayMsg:
        mov ah,9
        mov dx,myMsg
        int 21h
        mov ax,4C00h
        int 21h

myMsg db 'Hello!',24h
    


Description:
Filesize: 34.53 KB
Viewed: 1801 Time(s)

screenshot.jpg


Post 11 Jun 2010, 19:30
View user's profile Send private message Send e-mail Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
There is no support for 16-bit programs (.com programs) in x64 windows systems; you have to use some DOS emulator.

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 11 Jun 2010, 19:34
View user's profile Send private message Reply with quote
xHero



Joined: 11 Jun 2010
Posts: 7
xHero
is that the only way to learn DOS programming on windows 7 is with a DOS emulator? I just downloaded DOSBox and mounted my DIR.

I typed the name of the "com" and still got no output

C:\>example.com

C:\>

What is exeryone else doing that has windows 7? I want to learn assembly badly but can't get passed this hello world crap because of this problem.
Post 11 Jun 2010, 19:57
View user's profile Send private message Send e-mail Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
You can learn 32/64 bit assembly without problems/emulators: http://flatassembler.net/fasmw16914.zip

There are many great examples inside, also here: http://flatassembler.net/examples.php

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 11 Jun 2010, 20:21
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
xHero wrote:
What is exeryone else doing that has windows 7? I want to learn assembly badly but can't get passed this hello world crap because of this problem.
I'm happy Windows 7 user and have no problem with this code:
Code:
org 100h 

mov [myMsg+1],'i' 
mov ax,word [myMsg+5] 
mov word [myMsg+2],ax 

mov ah,9 
mov dx,myMsg 
int 21h 
mov ax,4C00h 
int 21h 

myMsg db 'Hello!',24h     
Result of the 'example.com' execution you can see on the screenshot attached below:

Image
Post 11 Jun 2010, 20:24
View user's profile Send private message Visit poster's website Reply with quote
xHero



Joined: 11 Jun 2010
Posts: 7
xHero
Awesome my DOSBox is working great now. Thanks guys

Why did you link to the 1.69.14 version instead of the 1.68?

those examples are way to advanced for me... so i take it 16bit programming is DOS and 32/64bit programming is for windows apps?? So then it is probably pretty smart to sutdy/read/learn/practice 16bit programming before I move on right?

Can anyone recommend some decent tutorials to start with. I finished the PDF you download on this site that take you through ax and dx. Any other tutorial I find just starts with those too or start with

.model small
.data
msgs db "tst",0

.code
entrypoint start
start:

which from my understanding you don't need with 16bit progs. I'm aware of the other two general registers cx and bx but have yet to use them. Most programs I see use a lot of e**(ex. eax) registers. Any decent tutorials that starts with absolute basics and takes me through everything I need to know before attempting Win32 would be great!!!
Post 12 Jun 2010, 00:55
View user's profile Send private message Send e-mail Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
1.69.14 > 1.68 =D

16-bit (real mode) nowadays is used for OS developing.
32-bit (protected mode) is the most used currently and you can find more examples than any else.
64-bit (long mode) the x64 (not "itanium 64") is the present and future (yah DOS gaywads! Image) but new generations are just too lazy to spend time in low level programming that there are few examples around.

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 12 Jun 2010, 01:19
View user's profile Send private message Reply with quote
xHero



Joined: 11 Jun 2010
Posts: 7
xHero
So which should I start with to learn the basics and work my way up without leaving behind anything that's really important to learn. I'm having problems finding 32-bit tutorials. Examples are fine and dandy but I'm still very new and need some tuts to break things down and tell me about the registers and why/when to use them. I need to learn things like

cmp
jza (the other one for jmp not sure how it goes)

and many more... like I said I haven't found one tutorial that starts to cover the eax family of registers and I would like to cover all others before I get to that. Could you please point me in the right direction?

After a long time of learning/researching/practicing I would love to throw together my own OS to play with. Obviously this is going to be much further down the line.
Post 12 Jun 2010, 03:57
View user's profile Send private message Send e-mail Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Why do you think there are some sticked threads Image?

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 12 Jun 2010, 04:16
View user's profile Send private message Reply with quote
xHero



Joined: 11 Jun 2010
Posts: 7
xHero
I looked at them already. The Iczelions tutorials aren't formatted for FASM. the one that were converted for fasm is a none working link. the examples on the FASM site jump right into how to do different things. I can't find a single tutorial that will run through the basic. So far I have only learned what you see in my original post. I can't find anything that starts with 32 bit register EAX, EBX, ECX, EDX or push,pop,cmp or anything usefull. the only tutorials I can find use MASM, TASM and NASM and start with things like C drivers and crap. I can't find anything usefull at all!
Post 13 Jun 2010, 22:20
View user's profile Send private message Send e-mail Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Instruction are the same in 99% of assemblers, so no matter if you read tuts for masm, tasm, yasm, wtfasm, roflasm, etc.

Now the order of arguments in most assemblers is intel syntax, that is:

instruction destination, source
example:
Code:
add, eax, ecx ; eax = eax + ecx
    

some instructions could have only one operand (argument):
Code:
inc eax ; eax = eax + 1
    


ax, cx, dx, bx are 16-bit registers
eax, ecx, edx, ebx are 32-bit registers
rax, rcx, rdx, rbx are 64-bit registers

In 32-bit there are 8 general purpose registers (GPR).The prefix "e" stands for elephantine =D (no i think it stands for extended, but not sure).

eax acumulator
ecx counter
edx data
ebx base
esi source index
edi destination index
ebp base pointer
esp stack pointer

So what's different between assemblers?
Their directives. Directives are "tools" that every assembler give you to specify the way you want your code to be assembled.

In short you can learn fast and directly assembly in fasm if you are smart enough to figure out the diferences between masm and fasm directives.

Or you can learn first masm then switch to fasm.

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 14 Jun 2010, 00:45
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
How i am learning...
Download Intel x86 and FASM manuals.
Download some code at your level of experience.
Identify/Lookup each line of code for entire program.
Optional: Break program and learn to fix it.
Post 14 Jun 2010, 02:38
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.