Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2003-02-23
Medium Priority
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?
Question by:Adun
  • 3
  • 2
LVL 50

Expert Comment

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

Author Comment

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

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!
LVL 50

Accepted Solution

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
  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.

    Mov  AH, 0
    Call [XMSAddr]   { This is the himemofs, himemeseg abover }
    Or   AX, AX
    Jne  @@1
    Mov  XMSError, BL
    Jmp  @@2
    Mov  HighB, AH
    Mov  LowB, AL
  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.

Author Comment

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?
LVL 50

Expert Comment

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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Loops Section Overview

580 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