gas

What does .comm mean?

丶灬走出姿态 提交于 2019-12-01 15:20:37
问题 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, %ebp pushl %ebx subl $20, %esp call L3 "L00000000001$pb": L3: popl %ebx leal LC0-"L00000000001$pb"(%ebx), %eax movl %eax, (%esp) call L_puts$stub movl $0, %eax addl $20, %esp popl %ebx leave ret .comm

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

偶尔善良 提交于 2019-12-01 11:29:15
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 rjmp .-10 ; 0x0 a: fa cf rjmp .-12 ; 0x0 c: f9 cf rjmp .-14 ; 0x0 e: f8 cf rjmp .-16 ; 0x0 10: f7 cf rjmp .-18 ; 0x0 12: c7 c1 rjmp .+910 ; 0x3a2, TIMER1 OVF 14: f5 cf rjmp .-22 ; 0x0 16: f4 cf rjmp .-24 ; 0x0 18: f3 cf rjmp .-26 ; 0x0 1a: f2 cf rjmp .-28 ; 0x0 1c: 2b c2 rjmp .+1110 ; 0x474, ADC conversion complete 1e: f0 cf rjmp .-32 ; 0x0 20:

GCC inline assembler, mixing register sizes (x86)

你离开我真会死。 提交于 2019-11-30 17:55:19
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 of `%eax' due to `w' suffix What I'm looking for is a way to tell the compiler/assembler that I want to access the lower 16 bit sub-register of %0. Accessing the byte sub-registers (in this case AL and AH) would be nice to know as well. I've already chosen the "q" modifier

Why does switching from AT&T to Intel syntax make this tutorial segfault using GAS?

强颜欢笑 提交于 2019-11-30 13:04:35
I'm working through some of the tutorials on http://www.ibm.com/developerworks/linux/library/l-gas-nasm/index.html to familiarize myself with x86/x64. This tutorial code compiles and runs without a hiccup using the provided code, which uses AT&T syntax: .global main .text main: # This is called by C library's startup code mov $message, %rdi # First integer (or pointer) parameter in %edi call puts # puts("Hello, World") ret # Return to C library code message: .asciz "Hello, World" # asciz puts a 0x00 byte at the end However, when I convert this code to Intel syntax, I get a "Segmentation fault"

How to link a C object file with a Assembly Language object file?

大憨熊 提交于 2019-11-30 12:42:20
I am having trouble linking 2 object files one of which was generated from an Assembly Language Source File and another that was generated from a C Source file. C source code: //main2.c extern int strlength(char *); int main(){ char * test = "hello"; int num = strlength(test); return num; } Assembly source code: #strlength.s .include "Linux32.s" .section .text .globl strlength .type strlength, @function strlength: pushl %ebp movl %esp, %ebp movl $0, %ecx movl 8(%ebp), %edx read_next_byte: movb (%edx), %al cmpb $END_OF_FILE, %al jle end incl %edx incl %ecx jmp read_next_byte end: movl %ecx,

MOV src dest (or) MOV dest src?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 11:06:34
问题 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: alt text http://i.imagehost.org/0897/mov.gif 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 know that he is right. But what am I missing here? btw.. he is using GCC's as to assemble these instructions. But

GCC not saving/restoring reserved registers on function calls

天大地大妈咪最大 提交于 2019-11-30 09:33:17
问题 I have a scenario in GCC causing me problems. The behaviour I get is not the behaviour I expect. To summarise the situation, I am proposing several new instructions for x86-64 which are implemented in a hardware simulator. In order to test these instructions I am taking existing C source code and handcoding the new instructions using hexidecimal. Because these instructions interact with the existing x86-64 registers, I use the input/output/clobber lists to declare dependencies for GCC. What's

Translation from NASM to GAS

非 Y 不嫁゛ 提交于 2019-11-30 08:52:16
问题 how do I translate mov [ebx], al from NASM to GAS? I tried mov %al, (%ebx) but it does segmentatiob fault. Another question, lets say I have an array in GAS .lcomm array, 50 Do I have to put a dollar($) sign in array like this: mov %rbx, $array or need not to? Any answer would be helpful :) 回答1: How about intel2gas? usage: intel2gas [options] [-o outfile] [infile] where options include: -h this help -i convert from intel to at&t format (default) -g convert from at&t to intel format -m -t

GCC inline assembler, mixing register sizes (x86)

限于喜欢 提交于 2019-11-30 02:42:29
问题 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 of `%eax' due to `w' suffix What I'm looking for is a way to tell the compiler/assembler that I want to access the lower 16 bit sub-register of %0. Accessing the byte sub

NASM Vs GAS (Practical differences)

a 夏天 提交于 2019-11-29 20:48:13
I'm not trying to prompt an Intel vs AT&T war (moot point anyway, now that they both support Intel syntax) or ask which one is "better" per se, I just want to know the practical differences in choosing one or the other. Basically, when I was picking up some basic x86 assembly a few years back, I used NASM for no reason other than the book I was reading did too -- which put me firmly but involuntarily in the NASM camp. Since then, I've had very few causes to use assembly so I haven't had the opportunity to try GAS. Bearing in mind that they both support Intel syntax (which I personally prefer)