我正在撰寫 ASM,我真的不了解 的規則mov,所以
mov rax, 100 ; it means that the number 100 is in rax?
mov rax, a ; it means that the value of a is in rax? or is the memory direction?
mov rax, [a] ; it means the value of a? or what?
mov [a], rax ; the direction of memori in a change to rax?
mov rax, rbx ; rbx is now rax?
對不起,如果我的問題很愚蠢,但我真的很困惑……謝謝
uj5u.com熱心網友回復:
因為我們有,mov rax, 100因為有效,我們知道它是 Intel 語法。繼續并假設 a 是一個標簽而不是一個宏或 equ,結果是一個常量:
mov rax, 100 ; Always means put constant 100 in rax
mov rax, a ; Either means put the address of a in rax,
; or put a in rax depending on which assembler.
; For nasm it's always the address of a.
mov rax, [a] ; Always means the 8 byte value stored at a
; for offsets above 2GB, target register must be al, ax, eax, or rax
mov [a], rax ; Put the value of rax in the value stored at a
mov rax, rbx ; Put the value of rbx in rax (no memory access)
mov rax, [rbx] ; Put the value stored where rbx points into rax
為了完整起見,我添加了最后一個。不在這里做 [] 操作中的數學運算。
但是你很少想加載絕對地址;您通常需要 rip-relative,您通常應該撰寫以下內容(NASM 語法):
lea rax, [rel a] ; put address of a into rax
mov rax, [rel a] ; put value at a into rax
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/313739.html
上一篇:在匯編語言中訪問變數的位
