[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Assembly problem with Borland C++ 5

Posted on 1997-08-13
4
Medium Priority
?
581 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 320 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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