139 questions
1
vote
0
answers
106
views
How to compare a register and the effective address of a variable in GAS with intel_syntax
I am following an assembly tutorial where they use NASM. They manage to compare a register to a variable's address with cmp rcx, digitSpace, but how can I do the same with GAS?
As you know this ...
2
votes
1
answer
72
views
jmp 0x1234 does not compile in clang with .intel_syntax?
Using clang on macOS with Xcode, the following x86_64 assembly code compiles successfully, which does NOT use Intel Syntax. The jmp instruction jumps to a displacement of 0x1234 bytes from the current ...
3
votes
1
answer
216
views
A variable named "offset" causes "Error: invalid use of register" to appear when using "-masm=intel" in gcc, but no error in AT&T mode
I tried to compile a very simple program using gcc with -masm=intel option. But instead "Error: invalid use of register" appears.
// test.c
#include <stdio.h>
size_t offset;
int main(...
2
votes
1
answer
85
views
GNU as: Escape symbol names in intel_syntax
With GNU as .intel_syntax, some identifiers apparently become keywords, and writing e.g.
call and
to invoke a function called and results in
Error: invalid use of operator "and"
How do you ...
3
votes
0
answers
64
views
Why can't I store data on the stack properly?
I'm writing a compiler, and it emitted the following (Intel-syntax) assembly code for Linux (x86-64):
lea r13, _s1
mov qword ptr [rbp + -2*8], r13
mov r10, qword ptr [rbp + -2*8]
lea r13, qword ptr [...
0
votes
0
answers
84
views
Junks ax after expression
This code works as a IN func for i/o ports in inline c:
int func(short port)
{
short data;
__asm__(
".intel_syntax \n\t"
"in byte %0, %1\n\t"
"...
0
votes
0
answers
27
views
How to assign to global variables in x86 intel syntax assembly [duplicate]
In the x86 intel syntax, global variable values can be accessed with [rip+a], but when I try to assign a new value to a global variable address, like mov [rip+a], 4, a Segmentation Fault occurs. I was ...
2
votes
2
answers
556
views
How to convert Intel Assembly C to AT&T C++
I trying to convert function "__cpuid" from С language to C++.
I have a problem that the g++ compiler does not work with Intel assembler.
I'm trying to translate this code:
__asm
{
...
1
vote
2
answers
438
views
What does % mean on register names in assembly language?
I tried to convert and interpret C language code into assembly language with GCC -S option.
What is the difference between push %rbp and push rbp?
0
votes
1
answer
523
views
Accessing "array" data in GNU assembler using Intel syntax
I am tasked to write a GNU assembly program using Intel syntax which counts numbers in array which are <= 6
I came up with the following code:
.intel_syntax noprefix
.data
n: .word 5
a: ....
2
votes
1
answer
1k
views
Choose Intel syntax for perf report assembly
My perf report shows everything in AT&T syntax:
...
0,18 │ pop %rax
0,14 │ ← retq
0,18 │a9: vmovsd -0x8(%rdi,%rsi,8),%...
3
votes
2
answers
1k
views
How Do I Convert This ATT assembly to Intel Syntax? Jump to a non-relative address without using registers
I was reading this article " assembly-challenge-jump-to-a-non-relative-address-without-using-registers ".
I need to do exactly what he suggests here (Jump to a non-relative address without ...
3
votes
1
answer
2k
views
why sometimes use offset flat:label and sometimes not
I'm learning assembly using GNU Assembler using the Intel syntax and there is one think that I don't really understand. Say for example this code right here :
.intel_syntax noprefix
.data
string: ....
0
votes
0
answers
2k
views
gcc inline assembly: how to use intel syntax temporarily with constraint 'm' under 'gcc -masm=att' [duplicate]
I'd like to use intel syntax gcc inline assembly, leaving gcc's default -masm=att dialect untouched.
The following code works fine:
#include <stdio.h>
int main(int argc, char *argv[])
{
int ...
0
votes
0
answers
655
views
Syntax for indirect jump in GAS (Intel syntax): double brackets and/or OFFSET as part of the addressing mode?
For an indirect jump to the address stored in L + 8 in 64-bit mode,
nasm accepts,
jmp [L + 8]
jmp qword [L + 8]
GNU as accepts,
jmp [L + 8]
jmp qword ptr [L + 8]
and also,
jmp [[L + 8]]
jmp [qword ...
1
vote
0
answers
46
views
GNU AS confusion between memory and immediate depending on declaration order? [duplicate]
I've searched the web but haven't found anything that answers my question so hopefully someone on here will be able to answer it.
Using GNU AS with Intel syntax (.intel_syntax noprefix) gives mixed ...
0
votes
0
answers
218
views
GAS Intel Syntax won't assemble mov rdi, offset:symbol
I'm new to x86 assembly and I'm following a practical work for the basics.
I have 2 equivalent sample codes: One in AT&T syntax and the other on Intel syntax.
When compiling theses with GCC, ...
0
votes
2
answers
2k
views
Is it possible to disassemble C code into intel assembly using an m1 mac?
I've been trying to disassemble C code into intel assembly code on my m1 macbook pro but can't find any way to do it (i've tried to look up how to do it using gdb, lldb, objdump, but no succes so far)....
2
votes
1
answer
1k
views
What is the syntax of "align" keyword/instruction in x86 assembly?
As far as I understand, some objects in the "data" section sometimes need alignment in x86 assembly.
An example I've come across is when using movaps in x86 SSE: I need to load a special ...
0
votes
0
answers
37
views
Assembly x86-64 | Segmentation fault [duplicate]
I have a task like this:
Implement the function with the signature in x86-64 assembly language:
extern int * A;
extern void func(size_t N);
The function in the loop N times:
Enters a signed 32-bit ...
3
votes
1
answer
472
views
Can Visual Studio display an Intel disassembly instead of AT&T syntax during a Linux-GCC-Debug session?
Currently the disassembly shows AT&T syntax below, but I'm accustomed to reading the Intel syntax.
Is there an option or setting to switch between them? Thanks.
0
votes
2
answers
454
views
x86 real mode function calls not executing
I have some x86 realmode assembly code which isn't behaving exactly as expected. I believe the issue relates to an incorrectly calculated jmp/call offset, but I might be mistaken.
Here is the ...
0
votes
1
answer
554
views
Intel x86 asm print string function [duplicate]
I attempted to write a print string function;
45 ; the address is stored in si
46 print_string: ...
0
votes
1
answer
1k
views
too many references for 'mov' when using two 64-bit registers?
I'm trying to compile one very simple program, but I get 2 errors that I can not fix:
1.s:13:Error: too many memory references for 'mov'
1.s:15:Error: too many memory references for 'lea'
Here is my ...
0
votes
0
answers
86
views
how can I store 20 digit number to 64-bit Register in Assembly
.intel_syntax noprefix
number1:
.quad 8403406020084561865 , 3325915310126341549 , 1038926090642473899 , 12330590014810845464
mov r12,[number1+0]
mov r13,[number1+8]
mov rcx,[number1+...
3
votes
1
answer
15k
views
How to inline-assembly with Clang 11, intel syntax and substitution variables
I have a lot of trouble to make it work:
I have tried the following ways:
uint32_t reverseBits(volatile uint32_t n) {
uint32_t i = n;
__asm__ (".intel_syntax\n"
&...
1
vote
1
answer
1k
views
GCC inline assembly intel syntax "Error: invalid use of register"
I decided to try using inline assembly in c for my basic operating system (using intel syntax because I am used to that with NASM). And I came across something I could not fix, I tried looking ...
2
votes
1
answer
390
views
How to create a C-callable function in assembly
I am learning assembly using Jeff Duntemann's book. I am trying to figure out how to write function that can be called in C.
Say for example that I want to implement the following function in assembly:...
0
votes
0
answers
161
views
What is the difference between mov dword ptr [eax], 5 and mov dword [eax], 5? [duplicate]
What is the difference between the operations:
mov dword ptr [eax], 5
and
mov dword [eax], 5
Furthermore, do
mov dword ptr [eax], 5
and
mov [eax], dword ptr 5
do the same thing?
2
votes
2
answers
4k
views
Intel Assembly ljmp syntax from AT&T syntax
I am trying to convert the xv6 boot code from At&t syntax to Intel syntax and I have a problem with the ljmp instruction. I am trying to learn the boot process of Intel computers and I am not ...
1
vote
1
answer
136
views
Does V8 engine know how to print generated machine code using Intel syntax?
I'm using D8 shell and the flag --print-opt-code to print the code TurboFan generates.
However, the code is printed using AT&T syntax. I'm not familiar with it, but with Intel syntax. I searched ...
0
votes
0
answers
541
views
Understanding compiler's mov [mem], reg instructions for C using CPUID instruction
I've been studying assembly in school, and I'm trying to apply it to a real situation. I have a product that is no longer supported and I want to see how a portion of the code that uses the CPUID to ...
0
votes
1
answer
280
views
How can I run C-code with assembly inserts [duplicate]
I have C-program with assembly insert.
Here is code:
main.c:
#include <stdio.h>
int f() {
int a = 0, b;
__asm__ (".intel_syntax noprefix\n\t"
"mov edx, 1\n\t&...
0
votes
1
answer
1k
views
What is EXTRN in Intel-syntax assembly?
x86 CPU: MSVC (2010)
What does EXTRN _printf:PROC means in code bellow and why after ":" we use some "PROC" directive instead of "near" or "far"?
CONST ...
0
votes
1
answer
4k
views
Differences between Assembly Languages
I'm very new to Assembly Language and I know there are many, many types of assembly languages. Such as ARM, MIPS, x86 etc. So I have questions.
Below is more Information
Hello World in ARM
.text ...
4
votes
1
answer
2k
views
Telling GAS to use semicolons for comments in Intel syntax mode
Can I use semicolons in GAS for comment characters?
I am using GAS 2.30 with the Intel syntax as below.
.intel_syntax noprefix
.section .text
# Program entry point
.globl _start
_start:
# Put ...
-1
votes
1
answer
983
views
GCC inline assembly cannot load local variable's address into register in x64 Intel format?
I am quite used to Intel-format inline assembly. Does anyone knows how to convert the two AT&T lines into Intel format in the code below? It is basically loading local variable's address into a ...
2
votes
0
answers
2k
views
clang doesn't use intel assembly syntax
I'm trying to compile an inline assembly code in clang (Windows). So,I have the following code:
int main(int, char **) {
asm("mov %eax,$4;");
}
I tried compiling it using clang++ -masm=...
1
vote
1
answer
189
views
Is there a way to specify syntax for x command output?
I want to know whether I can change the syntax of the output of the following command:
x/5i $rip
Now it gives output like that. I guess it is AT&T syntax, correct my if I'm wrong (newbie):
-> ...
1
vote
1
answer
404
views
Can I substitute a MOV operation with an OR operation?
First of all, I'd like to say that I'm new to ASM and if this is a stupid question please excuse it.
I read in Agner Fog's microarchitecture manual about partial register stalls (this seems a little ...
0
votes
0
answers
30
views
Cannot get correct immediate mode from GNU assembler for symbols with intel_syntax [duplicate]
I am trying to write a simple assembly program with GNU assembler (as) in MAC OS. Part of the program looks like the following:
.intel_syntax noprefix
.globl _main
.text
...
mov rdx, len
...
1
vote
0
answers
284
views
What is the "purpose" of commas in intel syntax?
I've been writing a programming game -- and with that comes writing a programming language. Initially I wanted the programming language to be a gross simplification of assembly language (like the game ...
0
votes
1
answer
205
views
OS resets on far jump after disabling paging
I'm working on modifying a routine that switches to and from realmode to perform a BIOS interrupt, but running into issues with paging. I had it working prior with no paging, but now that my OS uses ...
0
votes
1
answer
945
views
Different behavior calling JMP with register vs value
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,...
0
votes
1
answer
1k
views
invalid instruction suffix for mov?
I have this piece of inline assembly code that should print A in text mode:
void print(){
asm volatile(
"mov ax,0xb800\n"
"mov ds,ax\n" /*<-as complains about ...
3
votes
1
answer
1k
views
Offset before square bracket in x86 intel asm on GCC
From all the docs I've found, there is no mention of syntax like offset[var+offset2] in Intel x86 syntax but GCC with the following flags
gcc -S hello.c -o - -masm=intel
for this program
#...
1
vote
1
answer
672
views
What is the difference between using "offset" and "[ ]" on memory labels and registers in GAS .intel-syntax assembly?
Using GCC, compiling for 32-bit Intel architecture, with .intel_syntax noprefix.
Let's suppose I have the following .data section:
A: .int 0x1, 0x2
What is the difference between the following, when ...
0
votes
0
answers
19
views
Conversion of far jmp from NASM/Intel to GAS/AT&T [duplicate]
I just have a simple line of NASM/Intel syntax assembly that I need in GAS/AT&T syntax. The line is
JMP 0x08:reload_CS
I couldn't find anything online, but I have tried:
jmp $0x08, reload_CS
...
0
votes
2
answers
926
views
Converting [symbol + constant] Intel syntax addressing mode to AT&T syntax?
I just cant figure out how to add an offset to my destination when moving a value, specifically in Intel syntax I have:
MOV [gdtr + 2], EAX
and for AT&T syntax I have tried converting it to:
...
1
vote
0
answers
4k
views
gcc: asm syntax 'mov eax, OFFSET FLAT: .LC0'? [duplicate]
So I saw some code
.LC0:
.string "Hello world"
main:
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call puts
xor eax, eax
add rsp, 8
...