Questions tagged [gnu-assembler]

The GNU Assembler (GAS). Use for GAS macros, machine dependent syntax, linkage and file format issues. Do use for generic assembler questions about how the machine works; the CPU tags are meant for this.

'gas' or the GNU assembler is used by GCC to process assembler files. It is included in the binutils suite of tools.

Relevant topics include gas macros, machine dependent GAS syntax, linkage and output formats (usually ELF sections). There isn't any need to tag generic assembler question just because 'gas' is being used. Use the CPU tag such as , , , etc. instead.

(For x86, is the syntax used by default by GAS, GCC, and other GNU tools. Its operands are in reverse order from Intel's documentation.)

A manual is hosted online at sourceware.org as well as a possible locally installed version matching the GAS in use.


This tag was formerly called [gas], renamed because lots of Google Apps Script questions were getting mistagged as gas.

1024 questions
-1
votes
1 answer

How do I get a register to store an offset value in at&t syntax?

I am using this to write to the video memory (%es = 0xb800): movw $0x074b,%es:(0x0) However, what if I want the offset to be in %ax? I tried %es:%ax, or %es:(%ax), but nothing worked, and I kept getting errors. What am I doing wrong?
francisaugusto
  • 1,077
  • 1
  • 12
  • 29
-1
votes
1 answer

ARM11 bad instruction `num resb 5' Assembly

Attempting to compile the following in order to read a 5 byte char from stdin: .bss num resb 5 .text .global _start _start: mov r0, $1 mov r1, num mov r2, $5 mov r7, #3 swi $0 Via the following as -o…
Jacob Clark
  • 3,317
  • 5
  • 32
  • 61
-1
votes
1 answer

Any equivalent function of ARM's ldrb in x86 gas syntax?

I'm looking to load a string byte by byte to check for a null value that signifies the termination of that string in x86. I had prior done this in ARM using ldrb as such: loop: ldrb r1, [r0], #1 //Load next byte of string into r0 cmp …
user3210373
  • 33
  • 1
  • 1
  • 3
-1
votes
1 answer

What Linux does when I make write system call?

I'm a newbie for Linux, for assembly programming (GAS) and for English. So, sorry if I write something wrong. I hope Google Translate will help me enough to write it all not too bad. I want to know how to write a set of numbers, stored in section…
-1
votes
1 answer

I cant traduce this chunk of GAS code to INTEL/NASM syntax

in this code: #define G(gi1, gi2, x, t0, t1, t2, t3) \ lookup_32bit(t0, t1, t2, t3, ##gi1, RGS1, shr_next, ##gi1); \ lookup_32bit(t0, t1, t2, t3, ##gi2, RGS3, shr_next, ##gi2); \ \ lookup_32bit(t0, t1, t2, t3, ##gi1, RGS2, dummy, none); …
mimini
  • 19
  • 2
-1
votes
1 answer

How do use a memory location?

I have written a code for example .global _start .data str: .long 0x1 .text _start: mov $1, %rax # system call 1 is write mov $0x21, %rdx mov %rdx, 4(%rax) mov $60, %rax # system call 60 is exit xor %rdi, %rdi …
volkov
  • 117
  • 3
  • 13
-2
votes
1 answer

Correct LDR Rd,=constant_expression usage in GCC / GAS?

I'm migrating from Ride7 to Eclipse CDT with GNU arm-none-eabi toolchain. In my project, I have a hardware register description library using .equ directive in a way like: .equ BIT_31, 1 << 31 .equ BIT_30, 1 << 30 and so on up to .equ BIT_0, 1 <<…
jozi
  • 3
  • 2
-2
votes
1 answer

operand size for "out"

I'm using the GAS assembler. I'm trying to write to the I/O port 0x20, I do it like this: outb $0x20, $0x20 But I get this error: Error: operand type mismatch for out What am I doing wrong?
-2
votes
1 answer

Segmentation fault: 11 With Array Assignment in Loop Using x86 GNU GAS Assembly

This question is similar to another question I posted here. I am attempting to write the Assembly version of the following in c/c++: int x[10]; for (int i = 0; i < 10; i++){ x[i] = i; } Essentially, creating an array storing the values 1 through…
Ajax1234
  • 69,937
  • 8
  • 61
  • 102
-2
votes
1 answer

scanf a string and print strlen in assembly gas 64-bit

I am trying to write a strlen function in assembly using 64-bit GAS. I need to get an input string from the user, and print its length. This is my code: .lcomm d2, 255 .data pstring1: .ascii "%s\0\n" .text .globl main main: movq %rsp, %rbp …
-2
votes
3 answers

Porting from Windows to Linux. Assembler command translation

I have recently started learning porting from Windows to Linux. I've been translating program from Intel syntax to AT&T syntax also converting it from x32 to x64. And since I'm new enough to assembler and especially AT&T I've faced some troubles…
Random Guy
  • 1,095
  • 16
  • 29
-2
votes
1 answer

converting from intel assembly to gas/at&t

so can someone just do this tranlation for me? from intel assembly to at&t assembly? I'm learning gas syntax but having a little difficulty understanding some petty things... mov ecx, dword ptr[esp + 0xC + 0xC]
-2
votes
1 answer

Read & write and integer in assembly ATT

I have been trying to to read an integer from stdin and after write it in stdout, but the only thing that I accomplish is writing a simply hello world. This is the code that I have: .global _start _start: push %ebp movl %esp,%ebp subl $4,%esp…
Miguel
  • 1
  • 5
-2
votes
1 answer

Meaning of assembly instructions

I am working my way through http://www.amazon.com/Assembly-Language-Step-Step-Programming/dp/0470497025. Currently, I'm trying to move some of the code around so that I can compile with GAS, instead of NASM (the book's default compiler), and I'm…
-3
votes
2 answers

Calling Assembly from C compile error gcc

Trying to run assembly in C, but won't compile with gcc main.c #include #include "assem.s" void extern testing(int * a); int main(){ int b = 8; int * a = &b; testing(a); printf("%d",*a); } assem.s .globl…
Rambos
  • 3
  • 1
1 2 3
68
69