Mail Archives: djgpp/2008/01/17/15:45:50
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
From: | "Rod Pemberton" <do_not_have AT nohavenot DOT cmm>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: 32-bit version posted, demonstrates possible PMODE memory leak, was, gcc as a linker....
|
Date: | Thu, 17 Jan 2008 15:41:07 -0500
|
Organization: | Aioe.org NNTP Server
|
Lines: | 138
|
Message-ID: | <fmoecl$6ks$1@aioe.org>
|
References: | <478b3603$0$36444$4fafbaef AT reader5 DOT news DOT tin DOT it> <fmfik2$fvr$1 AT aioe DOT org> <fmidl0$kad$1 AT aioe DOT org>
|
NNTP-Posting-Host: | IVw7K97ih4IohxRqyKkqFw.user.aioe.org
|
Mime-Version: | 1.0
|
X-Complaints-To: | abuse AT aioe DOT org
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1441
|
X-Newsreader: | Microsoft Outlook Express 6.00.2800.1437
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
"Rod Pemberton" <do_not_have AT nohavenot DOT cmm> wrote in message
news:fmidl0$kad$1 AT aioe DOT org...
> "Rod Pemberton" <do_not_have AT nohavenot DOT cmm> wrote in message
> news:fmfik2$fvr$1 AT aioe DOT org...
> > The proper method is much longer in
> > assembly. I was hoping to find a shorter method. This would be useful
to
> > me, so I may get back to you on the 32-bit version.
>
> I've worked on a 32-bit version. If you understood the 16-bit version,
you
> wouldn't understand this...
>
> I wrote it in assembly the way I would've for DJGPP C and DPMI.
Okay, I've posted the 32-bit version below my signature.
> PMODEDJ, fails with "No memory to gather arguments" after a few runs.
Yes, I think there is a memory leak in PMODETSR.EXE somewhere...
Rod Pemberton
; nasm -f coff -o hello.obj hello.asm
; gcc -o hello.exe hello.obj
; PMODEDJ will generate an error after about sixteen executes
; stubedit hello.exe
; change CWSDPMI.EXE to PMODETSR.EXE
; execute until "No memory to gather arguments"
SECTION .data ; data section
msg: db "Hello World",13,10,'$' ; the string to print, 10=cr, 13=lf,
$=terminator
len equ $-msg
rm_call: ; DPMI real mode call structure
dd 00h ; EDI
dd 00h ; ESI
dd 00h ; EBP
dd 00h ; ESP (reserved)
dd 00h ; EBX
dd 00h ; EDX
dd 00h ; ECX
dd 00h ; EAX
dw 02h ; flags
dw 00h ; ES
dw 00h ; DS
dw 00h ; FS
dw 00h ; GS
dw 00h ; IP
dw 00h ; CS
dw 00h ; SP
dw 00h ; SS
tb_seg dd 0
tb_sel dd 0
rm_EDI equ rm_call+00h
rm_ESI equ rm_call+04h
rm_EBP equ rm_call+08h
rm_ESP equ rm_call+0Ch ; reserved
rm_EBX equ rm_call+10h
rm_EDX equ rm_call+14h
rm_ECX equ rm_call+18h
rm_EAX equ rm_call+1Ch
rm_flg equ rm_call+20h
rm_ES equ rm_call+22h
rm_DS equ rm_call+24h
rm_FS equ rm_call+26h
rm_GS equ rm_call+28h
rm_IP equ rm_call+2Ah
rm_CS equ rm_call+2Ch
rm_SP equ rm_call+2Eh
rm_SS equ rm_call+30h
SECTION .text ; code section
extern __go32_info_block
extern ___djgpp_ds_alias
global _main ; make label available to linker
_main: ; standard gcc entry point
; call DPMI - int 0x21, ax=0100h - allocate DOS memory
mov eax,0100h
mov ebx,((len+15)>>4) ; bx is length in paragraphs (16 bytes)
int 0x31 ; call DPMI function
movzx eax,ax ; zero upper part of eax
mov [tb_seg],eax ; save buffer segment
mov [tb_sel],edx ; save buffer selector
; copy msg to transfer buffer below 1Mb so DOS can access it
push es
mov esi,msg ; set esi to msg
mov edi, [tb_seg] ; set edi to __tb
shl edi,4
mov ecx,len ; set ecx to string length
push gs ; gs is ___djgpp_dos_sel
pop es ; set DOS segment to copy to
rep movsb ; copy string
pop es
; set values in real mode call structure for DPMI simulate int
mov eax, [tb_seg]
mov [rm_DS],ax ; set DS to __tb_segment (ax, not eax)
mov [rm_EAX],dword 0900h ; AH=09h write string command to int 21 hex
mov [rm_EDX],dword 0 ; set EDX to __tb_offset (0)
; call simulate int using DPMI - int 0x21, ah=09h - write string
mov eax,0x0300 ; DPMI Simulate Real Mode Interrupt function number
mov bl,0x21 ; interrupt to simulate, int 0x21
mov bh,0x00 ; no reset A20 and interrupt controller
movzx ebx,bx ; zero upper part of ebx
xor ecx,ecx ; no copy stack items
; "mov es,ds" ; selector of real mode call structure (done already)
mov edi, rm_call ; offset of real mode call structure
int 0x31 ; call DPMI function
%if 1
; call DPMI - int 0x21, ax=0101h - deallocate DOS memory
mov eax, 0101h
mov edx,[tb_sel]
int 0x31 ; call DPMI function
%endif
; exit via DPMI int 0x21 call
mov al,0 ; exit code, 0=normal
mov ah,4ch ; exit command to kernel
movzx eax,ax ; zero upper eax
int 0x21 ; interrupt 21 hex, call DPMI return
- Raw text -