flat assembler
Message board for the users of flat assembler.

Index > Main > beginner in fasm and assembly

Author
Thread Post new topic Reply to topic
s0s0s



Joined: 20 Apr 2013
Posts: 3
s0s0s 20 Apr 2013, 20:43
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: 1178
Location: Unknown
HaHaAnonymous 21 Apr 2013, 00:53
[ Post removed by author. ]


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: 1708
Location: Toronto, Canada
AsmGuru62 21 Apr 2013, 12:27
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
s0s0s 21 Apr 2013, 16:20
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: 1708
Location: Toronto, Canada
AsmGuru62 21 Apr 2013, 16:45
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
s0s0s 21 Apr 2013, 17:06
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: 1178
Location: Unknown
HaHaAnonymous 21 Apr 2013, 18:30
[ Post removed by author. ]


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: 204
ACP 21 Apr 2013, 22:18
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: 1708
Location: Toronto, Canada
AsmGuru62 22 Apr 2013, 14:56
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


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.