我有以下代码,可以用 gcc 命令很好地编译gcc ./example.c。程序本身调用函数“add_two”,它只是将两个整数相加。要在扩展汇编指令中使用 intel 语法,我需要首先切换到 intel,然后再切换回 AT&T。根据 gcc 文档,可以使用gcc -masm=intel ./exmaple.
每当我尝试使用 switch 编译它时,-masm=intel它都不会编译,我不明白为什么?我已经尝试删除该指令,.intel_syntax但它仍然无法编译。
#include <stdio.h>
int add_two(int, int);
int main(){
int src = 3;
int dst = 5;
printf("summe = %d \n", add_two(src, dst));
return 0;
}
int add_two(int src, int dst){
int sum;
asm (
".intel_syntax;" //switch to intel syntax
"mov %0, %1;"
"add %0, %2;"
".att_syntax;" //switch to at&t syntax
: "=r" (sum) //output
: "r" (src), "r" …Run Code Online (Sandbox Code Playgroud) 我想知道如何通过查看示例源代码来识别所使用的语法是em8086、TASM还是NASM?我是汇编新手..我想了解更多有关 emu8086 的信息。
我想知道如何在Intel语法的某些指令中将标签名称与寄存器名称区分开。例如,call rdx通常意味着间接跳转,但是如果我们rdx在同一程序集文件中有标签怎么办?我认为可以将其解释为直接跳转到rdx。是否有任何符号告诉汇编器是哪个?
我正在尝试运行从 GAS 风格获取的指令,但是当我将此指令移植到 intel 风格时,出现如下错误:
"error: parser: instruction expected"
Run Code Online (Sandbox Code Playgroud)
我尝试了各种组合,例如 REP movsl、REP loadsl,但都给出了相同的问题,任何人都可以告诉这个正确的命令相当于 x86 中的 REP stosl
嗨,我正在使用 gcc 在 mac 上处理 ASM intel_syntax noprefix,出于某种原因,我在后端不断收到此错误:64 位模式不支持 32 位绝对寻址 这是否与变量有关,在时刻是否已在 ASM 上使用内联?
这是我的代码:
#include <stdio.h>
char c, b;
int main() {
printf("Give me letter: ");
scanf(" %c", &c);
_
_asm( ".intel_syntax noprefix;"
"xor eax, eax;" // clear eax
"mov al, byte ptr [c];" // save c in eax
"cmp eax, 65;" // eax ? "A"
"jl Fin;" // eax < "A" -> Fin
"cmp eax, 90;" // eax ? "Z"
"jg UpC;" // eax >= …Run Code Online (Sandbox Code Playgroud) 我正在使用 AT&T 语法,但我想尝试一下英特尔。我有这个代码:
.text
.global _start
_start:
mov ebx, 0
mov eax, 1
int 80h
Run Code Online (Sandbox Code Playgroud)
哪个应该返回0,对吗?在我转换它之前,它是用 AT&T 做的。
我正在组装使用:
as out.s -msyntax=intel --32 -o out.o
Run Code Online (Sandbox Code Playgroud)
但我得到:
out.s:5: Error: ambiguous operand size for `mov'
out.s:6: Error: ambiguous operand size for `mov'
out.s:7: Error: junk `h' after expression
Run Code Online (Sandbox Code Playgroud)
我哪里出错了?
我对装配很新,并且有一些非常基本的问题.
这四个命令有什么区别?
mov ebx, eax
mov [ebx], eax
mov ebx, [eax]
mov [ebx], [eax]
Run Code Online (Sandbox Code Playgroud)
他们说括号的意思是"得到地址的价值".但那么,第一线真正做到了什么呢?它不会将eax的价值转移到ebx吗?如果是这样,那么括号的重点是什么?
还是我,我的idt.S文件(使用gcc编译的Intel语法)出现了新问题。当我尝试编译以下代码时:
load_idt:
mov edx, (esp + 4) ; On this line
lidt (edx)
sti
ret
Run Code Online (Sandbox Code Playgroud)
我收到一个我真的不知道如何解决的错误:
Error: too many memory references for `mov'
Run Code Online (Sandbox Code Playgroud) 我终于回到了我的 colorforth 项目,几年前当 binutils 的更新破坏了我的所有资源时,我放弃了这个项目。这是正在发生的事情的一个例子:
jcomeau@aspire:~$ cat /tmp/test.as
.intel_syntax
.arch i386
.code32
mov eax,[foo + eax*4]
lea ecx,[ecx*4+0x9e0]
mov edx,DWORD PTR [edi*4-0x4]
jmp DWORD PTR [ecx*4+0x12cc]
lea edx,[ecx+edx*1]
Run Code Online (Sandbox Code Playgroud)
第一个非指令行来自手册中的示例:https : //sourceware.org/binutils/docs/as/i386_002dMemory.html#i386_002dMemory,其余来自 objdump 反汇编--disassembler-options=intel。每一个都无法组装:
jcomeau@aspire:~$ as /tmp/test.as
/tmp/test.as: Assembler messages:
/tmp/test.as:4: Error: too many memory references for `mov'
/tmp/test.as:5: Error: too many memory references for `lea'
/tmp/test.as:6: Error: too many memory references for `mov'
/tmp/test.as:8: Error: too many memory references for `lea'
/tmp/test.as:7: Error: invalid operands (*UND* …Run Code Online (Sandbox Code Playgroud) 从我发现的所有文档中,没有提到像offset[var+offset2]Intel x86 语法那样的语法,但是 GCC 有以下标志
gcc -S hello.c -o - -masm=intel
对于这个程序
#include<stdio.h>
int main(){
char c = 'h';
putchar(c);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
产生
.file "hello.c"
.intel_syntax noprefix
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
push rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
mov rbp, rsp
.cfi_def_cfa_register 6
sub rsp, 16
mov BYTE PTR -1[rbp], 104
movsx eax, BYTE PTR -1[rbp]
mov edi, eax
call putchar@PLT
mov eax, 0
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size …Run Code Online (Sandbox Code Playgroud)