Solved

Assembly problem with Borland C++ 5

Posted on 1997-08-13
4
566 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
[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
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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