I do not understand, why the int21h/4Bh make this problems for MASM. I found a ASM code for FASM that seems to work. But with MASM it won't. The problem seems that in FASM INC files are in the standard embedded. I would like a simple and compact code for MASM.
My Goal: exec2 STARTAPP.COM/EXE Parameter1 Parameter2 ....
The START.COM/EXE start with: STARTAPP Parameter1 Parameter2 ...
Working asm code in FASM:
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 ```
I would like to convert this code to MASM with this:
; Assembling: masm exec2.asm
code segment
assume cs:code,ds:code
org 100h
start:
; 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 ; **< asm(14): error A2084: constant value too large**
int 21h
; now set up the pointer to command line in the parameters block
mov word [cmdline], offset command ; **< .asm(19): error A2009: syntax error in expression**
mov word [cmdline+2],ds ; **< .asm(20): error A2009: syntax error in expression**
; we are ready to execute the program now
mov ax,4B00h ; load and execute program
mov dx, offset 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
code ends
end start
END