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
0
votes
1 answer

I cannot understand the following gnu assembly code for powerpc architecture

#define START_GOT \ .section ".got2","aw";\ .LCTOC1 = .+32768 Is .LCTOC1 is a directive? Why is there a . before +32768?
Zhang Baolei
  • 95
  • 1
  • 10
0
votes
1 answer

Why do I get segmentation fault?

I compile code gcc -g3 hello3.s -o hello .data ssttrr: .string "%d\n" .text .globl main main: mov $213, %rdx push %rdx push $ssttrr call printf add $8, %rsp mov $60, %rax xor %rdi, %rdi syscall I understand error but i don't…
volkov
  • 117
  • 3
  • 13
0
votes
2 answers

How do a library function (C) call on gnu assembly language?

I compile a code. .data ssttrr: .string "%d\n" .text .globl main main: mov $213, %rdx push %rdx push $ssttrr call _printf add $8, %rsp or it .global main .text main: push %rax # caller-save register push %rcx …
volkov
  • 117
  • 3
  • 13
0
votes
1 answer

Convert 32-bit program to 16-bit program

Assembler throws error for my 16 bit code movzbw (%ax), %ax Error: `(%ax)' is not a valid base/index expression But the below instruction is valid on 32 bit code generation. movzbl (%eax), %eax Environment: Processor: Intel(x86) Assembler: "GNU…
user1103973
0
votes
2 answers

SIGSEGV When accessing array element using assembly

Background: I am new to assembly. When I was learning programming, I made a program that implements multiplication tables up to 1000 * 1000. The tables are formatted so that each answer is on the line factor1 << 10 | factor2 (I know, I know, it's…
user837703
0
votes
2 answers

GAS assembly snippet divides by 0, not sure why

I have the following function, involving a snippet of i386 assembly in GAS syntax: inline int MulDivRound( int nNumber, int nNumerator, int nDenominator ) { int nRet, nMod; __asm__ __volatile__ ( "mov %2, %%eax …
benwad
  • 6,414
  • 10
  • 59
  • 93
0
votes
1 answer

x86 assembly short and long size

I'm writing a little x86 program and I'm surprised about "types" size. .short are handling 4 bytes values such a .short 0xFFFF and .long 8 bytes, while .bytes are handling 2 bytes. I can't find an explaination, what I'm doing wrong?
Tempax
  • 139
  • 2
  • 6
0
votes
0 answers

show the difference in the opcodes for different architectures

I have the script which (as intended) allows me to see the difference in the opcodes generated for the different architectures (especially intrested in x87 instructions on x86 vs x86_64). #!/usr/bin/env bash cat - <<__EOF> a.cpp int main() { …
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
0
votes
2 answers

Assembly .byte array

I've defined a byte array using .data letters : .byte 0:26 And i've got some questions : 1 ) Is the first cell in the array available for use, or its employed for other purpose? 2 ) How can I load the 6 ( for example ) cell of the array…
Itamar
  • 524
  • 1
  • 9
  • 21
0
votes
1 answer

3 or 4 parameter x86 assembly in AT&T syntax

Simple question. I doubt this will receive much attention, but how do I do 3 or 4 parameter operations in x86-64 assembly in AT&T (gAS) syntax? It's known to any x86 programmer using gAS that the arguments are switched, for example: xor eax, ebx…
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
0
votes
1 answer

Wrong result from assembly program

Can someone help me find what is wrong with the following program? I'm reading 'Programming from the Ground Up' and attempting to translate the examples into x86-64 assembly. The following program finds the largest number in a set of data. But when…
Cole Rowland
  • 149
  • 5
0
votes
1 answer

Using GNU Assembler to dynamically create a struct and returning a pointer to it

Using the GNU Assembler I'm trying to call malloc to create a C struct, insert values into that struct and return a pointer to that struct. Below is the struct: struct node { void *next; void *last; char *name; …
User4679
  • 111
  • 3
  • 12
0
votes
2 answers

WebRTC in iPhone (gas-preprocessor issues)

I'm trying compile the lastest WebRTC version for iPhone. I not need to compile the entire solution, I only need to compile the VAD module. To do that, I have created a Xcode project and I have tried to compile the source necessary, but I have a…
Chris
  • 327
  • 2
  • 6
  • 22
0
votes
1 answer

Print .ascii declaration using Lodsb or just mov

I'm writing this bootloader that just prints out some stuff on the screen. This is what I have so far in assembly: .globl _start .code16 _start: movw $0x0003, %ax int $0x10 movb $0x0e, %ah movb $0x69, %al int $0x10 …
KrisSodroski
  • 2,796
  • 3
  • 24
  • 39
0
votes
1 answer

Adding two numbers in GAS

I'm new to GAS assembly here, my goal is to display the sum of the added two numbers that were entered by the user. I used char to number conversion and vice-versa and the results is always wrong (non-numeric). Can somebody tell me where's the…
oLraX
  • 217
  • 4
  • 14