flat assembler
Message board for the users of flat assembler.

Index > DOS > run an executable file from my asm code

Author
Thread Post new topic Reply to topic
arthur



Joined: 06 Apr 2008
Posts: 2
arthur
good morning every body i have a probleme in want to run an executable file from my asm code this is my code it compil very well with but when i run my programme a bug occur :

filename db "E:\emu8086\MyBuild\conver.exe"

mov al,00h
mov edx,filename
mov ah,4bh
int 21h

what is the cause of the bug? help me please,tank you.

_________________
basculo
Post 14 May 2008, 19:57
View user's profile Send private message ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quick guess: Perhaps you forgot to release your memory? Tomasz posted long time ago the steps to correctly execute an external program, try searching. If you found it please post the link here for future reference.
Post 14 May 2008, 22:41
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
Don't forget that ES:BX needs to point to an EXEC parameter block.
Code:
Format of EXEC parameter block for AL=00h,01h,04h:
Offset       Size    Description     (Table 01590)
 00h   WORD    segment of environment to copy for child process (copy caller's
                  environment if 0000h)
 02h     DWORD   pointer to command tail to be copied into child's PSP
 06h  DWORD   pointer to first FCB to be copied into child's PSP
 0Ah     DWORD   pointer to second FCB to be copied into child's PSP
 0Eh    DWORD   (AL=01h) will hold subprogram's initial SS:SP on return
 12h    DWORD   (AL=01h) will hold entry point (CS:IP) on return
    
Post 15 May 2008, 00:45
View user's profile Send private message Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
You might want to move "filename" to the end of the program so that the instructions are first.

An easier way to do this is to execute the program as if you were entering it into the command prompt. For example the following program performs the "dir" command in dos when it is assembled. This program basically frees up memory and then executes the command:

Code:
format binary
use16
org 100h

        ;First we have to free memory for the program or command we will use.
               push cs         ;\es = cs; to free memory in the segment we are currently using
            pop es          ;/
          mov ah,49h      ;\Free memory in segment es which is our segement
          int 21h         ;/

      ;Then we have to execute the command
                push cs         ;\ds = cs; Because path is in cs
           pop ds          ;/
          mov si,Path     ;si = offset of Path
                int 2Eh         ;execute dos command at ds:si

               mov ax,4C00h    ;\End our program
          int 21h         ;/

Path: db 3,"dir",0Dh            ;First number is length of string.  In this case "dir" is 3 bytes long. 
                          ;0Dh is the character for the enter key it always has to be there.

    




In your case you would have to change the last line as follows:

Code:
format binary
use16
org 100h

  ;First we have to free memory for the program or command we will use.
               push cs         ;\es = cs; to free memory in the segment we are currently using
            pop es          ;/
          mov ah,49h      ;\Free memory in segment es which is our segement
          int 21h         ;/

      ;Then we have to execute the command
                push cs         ;\ds = cs; Because path is in cs
           pop ds          ;/
          mov si,Path     ;si = offset of Path
                int 2Eh         ;execute dos command at ds:si

               mov ax,4C00h    ;\End our program
          int 21h         ;/

Path: db 29,"E:\emu8086\MyBuild\conver.exe",0Dh          ;First number is length of string.  In this case "E:\emu8086\MyBuild\conver.exe" is 29 bytes long. 
                                                        ;0Dh is the character for the enter key it always has to be there.
    


For more information...
http://lrs.uni-passau.de/support/doc/interrupt-57/RB-2860.HTM
http://lrs.uni-passau.de/support/doc/interrupt-57/RB-4170.HTM

This method does not work perfectly but I hope this helps!

rCX Cool

EDIT: See next post and other fixes


Last edited by rCX on 16 May 2008, 13:55; edited 2 times in total
Post 15 May 2008, 21:29
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Quote:
Code:
                mov ax,4Ch      ;\End our program
                int 21h         ;/     


Did you mean:
Code:
mov ax,4c00h
int 21h    
Wink
Post 16 May 2008, 09:28
View user's profile Send private message Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
DJ Mauretto wrote:

Did you mean:
Code:
mov ax,4c00h
int 21h    
Wink


Oh, thats why it was not working. Shocked I'll change it.
Post 16 May 2008, 13:51
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.