problem about gas-Collection of common programming errors


  • Phonon
    assembly gas
    I would like to get the address of a variable and’ed by 4096 (which would correspond to the address of its memory page). Since this is something that can be computed offline I did something that looks like this (v is the variable and vpage should contain the address of its page):.datav: .zero 0x100vpage: .long v & 0xfffff000Trying to compile this file with the x86 assembler results in the following error:test.S: Assembler messages: test.S:3: Error: invalid sections for operation on `

  • Phonon
    assembly mono ld gas
    I created a simple mono executable using MonoDevelop that prints “hello world”. I wanted to try the AOT ‘asmonly’ option. So: [root@localhost Debug]# ls abc.exe [root@localhost Debug]# mono –aot=full,static,asmonly abc.exe Mono Ahead of Time compiler – compiling assembly /home/alon/Projects/abc/abc/bin/Debug/abc.exe Code: 1538 Info: 50 Ex Info: 114 Class Info: 30 PLT: 5 GOT Info: 105 GOT Info Offsets: 24 GOT: 60 Output file: ‘/home/alon/Projects/abc/abc/bin/Debug/abc.exe.s’. Linking symbol: ‘mo

  • Soybean
    assembly inline-assembly gas segments
    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 cs into another register, but I figured I’d try it since using %0 wasn’t working (the ax register doesn’t work either). I’m looking at some code that compiles fine an

  • Bob Blogge
    assembly x86 nasm gas opcode
    the assembly code is mov eax, 0x3a14a5 jmp eaxGAS produces an opcode of 0xB8, 0xA5, 0x14, 0x3A, 0x00 0xFF, 0xE0while NASM produces and opcode of 0x66, 0xB8, 0xA5, 0x14, 0x3A, 0x00 0x66, 0xFF, 0xE0So you see NASM preappends a 0x66 before the code. Within my program (which I won’t go into details about), the GAS opcode works correctly, and the NASM code causes a crash indicating that these two opcodes are not equal. Why does NASM preappend the 0x66 and how can I get rid of it?update: The bits

  • batman
    assembly x86 gas att
    Please give me a very simple example of creating a function and calling it in x86 Assembly (AT&T syntax). Actaully I am trying to create a function that computes factorial of a number. This is what all I did :#include<syscall.h> #include<asm/unistd.h> # Calculates Factorial, Argument is passed through stack .text .global _start _start:pushl $5 #factorial of this value will be calculatedcall Factmovl %eax, %ebx #eax contains the result, Result is the return val of the progra

  • nrz
    assembly x86 gas divide-by-zero i386
    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 \n””mull %3 \n””divl %4 \n””mov %%eax, %0 \n””mov %%edx, %1 \n”: “=m” (nRet),”=m” (nMod): “m” (nNumber),”m” (nNumerator),”m” (nDenominator): “eax”, “edx”);return nRet + nMod*2 / nDenominator; }I’ve noticed that, in

  • R..
    c linux assembly gas
    I’m trying to use a function in assembly in a C project, the function is supposed to call a libc function let’s say printf() but I keep getting a segmentation fault.In the .c file I have the declaration of the function let’s sayint do_shit_in_asm()In the .asm file I have.extern printf .section .dataprinttext:.ascii “test” .section .text .global do_shit_in_asm .type do_shit_in_asm, @functiondo_shit_in_asm:pushl %ebpmovl %esp, %ebppush printtextcall printfmovl %ebp, %esppop %ebp retAny pointers co

  • volkov
    assembly x86-64 gas
    I compile a code..data ssttrr: .string “%d\n” .text .globl main main: mov $213, %rdx push %rdx push $ssttrr call _printf add $8, %rspor it.global main.text main:push %rax # caller-save register push %rcx # caller-save registermov $format, %rdi # set 1st parameter (format) mov %rax, %rsi # set 2nd parameter (current_number) xor %rax, %rax # because printf is varargs call printf # print

  • Hudson Worden
    c linux assembly ld gas
    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 %ebpmovl %esp, %ebpmovl $0, %ecxmovl 8(%ebp), %edx read_next_byte:movb (%edx), %alcmp

  • user1454902
    gcc gas
    I need to access an argument from a C functionvoid printk(char* msg);and store it into ESI. However I can not domov $msg, %esiormov $_msg, %esiBoth return a linker error (Saying that the symbol msg or _msg is undefined. I am pretty sure I could access msg by reading from the stack but it would be easier just to access the symbol msg in my assembly code. Is this even possible in GCC?

  • Phonon
    linker embedded arm ld gas
    I’m writing a boot script for an ARM-Cortex M3 based device. If I compile the assembler boot script and the C application code and then combine the object files and transfer them to my device everything works.However, if I use ar to create an archive (libboot.a) and combine that archive with the C application there is a problem:I’ve put the boot code in a section:.section .boot, “ax”.global _start_start:.word 0x10000800 /* Initial stack pointer (FIXME!) */.word start.word

Web site is in building