Solved

Exec & parameter in ASM

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

16 Experts available now in Live!

Get 1:1 Help Now