conver assembler pointer to c++ ?

Started by
5 comments, last by LessBread 17 years, 10 months ago
Hi I want to use interrupt 10h function 11h to read out the bios charackterset . I know that after I called the function the ES:BP will contain the adress. How can I copy or convert this adress into a pointer(c++) like void* or char* ? I want to use memcpy later to copy it. Btw i want to use inline assembler to call the inerrupt... Greetz jazzoid
Advertisement
I'm a newbie at asm, so tell me if i make a big mistake:
1. This is the wrong forum, questions like this should probably go here

2. Are you sure you know what your doing with interrupts? What OS are we talking about?

Aplogies if this underestimates your skill level, but:
3. The way you have worded the question suggests you are out of your depth. The typing system used in C++ is completely irrelevant in assembly. There is no 'conversion' from the value in ES:BP to a pointer in c++. Even in c++, casting a void* to a char* is just syntax to let the compiler know what you are doing. Nothing is actually done.

You have (assuming 32 bit machine) 4 bytes stored in that register. I'll take a bit of a stab at it(I don't know the intricacies of using asm with c++):


void* pointer

...asm stuff...

mov register, [pointer] or mov register, pointer, cant remember which.

[Edited by - DaBookshah on June 27, 2006 3:24:21 AM]
well,

after calling the interrupt ,
it returns the adress of the data i want to read/copy to
the adress ES:BP (segment:offset) .
The adress ist given in to parts...

I want to convert it to a absolute adress or something to
acces the data via pointer
Quote:Original post by jazzoid
well,

after calling the interrupt ,
it returns the adress of the data i want to read/copy to
the adress ES:BP (segment:offset) .
The adress ist given in to parts...

I want to convert it to a absolute adress or something to
acces the data via pointer


If you are using dos with some kind of 16 bit cpp compiler, then you have to use far pointers. If your compiler supports it, then you can take the segment and offset pairs as two 16 bit integers (unsigned short int), and costruct a single far pointer from that. If your compiler doesn't support far pointers and the rest of the 16 bit segmented memory model, then you are out of luck, you have to write assembly code to do it.

Viktor

ps: Borland compilers do support far pointers, just select the right memory model (called huge) on project creation. For more info, read Raplh Brown's Interrupt List and the official intel 8086 documentation.
Quote:Original post by DaBookshah
I'm a newbie at asm, so tell me if i make a big mistake:
1. This is the wrong forum, questions like this should probably go here

Hey! We are perfectly able to answer this one too (I hope) [grin]

Quote:Original post by DaBookshah
2. Are you sure you know what your doing with interrupts? What OS are we talking about?

That's probably the most relevant questin of the whole thread: there is only two case where youc an possibly do this: in 16 bits DOS or in 32 bit DOS (using a dos extender like the one which is supplied with DJGPP).

If the user is programming in a 32 bit DOS environment, the ASm code is simple. Like you said, put the content of the register in a pointer variable and that's all.

If the OP is using 16 bit, the answer is a bit more complicated. 16 far addresses are expressed using a traditional segment:address pattern, where both segment and address are 16 bit values. For example, the address of the beginning of the text memory in the graphic board is B000:0000. The representation of this pointer in C/C++, however, is not using two 16 bits values but a single 20 bit value which is stored in a far pointer (which is, in turn, a 32 bit value - ie means that bits 31 to 20 will not be used while bits 19 to 0 will represent the address). The pseudo code to create a far pointer is:
far char * p = (car char *)((segment << 8) + (address));

In ASM, you would need to do something like
xor eax, eax        // clear eaxxor ecx, ecx        // clear ecxmov ax, es         shl eax, 8          // eax = es << 8mov cx, bp   add eax, ecx        // eax = (es << 8) + bp 

(not sure it works, untested)

Quote:mov register, [pointer] or mov register, pointer, cant remember which.

This will move the content of the address pointed by pointer or the content of pointer into the register. You have to do it the otehr way [smile]

Now, another question arise: are you sure you are using DOS? Under windows (or under linux), you can't call int 10h, thus you will not be able to get the EGA character set.

HTH,
@Emmanuel:
THX man !

well i use MS .net 2003 ....
And I use Win32 ....

I was looking for a "cheap" (memory saving) way to get a font together.
Well, mmm you say I can't use them under windows ? :(

32 bit Windows operates in protected mode. That means that there is no function 11h associated with interrupt 10h. On Windows 2000 and XP, interrupt 10h is associated with floating point exception (see table 3-2 here).

For additional information:

Inside NT's Interrupt Handling

A Study of BIOS Interrupts as used by Microsoft Windows 2000
A Study of BIOS Services as used by Microsoft Windows XP

Interfacing the the Native API in Windows 2000

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement