intel-syntax

Commenting syntax for x86 AT&T syntax assembly

爷,独闯天下 提交于 2020-08-18 14:13:54
问题 The Intel syntax has comments using the semicolon. When I switched to AT&T, it actually tried to interpret the comments. What is the comment syntax for AT&T assembly? 回答1: Comments for at&t assembler are: # this is a comment /* this is a comment */ According to the fourth result Google gave me // and /* */ comments are only supported in .S files because GCC runs the C preprocessor on them before assembling. For .s files, the actual assembler itself ( as ) only handles # as a comment character

Commenting syntax for x86 AT&T syntax assembly

这一生的挚爱 提交于 2020-08-18 14:10:48
问题 The Intel syntax has comments using the semicolon. When I switched to AT&T, it actually tried to interpret the comments. What is the comment syntax for AT&T assembly? 回答1: Comments for at&t assembler are: # this is a comment /* this is a comment */ According to the fourth result Google gave me // and /* */ comments are only supported in .S files because GCC runs the C preprocessor on them before assembling. For .s files, the actual assembler itself ( as ) only handles # as a comment character

Different behavior calling JMP with register vs value

你。 提交于 2020-06-01 05:54:29
问题 I'm trying to perform an absolute jump to the address 0x7C00 as part of a procedure in a hobby OS. I'm using intel syntax in GAS and testing in QEMU. I tried two methods: jmp 0x00007c00 and mov eax, 0x00007C00 jmp eax The second method seems to work as I intended and jumps to 0x7C00, but the first method causes QEMU to crash stating that it's "trying to execute code outside RAM or ROM at 0x40007c00". Does anyone know why it's jumping to a different address and the upper bytes are being set to

What do square brackets mean in x86 assembly?

Deadly 提交于 2020-05-10 09:25:09
问题 I'm very new to assembly, and have some very basic questions. What is the difference between these four commands? mov ebx, eax mov [ebx], eax mov ebx, [eax] mov [ebx], [eax] They say that the brackets mean "get the value of the address". But what, then, does that very first line really do? Does it not move the value of eax into ebx? If it does, then what are the point of the brackets? 回答1: Let's make a very simple example and imagine we have a CPU with only two registers, EAX and EBX. mov ebx

What do square brackets mean in x86 assembly?

冷暖自知 提交于 2020-05-10 09:21:08
问题 I'm very new to assembly, and have some very basic questions. What is the difference between these four commands? mov ebx, eax mov [ebx], eax mov ebx, [eax] mov [ebx], [eax] They say that the brackets mean "get the value of the address". But what, then, does that very first line really do? Does it not move the value of eax into ebx? If it does, then what are the point of the brackets? 回答1: Let's make a very simple example and imagine we have a CPU with only two registers, EAX and EBX. mov ebx

Getting Intel-syntax asm output from icc, instead of the default AT&T syntax?

这一生的挚爱 提交于 2020-01-04 01:29:08
问题 I am stuck at a problem. I've been using gcc to compile/assemble my C code for a while and got used to reading Intel assembly syntax. I used the -masm=intel flag when generating the assembly files. Yet recently, due to company migrations, they obtained Intel's icc, claiming it is better. So now I need to use icc, but it was strange that it has the default assembly syntax as AT&T. I tried to change it but it didn't work, so I contacted Intel support and they also don't know and each person

Referencing memory operands in .intel_syntax GNU C inline assembly

与世无争的帅哥 提交于 2019-12-24 23:16:40
问题 I'm catching a link error when compiling and linking a source file with inline assembly. Here are the test files: via:$ cat test.cxx extern int libtest(); int main(int argc, char* argv[]) { return libtest(); } $ cat lib.cxx #include <stdint.h> int libtest() { uint32_t rnds_00_15; __asm__ __volatile__ ( ".intel_syntax noprefix ;\n\t" "mov DWORD PTR [rnds_00_15], 1 ;\n\t" "cmp DWORD PTR [rnds_00_15], 1 ;\n\t" "je done ;\n\t" "done: ;\n\t" ".att_syntax noprefix ;\n\t" : : [rnds_00_15] "m" (rnds

How to get `mov rdx, symbol` to move symbol value and not value at symbol's address in clang intel-syntax?

◇◆丶佛笑我妖孽 提交于 2019-12-24 03:45:10
问题 I have the following code which I'm using with clang on macOS: .intel_syntax noprefix .data hello: .ascii "Hello world\n" hello_len = . - hello .text .globl _main _main: mov rax, 0x2000004 mov rdi, 1 lea rsi, [rip + hello] mov rdx, hello_len # <------- syscall mov rax, 0x2000001 syscall While it looks like it should print "Hello World" and exit, it actually segfaults. It turns out it's because mov rdx, hello_len actually tries to move the value that is at address hello_len , not the value of

NASM/Yasm drops CALL after comment ending with backslash

穿精又带淫゛_ 提交于 2019-12-20 05:28:07
问题 I am currently trying to built my own boot loader and noticed something peculiar. When below code is assembled with NASM or Yasm without the marked NOP command the following CALL is missing from the binary. With the NOP included the CALL is correctly assembled but the op code 0x90 (NOP) is not present in the binary (later is understandable due to the nature of NOP). to_hex_ascii: add al, '0' cmp al, 0x3a jl .end ; add al, 0x07 add al, 0x27 .end: ret print_word_hex: push bp mov bp, sp mov dx,

How to set gcc to use intel syntax permanently?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 08:56:14
问题 I have the following code which compiles fine with the gcc command gcc ./example.c . The program itself calls the function "add_two" which simply adds two integers. To use the intel syntax within the extended assembly instructions I need to switch at first to intel and than back to AT&T. According to the gcc documentation it is possible to switch to intel syntax entirely by using gcc -masm=intel ./exmaple . Whenever I try to compile it with the switch -masm=intel it won't compile and I don't