DPMI code from .COM file? (Developers)
> To narrow the question:
> In FASM distribution is a example file USEDPMI.ASM
> It prints a message "Hello from protected mode!"
> Here is the listing:
I edited your post to put the listing into BB-code [code]
tags.
> format MZ
> heap 0 ; no additional memory
>
> segment loader use16
Insert whatever is used by FASM for flat .COM files.
> push cs
> pop ds
This is probably fine.
> mov bx,si ; allocate memory for DPMI data
> mov ah,48h
> int 21h
> jc error
Before this you need to shrink the process's memory block because flat .COM files are always loaded with max alloc = FFFFh. Shrink it to 1000h paragraphs (64 KiB), or if you want to shrink it smaller insure that the stack is below that. Eg (for NASM, adjust to whatever FASM needs):
cpu 8086
org 256
startprogram:
[...]
cmp sp, stack_end
jb error
mov sp, stack_end
mov bx, ( (stack_end - startprogram) + 256 + 15 ) >> 4
mov ah, 4Ah
int 21h
jc error
[...]
align 2
endprogram:
stack_end: equ endprogram + 512
> mov ecx,main
> shl ecx,4
> mov dx,cx
> shr ecx,16
> mov ax,7 ; set descriptor base address
> int 31h
> mov bx,si
> int 31h
This needs to change. Easiest is putting the "main" or "start" label in the same segment as the .COM entrypoint. In that case replace the "mov ecx, main
" with:
mov cx, cs
movzx ecx, cx
If you want to keep using different segments then in NASM you'd need "section main vstart=0
" and load ecx with CS plus whatever is the size in paragraphs of the PSP plus the section "loader". Not sure how to do that in FASM.
---
l
Complete thread:
- DPMI code from .COM file? - Laaca, 11.05.2020, 13:37 (Developers)
- DPMI code from .COM file? - ecm, 11.05.2020, 14:42
- DPMI code from .COM file? - Laaca, 11.05.2020, 14:50
- DPMI code from .COM file? - ecm, 11.05.2020, 15:07
- DPMI code from .COM file? - ecm, 11.05.2020, 16:07
- DPMI code from .COM file? - Laaca, 11.05.2020, 22:44
- DPMI code from .COM file? - ecm, 11.05.2020, 23:05
- DPMI code from .COM file? - Laaca, 11.05.2020, 22:44
- DPMI code from .COM file? - Laaca, 11.05.2020, 14:50
- DPMI code from .COM file? - ecm, 11.05.2020, 14:59
- DPMI code from .COM file? - Rugxulo, 13.05.2020, 04:39
- DPMI code from .COM file? - CandyMan, 13.05.2020, 19:53
- DPMI code from .COM file? - ecm, 11.05.2020, 14:42