Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DOS INT 21 Load/Exec question...

195 views
Skip to first unread message

wolf3y3

unread,
Nov 18, 2008, 7:08:34 PM11/18/08
to
I am wondering how to use AH=4Bh of the INT 21 DOS interrupt.
This function of the INT 21 interrupt, requires a parameter block.
I am wondering about the pointers to the File Control Blocks,
what are these FCB's used for,
and what are they loaded with?

Bruce M. Axtens

unread,
Nov 19, 2008, 3:14:39 AM11/19/08
to
You be best getting a hold of Ralf Brown's interrupt list
<http://www.ctyme.com/rbrown.htm>, probably
<http://www.ctyme.com/intr/rb-2939.htm>. FCBs are a hangover from CP/M
are were what we used to file I/O.

Kind regards,
Bruce.

bruce_axtens.vcf

Dirk Wolfgang Glomp

unread,
Nov 20, 2008, 2:45:49 AM11/20/08
to

Here is a masm-sample of a parameter block for load and execute(AL=00h).
(I place this block in the code segment.)
;---------------------------
PARBLOCK DW 0 ; same environment
DW OFFSET COMLINE ; offset/segment of the command line
DW SEG CODE
DD 0 ; no entry in PSP #1
DD 0 ; no entry in PSP #2
COMLINE DB 80h dup (0) ; command line
;---------------------------

RBIL->inter61b.zip->Interrup.g
--------D-214B-------------------------------
INT 21 - DOS 2+ - "EXEC" - LOAD AND/OR EXECUTE PROGRAM
AH = 4Bh
AL = type of load
...
Notes: DOS 2.x destroys all registers, including SS:SP.

; So we need a placeholder:
REGSS DW ?
REGSP DW ?

;-----------------------------------------------------------------
;-----------------------------------------------------------------

If the child want to use own command line parameter (that we can store
in the command tail above), than it is neccessary that the child found
the current PSP before.

RBIL->inter61b.zip->Interrup.h
--------D-2162-------------------------------
INT 21 - DOS 3.0+ - GET CURRENT PSP ADDRESS
AH = 62h
Return: BX = segment of PSP for current process
Notes: this function does not use any of the DOS-internal stacks
and may thus be called at any time, even during another
INT 21h call the current PSP is not necessarily the caller's
PSP identical to the undocumented AH=51h
SeeAlso: AH=50h,AH=51h
---------------------------------------------

Dirk

wolf3y3

unread,
Nov 20, 2008, 9:27:12 PM11/20/08
to
This code after calling function AH=4AH lock ups,
what is wrong?

jmp start
zfnam db 'bluedit.com',0
parblock dw 0
dw 80h
codebase dw 0
dd 0
dd 0
start:
mov ah,4ah ; Modify Allocated Memory
mov bx,4000 ; Allocate 4000 paragraphs
int 21h
int 3
mov ah,4bh
mov al,0
mov bx,offset parblock
mov dx,offset zfnam
mov [codebase],cs
int 21h
int 3
mov ax,4c00h
int 21h

Charles Crayne

unread,
Nov 21, 2008, 12:52:19 AM11/21/08
to
On Thu, 20 Nov 2008 18:27:12 -0800 (PST)
wolf3y3 <spam...@crayne.org> wrote:

> This code after calling function AH=4AH lock ups,
> what is wrong?

The basic problem is that DOS allocates all available memory to a .com
program, so you cannot allocate memory to run another program unless
you first free the unused storage above your program.

You should be checking the carry flag on return from the function call,
and, if it is set, report the error code and terminate the program.

--
Chuck
http://www.pacificsites.com/~ccrayne/charles.html

Dirk Wolfgang Glomp

unread,
Nov 21, 2008, 4:16:12 AM11/21/08
to
Am Thu, 20 Nov 2008 18:27:12 -0800 (PST) schrieb wolf3y3:

> This code after calling function AH=4AH lock ups,
> what is wrong?
>
> jmp start
> zfnam db 'bluedit.com',0

I think this parameter block need a word alignment.

> parblock dw 0
> dw 80h
> codebase dw 0

The command line of the caller?

> dd 0
> dd 0
> start:
> mov ah,4ah ; Modify Allocated Memory
> mov bx,4000 ; Allocate 4000 paragraphs
> int 21h

When a programm starts it allocate all memmory and so it is necessary
to free this non used memmory and give it back to DOS, before we can
allocate some memmory.

mov bx, ss
mov ax, es
sub bx, ax
mov ax, sp
add ax, 0Fh
shr ax, 4
add bx, ax
mov ah, 4Ah
int 21h

Now we can allocate memmory in paragraphs.

mov bx, 4000
mov ah, 48h
int 21h
jc ERROR

To start a child-programm we don´t need to allocate any mommory
and if the free memmory to small the child-programm can´t start.

> int 3

?

> mov ah,4bh
> mov al,0
> mov bx,offset parblock
> mov dx,offset zfnam
> mov [codebase],cs

The stack-register SS and SP of the caller will be loose.

mov [SSREG], ss
mov [SPREG], sp

> int 21h
> int 3
> mov ax,4c00h
> int 21h

mov ss, [SSREG]
mov sp, [SPREG]

Dirk

Dirk Wolfgang Glomp

