Article View: alt.lang.asm
Article #177Re: 32bit conversion help needed
From: pramin artrit
Date: Fri, 01 Sep 1995 17:13
Date: Fri, 01 Sep 1995 17:13
81 lines
3518 bytes
3518 bytes
Donald K. Forbes (don@mythos.com) wrote:
: ewirtz@bga.com (Erik Wirtz) wrote:
: >I am trying to convert a program that accesses a network card
: >to 32bit Protected mode. It consists of a small C program and a
: >small ASM program, It works flawlessly in real mode. When compiled
: >under 32bit Protected Mode it generates GP's. I need help getting
: My guess is you are trying to access memory using a real mode
: segment/offset pair. You can not do this from protected mode.
: You must allocate a selector and set its base address and limit.
: In Windows 16 bit or Borland 16 bit DPMI you can use
: AllocSelector(), SetSelectorBase() and SetSelectorLimit().
: but since your are using Borland 32 bit DPMI these are not
: available, therefore, you must call DPMI yourself. If you
: do this, though, your program will not run in a DOS shell
: under Windows 95 (it will if you use 16 bit DPMI). Here is
: some code that will allocate a selector and set its base/limit:
: /**************************************************************************
: *
: * Allocates a selector with base addres 'dwBaseAddress' and limit of
: * 'dwLimit'. The return value is the new selector if the function is
: * successful or 0 on failure.
: *
: * This is function should not be confused with the Windows API
: function
: * of the same name which simply allocates a selector.
: *
: ********************************************/
: SELECTOR _EXPORT AllocSelector(DWORD dwBaseAddress, DWORD dwLimit)
: {
: SELECTOR selNew;
: asm {
: // dwLimit must be non-zero
: mov eax, dwLimit
: or eax, eax
: jz short Fail
:
: // Allocate a data selector (DPMI sets default acces rights)
: mov ax, 0x0000
: mov cx, 0x0001
: int DPMI_INT
: jc short Fail
: mov selNew, ax
: // Set the selector's base address
: mov ax, 0x0007
: mov bx, selNew
: mov ecx, dwBaseAddress
: mov dx, cx
: shr ecx, 16
: int DPMI_INT
: jc short Fail
: // Set the selector's limit
: mov ax, 0x0008
: mov bx, selNew
: mov ecx, dwLimit
: dec ecx
: mov dx, cx
: shr ecx, 16
: int DPMI_INT
: jc short Fail
: }
: Success:
: return selNew;
: Fail:
: return 0;
: }
: ------------------------------------------------------------
: Donald K. Forbes e-mail: don@mythos.com
: _ _ ____ ___ ___
: / / //__/ / /__// //__
: / / / / / //__/___/ Software, Inc.
: My opinions are mine and not necessarily that of my employer
: ------------------------------------------------------------
Technical Details
Message-ID:
<427evf$s4a@malakor.kku.ac.th>Path:
arc1-ca.pugleaf.net!malakor.kku.ac.th!kku1!praminReferences:
<40tocr$k7b@giga.bga.com> <41arfs$s6v@nnrp3.primenet.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!malakor.kku.ac.th!kku1!pramin From: pramin@kku1.kku.ac.th (pramin artrit) Newsgroups: alt.lang.asm,comp.lang.c,rec.games.progammer,alt.msdos.programmer,comp.os.msdos.programmer,comp.os.netware.misc,comp.programming,realtime.programmers,comp.lang.c++ Subject: Re: 32bit conversion help needed Followup-To: alt.lang.asm,comp.lang.c,rec.games.progammer,alt.msdos.programmer,comp.os.msdos.programmer,comp.os.netware.misc,comp.programming,realtime.programmers,comp.lang.c++ Date: 1 Sep 1995 17:13:19 GMT Organization: Khon Kaen University, Khon Kaen, Thailand Message-ID: <427evf$s4a@malakor.kku.ac.th> References: <40tocr$k7b@giga.bga.com> <41arfs$s6v@nnrp3.primenet.com> NNTP-Posting-Host: koon.kku.ac.th X-Newsreader: TIN [version 1.2 PL2]