简体   繁体   English

使用fasm汇编程序将寄存器值以汇编语言移动到存储器地址时遇到问题吗?

[英]Problems in moving a register value to a memory address in assembly language using fasm assembler?

I am really confused about this one thing. 我对这件事真的很困惑。 I was following the book assembly programming for x86 processors and i was reading about the mov instructions and how it works. 我一直在遵循针对x86处理器的汇编程序设计书籍,并且正在阅读有关mov指令及其工作方式的信息。 So, the author said that the following instruction is valid mov mem,reg.....basically moving a register value to a memory address. 因此,作者说以下指令是有效的mov mem,reg .....基本上将寄存器值移动到存储器地址。

Now this what i tried and i keep getting this error called invalid operand. 现在,这是我尝试过的,并且我不断收到称为无效操作数的错误。 Can someone please explain me what exactly is the error. 有人可以解释一下到底是什么错误。

#fasm#

 mov ax,[var] ;the value 67 is moved to the ax register works perfect
 mov myvar,ax ; my aim is to move the value 67 to the memory location of ;myvar but then i keep getting this error - Invalid operand? why is that?

var: dw 67   
myvar: dw ?

Can you try this: 你可以尝试一下:

mov [myvar], ax
  • myvar is a constant holding the address of the memory allocated for the variable. myvar是一个常量,保存为变量分配的内存地址。
  • [myvar] instructs to fetch/store a value in memory at the address pointed by myvar [myvar]指示在myvar指向的地址处在内存中获取/存储值

So: 所以:

mov ax, myvar  ; load the address of myvar in ax
mov ax, [myvar]; load the value stored at address myvar
mov [myvar], ax; store the value of ax at address myvar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM