Solved

Assembly problem with Borland C++ 5

Posted on 1997-08-13
4
565 Views
Last Modified: 2013-12-03
I have a 16-bit Windows app that has some inline assembly in it. I get errors when I compile, but I have seen other code similar to mine work. Perhaps is was with a different compiler, but I need it to work with BC5. I need it to copy a single instruction to another location. The code looks something like this:

// ...
WORD off;
_asm mov ax,offset label
_asm mov off,ax

// More code...

return;
label:
// the assembly instruction to copy goes here.

I know that the label works properly with a jmp instruction, but not with offset. I get an undefined symbol error when I try to compile. What is another method I could use?

Thanks in advance.
0
Comment
Question by:eppsman
  • 2
  • 2
4 Comments
 

Author Comment

by:eppsman
ID: 1403864
Edited text of question
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1403865
Tell me if I got it right: you want to put into off the opcode of a copy instruction you wrote in assembly and that you put after the return statement of the C function.
The label works fine because you are able to jmp to it through inline asm code, but if you load the offset of the label position  you get a compilation error.
Everything correct?

I think I can help you, but where exactly do you get the compilation error? On the line:
asm mov ax,offset label
?

Davide Marcato.
0
 

Author Comment

by:eppsman
ID: 1403866
What I meant about the jmp statement was if I replaced the line:

_asm mov ax,offset label

with

_asm jmp label

the compiler will recognize that "label" is a label, but that was just to test and see if the compiler would do it. I don't want a jmp instruction there. I get the error on that line with the offset instruction, which is the instruction that I need.
Thank you.


0
 
LVL 4

Accepted Solution

by:
davmarc earned 160 total points
ID: 1403867
Are you sure that the sintax you used is acceptable for BC++ inline assembler? I don't use BC++ but try with "offset [label]" or something similar.

If this approach doesn't work, you can always use the hexadecimal values of the word identifying the opcode and its parameter (the disassembly window in debug mode should help here), and assign them to off directly:
WORD off = MAKEWORD(0x1234, 0xABCD); // just an example

Davide Marcato.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

829 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