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 > Main > beginner in fasm and assembly

Author
Thread Post new topic Reply to topic
s0s0s



Joined: 20 Apr 2013
Posts: 3
beginner in fasm and assembly
hi i'm beginner in fasm and assembly and when i try to run this code in the book i read for learning assembly error comes up for line: mov fldf,ax
org 100h

;-----------------------------------------------------
sstack:
dw 32 dup(0)
;-----------------------------------------------------

dataseg:

fldd dw 215
flde dw 125
fldf dw ?

;-----------------------------------------------------

main:

mov ax,dataseg
mov ds,ax
mov ax,fldd
add ax,flde
mov fldf,ax ;error error error
mov ax,4c00h
int 21h [/code]
Any help would be greatly appriciated for solve this problem .
thanks
Post 20 Apr 2013, 20:43
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1171
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 21:00; edited 1 time in total
Post 21 Apr 2013, 00:53
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1386
Location: Toronto, Canada
This will be proper COM program:

Code:

        org 100h
        use16
        ;
        ; COM Program begins here
        ;
        mov     ax, [ValueA]
        add     ax, [ValueB]
        mov     [Result], ax
        ;
        ; Return to MS-DOS
        ;
        int     20h
        ;
        ; COM Data (variables) begins here
        ;
        ValueA  dw 215
        ValueB  dw 125
        Result  dw ?



Notice that no need to set up any segments, since COM has only one
segment and loader will set all segment registers for you to that segment.

You got the result of A+B, but how are you going to display it?
Post 21 Apr 2013, 12:27
View user's profile Send private message Send e-mail Reply with quote
s0s0s



Joined: 20 Apr 2013
Posts: 3
thanks guys for you're guidance and consideration but this is exe file and that's the point because i don't know how to define stack , data and code segment in fasm and i think my book illustrate the code in masm 6.0.
Post 21 Apr 2013, 16:20
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1386
Location: Toronto, Canada
I see.
You can find the EXE code samples for DOS in a FASM package for DOS:

1. Multi-segmented DOS EXE file:

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




2. A simple DOS EXE:

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


Post 21 Apr 2013, 16:45
View user's profile Send private message Send e-mail Reply with quote
s0s0s



Joined: 20 Apr 2013
Posts: 3
mmmmmmmmm..... in my book say that we must exactly define
the stack , data , code segment for exe file . but in you're second example you didn't something like that, is this because of fasm feature
or the second example is .com file ?
Post 21 Apr 2013, 17:06
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1171
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 20:58; edited 1 time in total
Post 21 Apr 2013, 18:30
View user's profile Send private message Reply with quote
ACP



Joined: 23 Sep 2006
Posts: 197

AsmGuru62 wrote:
This will be proper COM program:

Code:


        ; Return to MS-DOS
        ;
        int     20h
        






Please note that int 20h is a legacy function and int 21h ah=4Ch should be used instead (just like in other examples). Obviously under plain MS-DOS it works but under some extended environments it might not.
Just my 2 cents...
Post 21 Apr 2013, 22:18
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1386
Location: Toronto, Canada
Good point ACP, thanks.
Post 22 Apr 2013, 14:56
View user's profile Send private message Send e-mail 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.