Solved

Assembly problem with Borland C++ 5

Posted on 1997-08-13
4
557 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now