Solved

Assembly problem with Borland C++ 5

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

20 Experts available now in Live!

Get 1:1 Help Now