flat assembler
Message board for the users of flat assembler.

Index > DOS > How to execute an external program in ASM? Help please.....

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 19 Sep 2003, 21:33
Hi!! Just a small question... I have tried for a long time how to execute an external program in assembly language, but it's not working.
Please help me!!! How can I execute an external program using FASM ??
I think there are some options:
INT 2Eh
INT 21h - Function 4Bh
But I don't know how to... any helps are welcome!!
Sorry for the bad english (I'm from Brazil)
Question Question Question Question
Question Question Question Question
Post 19 Sep 2003, 21:33
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 19 Sep 2003, 21:49
Yeah, the function 4Bh may be a little hard to use for the beginner. Here's a little example:
Code:
        org     100h

; first, we need to free the conventional memory we don't use,
; so there will be some memory available for the program we want
; to run, if we used MZ format of executable, the directive
; "heap 0" would be enough for this purpose, in case of .com
; program we have to free that memory manually be resizing the
; memory block starting at our PSP (es is already set to it)

        mov     ah,4Ah                  ; resize memory block
        mov     bx,10010h shr 4         ; only memory needed for .com
        int     21h

; now set up the pointer to command line in the parameters block

        mov     word [cmdline],_command
        mov     word [cmdline+2],ds

; we are ready to execute the program now

        mov     ax,4B00h                ; load and execute program
        mov     dx,_program             ; ASCIIZ path of program
        mov     bx,params               ; parameter block
        int     21h

        int     20h                     ; exit program


_program db 'c:\command.com',0
_command db 0                           ; length of command line
         db 13                          ; must end with CR character

params:
 environment dw 0       ; segment of environment, 0 means to use parent's one
 cmdline dd ?           ; pointer to command line
 default_fcb1 dd 0      ; pointers to file control blocks
 default_fcb2 dd 0      
    
Post 19 Sep 2003, 21:49
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 19 Sep 2003, 21:58
Yeah!! That's hard to do... but that's what I was looking for, now I'll get to study Very Happy
Thanks a lot for the help!!!
Exclamation
Post 19 Sep 2003, 21:58
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1403
Location: Piraeus, Greece
Picnic 07 May 2007, 19:27
I was searching for this. Thanks for the script. This post was old, sorry Cool


-What do you want?
-Me?
-Yeah.
-Two days bed and board.
Vriess might want to snag|a part or two. I mean, if it's not imposing...


Aliens 4
Post 07 May 2007, 19:27
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 24 May 2007, 05:45
Isn't there some (old DOS?) bug that needs SS:SP to be saved first?
Post 24 May 2007, 05:45
View user's profile Send private message Visit poster's website Reply with quote
bttr



Joined: 21 Oct 2003
Posts: 16
Location: Berlin, Germany
bttr 24 May 2007, 13:38
Why do you guess? Just read http://www.ctyme.com/intr/rb-2939.htm
Post 24 May 2007, 13:38
View user's profile Send private message Visit poster's website 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.