Why Does the lea dx, bp+variable Instruction Cause an A2049 Error in MASM?

  • Thread starter Thread starter beginnermoj
  • Start date Start date
  • Tags Tags
    Assembly Error
Click For Summary

Discussion Overview

The discussion centers around an error encountered in MASM (Microsoft Macro Assembler) when using the instruction "lea dx,bp+variable." Participants explore the nature of the error, potential solutions, and the context of programming in assembly language.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports an "error A2049: Illegal use of register" when attempting to use "lea dx,bp+variable" in their assembly code.
  • Another participant suggests rearranging the instruction to "dx,variable+bp" or using brackets, proposing variations like "dx,[variable+bp]" or "dx,[bp+variable]."
  • Some participants express curiosity about the relevance and use of assembly language in modern programming, questioning whether it is still commonly used.
  • A later reply indicates that using brackets is necessary to differentiate between an address and an immediate value, suggesting the correct format is "lea dx,[offset+bp]."

Areas of Agreement / Disagreement

There is no clear consensus on the solution to the error, as participants propose different approaches and express varying levels of familiarity with assembly language.

Contextual Notes

Participants do not clarify the specific definitions of terms like "offset" or the exact nature of the variable being referenced, leaving some assumptions unaddressed.

Who May Find This Useful

This discussion may be useful for programmers working with MASM, those learning assembly language, or individuals interested in error handling within low-level programming contexts.

beginnermoj
Messages
1
Reaction score
0
when I use the instruction "lea dx,bp+variable" in my program, when compiling I get the following error:
" error A2049: Illegal use of register"
this is a section of my program:
pop bp
sub bp,107h
mov ah,4eh
lea dx,bp+file_inf ;this is the line that I have error
mov cx,0000h
int 21h

what can I do to solve this error? please some one help me!
I used masm 5.1 and also masm 611
 
Technology news on Phys.org
Just a guess, but try and switch them around.

dx,variable+bp

or brackets
dx,[variable+bp] ;or try
dx,[bp+variable]just a guess
 
What is that? Assembly language? Do people still program in Assembly??
 
DaveC426913 said:
What is that? Assembly language? Do people still program in Assembly??

I have a friend who uses code warrior to write assembly for the motorola family of micros, and swears by it. In the forum devoted to code warrior there are unending posts, so I'm told, about problems inherent in wedging the C language into a role for an application that is really about bit and register manipulation.
 
jmaat7 got it right, you just need brackets to indicate it's an address as opposed to an immediate value.

lea dx,[offset+bp]
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 13 ·
Replies
13
Views
6K
  • · Replies 4 ·
Replies
4
Views
5K