BB> Hello Glen,
BB> GM> Since a COM program runs in 64k it's pretty safe to deallocate all
BB> GM> but 0fffh pages above the PSP:0000h.
BB> May I please bother you for an example proc?
Not a problem, here's a quick and dirty sample from a program I wrote
to trap another problem. It was a COM program and I deallocated the
exact same way. It was a quick write at the time and not too clean...
(I wasn't looking for an award anyways)
resize_block:
push cs ;get current segment
pop es ;make sure es is correct
mov bx, 0fff ;set to 64k in paragraphs
mov ah, 04a ;set resize block
int 021 ;do it...
jnc z2 ;skip if bad
mov ax, 04cff ;exit errorlevel 255
int 021 ;you go dos!
z2: ;label if resize good
ret
I assume you want to resize to run another program...
Here's how...
setup data like this...
command db "C:\YOURPATH\YOURPROG.EXE",00
;path and program your doing
;even exe if it's small enough
exec_block dw 00 ;contents of shell data block
cmd_offset dw 00
cmd_tail_offset dw 00
cmd_tail_segment dw 00
fcb1_offset dw 00
fcb1_segment dw 00
fcb2_offset dw 00
fcb2_segment dw 00
fcb1 db 00
db 11 dup 020
db 25 dup 00
fcb2 db 00
db 11 dup 020
db 25 dup 00
dw 3 dup 00 ;end of block
old_sp dw 00 ;a save area for stack pointer
then the code somewhere....
;now try exec
;first build exec param block
push cs ;save segment
pop ax ;into ax
mov cmd_tail_segment, ax ;load segments
mov fcb1_segment, ax
mov fcb2_segment, ax
mov ax, 0080 ;point to a command tail buffer
mov cmd_tail_offset, ax
mov ax, offset fcb1 ;point to buffers
mov fcb1_offset, ax
mov ax, offset fcb2
mov fcb2_offset, ax ;done
;now lets setup dos
push cs ;put in stack
pop es ;set value there
mov bx, offset exec_block ;point to block
mov dx, offset command ;point to command
mov ax, sp ;get stack pointer
mov old_sp, ax ;save that
mov ax, 04b00 ;set ah and al
int 021 ;shell O shell...
mov ax, cs ;segment will be ok
mov ss, ax ;reset other segments
mov ds, ax
mov es, ax
mov ax, old_sp ;get stack pointer
mov sp, ax ;restore stack
This isn't the cleanest exec either, another quick and dirty for a COM
program. I reused the PSP's command tail buffer for the EXEC.
You could make a seperate one at the end of the exec_block
Glen...
--- ProBoard v2.16 [Reg]
---------------
* Origin: NC/NEC SEWAnet, Bucolic Fair (1:3407/25)
|