unread,
Nov 21, 2008, 4:26:26 AM11/21/08
to
Am Thu, 20 Nov 2008 21:52:19 -0800 schrieb Charles Crayne:

> On Thu, 20 Nov 2008 18:27:12 -0800 (PST)
> wolf3y3 <spam...@crayne.org> wrote:
>
>> This code after calling function AH=4AH lock ups,
>> what is wrong?
>
> The basic problem is that DOS allocates all available memory to a .com
> program,

Also an .exe allocates all memory.

Dirk

Alexei A. Frounze

unread,
Nov 21, 2008, 7:04:41 AM11/21/08
to

I might've forgotten the details, but didn't a couple of fields in the
EXE file header prescribe the minimum and maximum memory requirements
of the program? DOS would allocate between the minimum and maximum if
possible. There could still be some free memory afterwards.

Alex

Patrick Klos

unread,
Nov 21, 2008, 9:44:35 AM11/21/08
to
In article <64a35da7-f196-4b12...@33g2000yqm.googlegroups.com>,

That's true. You can build an .EXE file that limits how much memory is
allocated when it's loaded. Some call these fields MIN_BSS and MAX_BSS.

========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
Patrick Klos Email: pat...@klos.com
Klos Technologies, Inc. Web: http://www.klos.com/
============================================================================

lavron

unread,
Nov 21, 2008, 10:30:20 AM11/21/08
to


Congratulation, Alex. Your memory is great - you remember well. The
minimum/maximum fields are there in the .EXE header.

Practically, in my opinion, the best way to handle this problem is to
specify the parameter /CP:1 to the linker, instructing it to release
all storage not necessary for the compiled code.

wolf3y3

unread,
Nov 21, 2008, 4:42:27 PM11/21/08
to
Thanks for the help!

jmp start
zfnam db 'bluedit.com',0

errorstr db 'Error...$'


parblock dw 0
dw 80h
codebase dw 0
dd 0
dd 0

ssreg dw 0
spreg dw 0

start:
mov bx,0
mov ah,4ah
int 21h

mov ah,48h ; Modify Allocated Memory
mov bx,8000 ; Allocate 8000 paragraphs
int 21h
int 3

mov [ssreg],ss
mov [spreg],sp

mov ah,4bh
mov al,0
mov bx,offset parblock
mov dx,offset zfnam
mov [codebase],cs
int 21h

jc exit_error
jmp exit_noerror
int 3

mov ss,[ssreg]
mov sp,[spreg]
exit_error:
mov ah,09h
mov dx,offset errorstr
int 21h
exit_noerror:
mov ax,4c00h
int 21h

Steve

unread,
Nov 22, 2008, 7:39:46 AM11/22/08
to
lavron <spam...@crayne.org> writes:
>
>Practically, in my opinion, the best way to handle this problem is to
>specify the parameter /CP:1 to the linker, instructing it to release
>all storage not necessary for the compiled code.

Note: Do not use CP:1 if you also use EXEPACK.

Steve N.

Dirk Wolfgang Glomp

unread,
Nov 23, 2008, 3:45:30 AM11/23/08
to

Do you have letter that describe those parameter and wich parameter
can be used in which version of link.exe?

I use masm.exe(5.00) in DOS or ML.exe(6.14.844) in Windows and
link the *.obj-files with link.exe(3.64 from masm version 5.00)
to build a 16bit executable.

Now i found a notice that i can also use the linker from MASM 6.11
to build a 16bit executable:
Ml611d.exe(include some packed files like this one)->Errmsg.txt:
"If you are building a 16-bit executable file, use the LINK.EXE
included with MASM 6.11...."

Dirk

Steve

unread,
Nov 23, 2008, 9:51:57 AM11/23/08
to

I have hard copy documentation for MASM versions 1 and 3.
I have a ZIP file from the Internet of DOC files for
MASM version 6.

Microsoft LINK from MASM later than 6.11 are only for
32 bit Windows programs.

Steve N.

From MASM 5.0.

Microsoft (R) Segmented-Executable Linker Version 5.15
Copyright (C) Microsoft Corp 1984-1991. All rights reserved.

Usage:

LINK
LINK @<response file>
LINK <objs>,<exefile>,<mapfile>,<libs>,<deffile>

Valid options are:
/? /ALIGNMENT
/BATCH /CODEVIEW
/CPARMAXALLOC /DOSSEG
/DSALLOCATE /EXEPACK
/FARCALLTRANSLATION /HELP
/HIGH /INCREMENTAL
/INFORMATION /LINENUMBERS
/MAP /NODEFAULTLIBRARYSEARCH
/NOEXTDICTIONARY /NOFARCALLTRANSLATION
/NOGROUPASSOCIATION /NOIGNORECASE
/NOLOGO /NONULLSDOSSEG
/NOPACKCODE /OVERLAYINTERRUPT
/PACKCODE /PACKDATA
/PADCODE /PADDATA
/PAUSE /PMTYPE
/QUICKLIBRARY /SEGMENTS
/STACK /TINY
/WARNFIXUP

Dirk Wolfgang Glomp

unread,
Nov 23, 2008, 1:42:48 PM11/23/08
to

> /? ...

Thanks.

Dirk

0 new messages