far pointer in assembler question 
Author Message
 far pointer in assembler question

Hello,

I would like to find an example of reading from a far pointer address using
inline assembler.  Here is how I set the address of the far pointer.

    #define MK_FP( seg,ofs )( (unsigned long _seg * )( seg )
              +( unsigned long near * )( ofs ))
    unsigned far long *ptr;
    unsigned long val;                           /*a total of four bytes
only */
    ptr = MK_FP(0x4000,0x0000);    /* sets address and offset in peek and
poke*/

How can I access the address pointed to by pointer to do either of these:
    *ptr = val;
    val = *ptr;

Here's why I need it ... I am writing some code to sit on an 0x86
microprocessor. Unfortunately I need a large array that can't fit within the
small memory model library that is provided with the compiler and have to
store it using peek and poke.  However, for some reason the peek is very
slow compared to poke and therefore would like to write some code in
assembler to see if I can speed it up.

I am having trouble with setting the address pointer (seg:off) to the far
memory location.

Any help would be appreciated,
Sincerely,
Joshua Swamidas
Instrumar Ltd.
St. John's, Newfoundland
Canada



Tue, 05 Jun 2001 03:00:00 GMT  
 far pointer in assembler question
I know that I nees to use "les" to load the seg and offset pointers but how
do I then move those the two words to my long variable, val?

Josh



Tue, 05 Jun 2001 03:00:00 GMT  
 far pointer in assembler question

Quote:

>I know that I nees to use "les" to load the seg and offset pointers but how
>do I then move those the two words to my long variable, val?

>Josh

I will only guess this is probably completely wrong.........
mov AX,DW
lods  uservariable,AX
Quote:
>this will load the Double word into your variable....... I think



Wed, 06 Jun 2001 03:00:00 GMT  
 far pointer in assembler question

Quote:


>>I know that I nees to use "les" to load the seg and offset pointers but
how
>>do I then move those the two words to my long variable, val?

>>Josh
>I will only guess this is probably completely wrong.........
>mov AX,DW
>lods  uservariable,AX
>>this will load the Double word into your variable....... I think

You want to load the DS:AX with the array pointer, CurrArry.
In the data segment you allocate space:
CurrArry    DD    Array1

The code sequence is as follows:
LDS    AX,CurrArry
The high word of CurrArry could be any segment you have allocated in your
program, or it could be any segment in memory (Lower Memory).  The AX
register would contain the offset into that segment where Array1 is located.

Hope this helps
Jerry



Thu, 07 Jun 2001 03:00:00 GMT  
 far pointer in assembler question
Thanks for your help, with this little code I was able to increase my code
speed by about 60%.  I has two mistakes in my code. The first was the use of
the variable "ptr" and the second was not using the accumulater register. I
was using DX I didn't think that it should make a difference.  Oh well

Sincerely,
Joshua Swamidas



Fri, 08 Jun 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Far Pointers and String Instructions

2. Please I would appreciate some input, Far pointer from C++ to asm

3. NASM: How to declare a far pointer?

4. Watcom C/C++ & far pointers

5. les, far pointer on linux

6. CallDLL and Long Far Pointer Return

7. Creating a FAR pointer in MS fortran

8. Passing char far * to assembler?

9. A couple of simple pointer questions (targets, arrays of pointers)

10. pointers and inline assembler

11. ISO C Binding: Pointer to a pointer of pointers: ***argv

12. Further Questions

 

 
Powered by phpBB® Forum Software