Solved

Exec & parameter in ASM

Posted on 1997-10-26
4
332 Views
Last Modified: 2013-11-22
Do you know how to execute a program and to access to the programmer parameters from an ASM program?
0
Comment
Question by:kilobug
  • 2
4 Comments
 
LVL 10

Expert Comment

by:rbr
ID: 1216358
To get the paramters use int 21h function 62h. The returnvalue in BX is the
segment adress of the PSP of the current program. At the adress BX:0080
are the number of bytes of your parameter block and starting at BX:0081
you can read the parameters of your program.
0
 

Author Comment

by:kilobug
ID: 1216359
Thanx anyway, but this is only a part of the question...

  I will explain what I exactly want:
* To make a DOS ASM program which can execute other programs (EXE and COM).
* To make a DOS ASM program which can access to the parameter given on the command line.(This is easier, the main thing is the execution).
0
 
LVL 10

Accepted Solution

by:
rbr earned 200 total points
ID: 1216360
For executing a other program use int 21h function 4bh subfunction 0

AH=4bh
AL=00h
ES=segmentadress of parameterblock
BX=offsetadress of parameterblock
DS=segmentadress of the programname you want to execute
DX=offsetadress of the programname

The parameterblock must contain the following.
Byte 0-1: Segment of enviromentblock
Byte 2-3: Offset of command-parameters
Byte 4-5: Segment of command-parameters
Byte 6-7: Offset of 1st FCB
Byte 8-9: Segment of 1st FCB
Byte 10-11: Offset of 2nd FCB
Byte 12-13; Segment of 2nd FCB.
If Byte 0-1 are 0 the enviroment block of the calling program is used.
If you don't need any FCB Byte 6-13 can have any value you want.
The programname must be a string with a 0 at the and. No wildchars are
allowed. The command-paramters must have the following form.
Byte 0: Length of the command-paramters.
Byte 1-Length: command-paramters.
Bate Length+1: Carriage Return (ASCII 13). Do not cont this character to
the length.
0
 

Expert Comment

by:Thefly
ID: 1216361
Here is my solution to copy command line option string (from PSP to a PSP buffer var)

dosseg
.model large
.stack 200h
.data
;psp
psp dw 0
pspbuffer db 128 dup (0)
.386
.code
        push es
        mov ax,@data
        mov ds,ax
        pop es
        mov ax,es
        mov psp,ax
        mov bp,80h
        mov cx,es:[bp]
        mov ch,0
        inc cx
        psploop:
        mov bx,bp
        sub bx,80h
        mov ax,es:[bp]
        mov pspbuffer+bx,al
        inc bp
        loop psploop
        mov ax,4c00h
        int 21h
end

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question