?
Solved

How to make a "call es:bx" in Turbo C in-line assembly? thanks

Posted on 2003-02-23
5
Medium Priority
?
648 Views
Last Modified: 2008-03-10
Hi there,
I want to insert a call function in Turbo C like this, CALL ES:BX
but seems it does not work.
what is the correct syntax pls?
thanks!
0
Comment
Question by:Adun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:dbrunton
ID: 8006133
If you don't have Turbo Assembler in your system assembly won't work.

Assuming you do then try

asm   call   es:bx
0
 

Author Comment

by:Adun
ID: 8006350
Hi dbrunton,
Thanks for ur reply.
I do have tasm.exe and i tried

asm call es:bx

the tasm issued me a warning saying:
":" operator ignored.
then i run the generated exe file. it just hangs...

Below is what i typed in Turbo C 2.0 IDE

#include ....
void main(void)
{
int i;
asm mov ax, 0x4310
asm int 0x2F
asm mov ah,0x00
asm call es:bx
asm mov i,ax
printf("%X",i);
}

the INT 2FH with AX=4310H is to put Dos Extended Memory Driver Control address into ES:BX
then calling ES:BX with AH=0x00 means to get XMS driver version into AX.
but against all that, it simply hangs...
pls HELP!
0
 
LVL 49

Accepted Solution

by:
dbrunton earned 200 total points
ID: 8006560
Here's some code from a Turbo Pascal unit.  This might help

    mov ax,4300h      { Check to see IF HIMEM.SYS installed }
    int 2fh
    cmp al,80h        { Returns AL = 80H IF installed }
    jne @1
    mov ax,4310h      { Now get the entry point }
    int 2fh
    mov himemofs,bx
    mov himemseg,es
 @1:
  END;
  XMSDriverLoaded := (himemseg <> 0);   { Pascal code }

That's the equivalent of your first 2 lines of assembler.  It tests and returns whether it found XMS or not plus stores es:bx into a variable.

 Asm
    Mov  AH, 0
    Call [XMSAddr]   { This is the himemofs, himemeseg abover }
    Or   AX, AX
    Jne  @@1
    Mov  XMSError, BL
    Jmp  @@2
   @@1:
    Mov  HighB, AH
    Mov  LowB, AL
   @@2:
  end;
  GetXMSVersion := (HighB * 100) + LowB;

This code is the equivalent of your bottom three lines of assembler.

I suggest you get the first bit going first to see if theres is extended memory present first.  If that works then, then, try and get the version.
0
 

Author Comment

by:Adun
ID: 8006580
Hi, thanks again for ur help.
I tried the first bit and the AL does return 80H, which means Extended memory is installed.
But when i tried to set AX=4310H then call es:bx, it hangs...
Maybe i should use call [es]:[bx] or call [es]:bx or something?
Thanks.
0
 
LVL 49

Expert Comment

by:dbrunton
ID: 8006714
Try storing the es and bx address into a variable and then call that.

This is what the second code fragment I posted is doing.  Now why you have to do that I don't know.

The method you show "seemingly" should work but isn't.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question