gas

GCC inline assembler, mixing register sizes (x86)

Does anyone know how I can get rid of the following assembler warning? Code is x86, 32 bit: int test (int x) { int y; // do a bit-rotate by 8 on the lower word. leave upper word intact. asm ("rorw $8, %0\n\t": "=q"(y) :"0"(x)); return y; } If I compile it I get the following (very valid) warning: Warning: using `%ax' instead...

Splitting a string on AT&T IA-32 Linux Assembler (gas)

.section .data astring: .asciz "11010101" format: .asciz "%d\n" .section .text .globl _start _start: xorl %ecx, %ecx movb astring(%ecx,1), %al movzbl %al, %eax pushl %eax pushl $format call printf addl $8, %esp movl $1, %eax movl $0, %ebx int $0x80 Suppose I wanna break the .asciz string 1101011 and get it's first one. How do I...

creating a substring on Linux IA-32 assembler (gas)

I wanna create a substring (ministring) of 3 asciz chars out of my original (thestring). The thing ain't printing when being run so I don't know what the hell I'm I doing. Why it ain't printing? Am I creating the ministring correctly? .section .data thestring: .asciz "111010101" ministring: .asciz "" formatd: .asciz "%d" formats:...

Algorithm for modeling expanding gases on a 2D grid

I have a simple program, at it's heart is a two dimensional array of floats, supposedly representing gas concentrations, I have been trying to come up with a simple algorithm that will model the gas expanding outwards, like a cloud, eventually ending up with the same concentration of the gas everywhere across the grid. For example a giv...

[gcc generated assembly] .comm?

I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; } to assembly using gcc producing, .cstring LC0: .ascii "Hello, World!\0" .text .globl _main _main: pushl %ebp movl %esp, %eb...

Threads in x86 assembler (using the GNU assember: as)

Whilst learning the "assembler language" (in linux on a x86 architecture using the GNU as assembler), one of the aha moments was the possibility of using system calls. These system calls come in very handy and are sometimes even necessary as your program runs in user-space. However system calls are rather expensive in terms of performanc...

How to translate NASM "push byte" to GAS syntax?

Why I'm "porting" a NASM source to GAS and I found the following lines of code: push byte 0 push byte 37 GAS doesn't allow "push byte" or "pushb". How should I translate the above code to GAS syntax? Thanks ...

Where can I find an interrupt list for i486-linux-gnu instruction set?

I am developing a compiler for my senior project in school, and I am using AS (GNU Assembler) to assemble. All of my tests have been fairly successful, but no interrupt lists I have seen have seemed to work or match up with my test code. The relevant information for this version of AS: GNU assembler 2.17 Debian GNU/Linux Copyright 2005...

documentation of gnu assembler directives

I'm trying to learn mips assembly at the moment. To that end, I wrote a very simple c program... int main(){} ...and compiled it on a mips machine with the -S option to gcc to generate assembly code. Here is what the beginning of the main function looks like: .ent main main: .frame $fp,8,$31 .mask 0x40000000,-8 .f...

gas vs. nasm: which assembler produces the best code?

Both tools translate assembly instructions directly into machine code, but is it possible to determine which one produces the fastest and cleanest code? ...

x86 Assembly, misleading Error

I am trying to learn assembly, and have a program in AT&T syntax, for use with GNU AS Which I believe should work. I receive this error with GDB: Program received signal SIGSEGV, Segmentation fault. .PROGRAM () at concatenator.s:60 60 call strlen Current language: auto; currently asm The code is: .file "concatenator....

Memory adressing in asm

Hi, I'm learning asm and here's one of my (many) problems : I'd like to change the value of some index of an array. Let's say that : %eax contains my new value the top of the stack (ie (0)%esp) contains the index of the array -4(%ebp) contains the adress of the array. I've tried movl %eax, (-4(%ebp),0(%esp),4) but it did not work. ...

ljmp syntax in gcc inline assembly

I was thinking of using a far jump to set the code segment (CS) register. Getting into why I'm doing this and why I'm dealing with segmentation at all would take a while, so bear with me and consider it an academic exercise. I can't seem to get the syntax right. Error: suffix or operands invalid for 'ljmp' I know it's foolish to put c...

Installing GNU Assembler in OSX

No matter how hard I google, I can't seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac. Any pointers would help. Thanks. ...

How can I jump relative to the PC using the gnu assembler for AVR?

I have a binary file that I've disassembled using avr-objcopy. The interrupt vector table looks like: 00000000 : ; VECTOR TABLE 0: 13 c0 rjmp .+38 ; 0x28, RESET 2: b8 c1 rjmp .+880 ; 0x374, INT0 4: fd cf rjmp .-6 ; 0x0 6: fc cf rjmp .-8 ; 0x0 8: fb cf ...

MOV src dest (or) MOV dest src?

MOV is probably the first instruction everyone learns while learning ASM. Just now I encountered a book Assembly Language Programming in GNU/Linux for IA32 Architectures By Rajat Moona which says: But I learnt that it is MOV dest, src. Its like "Load dest with src". Even Wiki says the same. I'm not saying that the author is wrong. I...

Effect of suffixes in memory to cache operations

In x86 GNU Assembler there are different suffixes for memory related operations. E.g.: movb, movs, movw, movl, movq, movt(?) Now my question is the following: Does the suffix has ANY effect on how the processor is getting the data out of main memory or will always be one or more 32-bit (x86) chunks loaded into the cache ? What are t...

What are CFI directives in Gnu Assembler (GAS) used for?

There seem to be a .CFI directive after every line and also there are wide varities of these ex.,.cfi_startproc , .cfi_endproc etc.. more here. .file "temp.c" .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16...

gas: too many memory reference

when compiling the instruction movl 4(%ebp), 8(%ebp) i got 'too many memory referene', what's wrong with it?? ...

What is register %eiz?

In the following assembly code that I dumped out using objdump: lea 0x0(%esi,%eiz,1),%esi What is register %eiz? What does the preceding code mean? ...