«« ( Date ) »» // «« ( Thread ) »» // mips-nastava - 2004

Re: asembler i exe

by Bojan
sreda, 28. januar 2004 - 04:50.

The Art of Assembly Language

The "load and execute" call requires two parameters. The first, in ds:dx, is a pointer to a zero terminated string containing the pathname of the program to execute. This must be a ".COM" or ".EXE" file and the string must contain the program name's extension. The second parameter, in

es:bx, is a pointer to a LOADEXEC data structure. This data structure takes the following form:

LOADEXEC struct

EnvPtr word ? ;Pointer to environment area

CmdLinePtr dword ? ;Pointer to command line

FCB1 dword ? ;Pointer to default FCB1

FCB2 dword ? ;Pointer to default FCB2

LOADEXEC ends

Envptr is the segment address of the DOS environment block created for the new application. If

this field contains a zero, DOS creates a copy of the current process' environment block for the child process.If the program you are running does not access the environment block, you can save several hundred bytes to a few kilobytes by pointing the environment pointer field to a string of four zeros.

The CmdLinePtr field contains the address of the command line to supply to the program. DOS

will copy this command line to offset 80h in the new PSP it creates for the child process. A valid command line consists of a byte containing a character count, a least one space, any character belonging to the command line, and a terminating carriage return character (0Dh). The first byte should contain the length of the ASCII characters in the command line, not including the carriage return. If this byte contains zero, then the second byte of the command line should be the carriage return, not a space. Example:MyCmdLine byte 12, " file1 file2",cr

The FCB1 and FCB2 fields need to point at the two default file control blocksfor this program.

FCBs became obsolete with DOS 2.0, but Microsoft has kept FCBs around for compatibility anyway. For most programs you can point both of these fields at the following string of bytes:

DfltFCB byte 3," ",0,0,0,0,0

The load and execute call will fail if there is insufficient memory to load the child process. When you

create an ".EXE" file using MASM, it creates an executable file that grabs all available memory, by default.Therefore, there will be no memory available for the child process and DOS will always return an error.Therefore, you must readjust the memory allocation for the parent process before attempting to run the child process. The section "Semiresident Programs" on page 1055 describes how to do this.

----- Original Message -----

From: Vladimir Skrbic
To: mips-nastava@titan.etf.bg.ac.yu
Sent: Saturday, January 24, 2004 10:15 PM
Subject: [mips-nastava] asembler i exe


Jel zna neko kako se iz asemblera moze izvrsiti neki exe program?

U nekom helpu sam nasao ovo:

mov ah,4bh
xor al,al
lea dx,ImeFajla
int 21h

ali nista se ne desava, niti prijavljuje gresku. Da li mozda treba jos neki parametri da se postave?

Hvala unapred.


Pozdrav,
Skrba