Solved

Exec & parameter in ASM

Posted on 1997-10-26
4
313 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

862 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now