Linux 装配NASM-和掩模
当我运行这个程序时,它会说: asm:9:错误:操作码和操作数的组合无效 问题是,啊,。代码的其余部分应该是正确的,我只需要知道如何解决这个问题,因为我似乎无法在两个寄存器之间执行ANDLinux 装配NASM-和掩模,linux,assembly,nasm,x86-16,Linux,Assembly,Nasm,X86 16,当我运行这个程序时,它会说: asm:9:错误:操作码和操作数的组合无效 问题是,啊,。代码的其余部分应该是正确的,我只需要知道如何解决这个问题,因为我似乎无法在两个寄存器之间执行AND section .text global _start _start: call _input mov al, input mov ah, maschera and al, ah mov input, al call _output jmp _exit
section .text
global _start
_start:
call _input
mov al, input
mov ah, maschera
and al, ah
mov input, al
call _output
jmp _exit
_input:
mov eax, 3
mov ebx, 0
mov ecx, input
mov edx, 1
int 80h
ret
_output:
mov eax, 4
mov ebx, 1
mov ecx, input
mov edx, 1
int 80h
ret
_exit:
mov eax, 1
int 80h
section .data
maschera: db 11111111b
segment .bss
input resb 1
MASM/TASM/JWASM语法不同于NASM。如果要在某个地址加载/存储数据,则需要显式使用方括号。如果要使用
MOV
指令将标签地址放在变量中,则不使用方括号。方括号类似于反引用运算符
在32位代码中,您需要确保将地址加载到32位寄存器中。任何高于255的地址都不适合8字节寄存器,任何高于65535的地址都不适合16位寄存器
您可能正在查找的代码是:
section .text
global _start
_start:
call _input
mov al, [input]
mov ah, [maschera]
and al, ah
mov [input], al
call _output
jmp _exit
_input:
mov eax, 3
mov ebx, 0
mov ecx, input
mov edx, 1
int 80h
ret
_output:
mov eax, 4
mov ebx, 1
mov ecx, input
mov edx, 1
int 80h
ret
_exit:
mov eax, 1
int 80h
section .data
maschera: db 11111111b
segment .bss
input resb 1
和al,啊
不是你给我们看的代码中的第9行。无论如何,这个指令可能不是问题所在。更可能是mov输入,al
,它应该是mov[input],al
。同样,在所有其他访问内存的地方(即使用括号访问给定地址的内存)。现在我遇到了以下错误:jdoodle.asm:(.text+0x6):重新定位被截断以适应:R_386_8反对。bss'jdoodle.asm:(.text+0x8):重新定位被截断以适应:R_386_8反对。看看数据