flat assembler
Message board for the users of flat assembler.
Index
> DOS > run an executable file from my asm code |
Author |
|
LocoDelAssembly 14 May 2008, 22:41
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.
|
|||
14 May 2008, 22:41 |
|
sinsi 15 May 2008, 00:45
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 |
|||
15 May 2008, 00:45 |
|
rCX 15 May 2008, 21:29
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 EDIT: See next post and other fixes Last edited by rCX on 16 May 2008, 13:55; edited 2 times in total |
|||
15 May 2008, 21:29 |
|
DJ Mauretto 16 May 2008, 09:28
Quote:
Did you mean: Code: mov ax,4c00h int 21h |
|||
16 May 2008, 09:28 |
|
rCX 16 May 2008, 13:51
DJ Mauretto wrote:
Oh, thats why it was not working. I'll change it. |
|||
16 May 2008, 13:51 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.