TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: ROBERT HORNE
from: DENIS BOYLES
date: 1997-05-01 15:01:00
subject: External Programs

 RH> Hi all!  Can somebody tell me how to execute external
 RH> programs, such as EXE or COM files in assembler?  I have a
 Hi Robert,
 Perhaps studying my own little test program might help you. It assembles
 into a COM program and then EXECs DOS' CHKDSK program.
;--------------------------------------------------------------------------
;-=[EXEC.ASM]=- Public Domain (pd) 1997 by Denis Boyles
;             ! Arrowsoft Assembler (MASM v3.0) / VAL Linker (as .COM file)
;             ? A test program using DOS's EXEC function.
PRG SEGMENT
    ASSUME CS:PRG,DS:PRG
    ORG 0100h
START:
    jmp     short main
program     db "C:\DOS\CHKDSK.EXE",0   ;complete path/program to exec
table       dw 0,80h,0,-1,-1,-1,-1     ;exec table,def env,use our command
main PROC
    mov     SP,100h                    ;move stack pointer for safety to PSP?
    mov     BX,offset snip             ;calculate the size of our code
    shr     BX,1                       ;in paragraphs so we can...
    shr     BX,1
    shr     BX,1
    shr     BX,1
    inc     BX
    mov     AH,4Ah                     ;DOS - resize memory segment
    int     21h                        ;...call DOS to resize memory
    mov     word [table][2],ES         ;store the PSP segment into table
    mov     AX,4B00h                   ;DOS - exec program (load/return-0)
    mov     BX,offset table            ;ES:BX -> exec table
    mov     DX,offset program          ;DS:DX -> program to exec
    int     21h                        ;call DOS to execute program
    mov     AH,4Dh                     ;DOS - get returning errorlevel
    int     21h                        ;call DOS to get code into AL
    
    mov     AH,4Ch                     ;DOS - terminate program with code
    int     21h                        ;call DOS to end with code AL
main ENDP
snip LABEL byte                        ;label point for the end of our code
PRG ENDS
    END main
;--------------------------------------------------------------------------
 Cheers,
   Denis Boyles
___ Blue Wave/QWK v2.12
--- Maximus/2 3.01
---------------
* Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.