The segment and offset are stored in two separate registers in the CPU. 
Therefore, to move the contents of the two registers to memory to store
them as a single full pointer ('far pointer') can be done with a single
asm instruction, but depending on the memory bus word size, two or more
memory accesses.  They can also be accessed (moved) independently of
each other in memory, or the CPU.  These C functions provide a way in C
to re-unite the two parts into contiguous memory or register space so
that the single asm instructions that use both of them can still work. 
Conversely, these functions provide a way to move the two parts
separately in a C friendly way if needed.

To translate DPM memory is a straight forward procedure:

#define DPM_OFFSET 0xC000 

#define DPM_TO_CPU (addr) (addr += DPM_OFFSET)

#define CPU_TO_DPM (addr) (addr -= DPM_OFFSET)  

- Kal.

Norm Dresner wrote:
> 
> Back in MS-DOS days, we had functions provided with the compiler to do the
> conversions between a pointer and a segment:offset description of an address:
>         void                    *MK_FP( ushort seg , ushort off );
>         unsigned short  FP_SEG( void *pointer );
>         unsigned short  FP_OFF( void *pointer );
> 
> I have the need to do computation like this when accessing an ISA board
> (1st 1M of memory) and when translating the addresses from the dual-ported
> RAM from what's seen by the CPU on the board to what's seen by the PC (On
> the board, the DPM looks like it starts at  0x1000:0 while on the PC it's
> at 0xD000:0).
> 
> Obviously I could roll my own replacements but before I start doing that I
> was wondering if it had already been done -- and probably more elegantly
> (and even more correctly) than I could do (at least the first time I do it).
> 
> Thanks
>         Norm
> 
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to