FAQ Database Discussion Community


GNU GAS: Label is not relatively referenced

assembly,linker,nasm,boot,gas
I am writing a little bootsector for learning purpose. Here is boot.S .code16 .text movw $0xB800, %ax /* 0xB000 is the text screen video memory */ movw %ax, %es /* set it as the %es segment */ movb label, %al movb %al, %es:0x0 /* screen[0] = 'A' */ movb $0x07,...

Using gas, how can I get the offset to a particular label?

assembly,gas
I'm using pwnlib to write a small shellcode for a challenge. My shellcode needs to modify itself to pass application filters. I first wrote it with nasm, and did something like that: sub edx, edx mov dl, 0x82 add al, do_mov_rdi_rax sub dword [rax], edx mov dh, 0x82 add al,...

System calls in GAS

assembly,system-calls,gas
I'm trying to create a folder in 64 bit GNU as like this: .global main .text main: movl $83, %edi # SYS_mkdir movl $folder, %esi # folder_name movl $0777, %edx # flags call syscall ret # exit folder: .string "folder" this code works, however I'd rather implement it using the...

Gnu assembler gives unexpected memory operand

assembly,x86-64,gnu,gas,yasm
The GNU assembler gives an unexpected memory operand when assembling Intel syntax code. I have reduced my bug to one single lonely line of code, and for the last three days I've tried anything to understand why the GNU assembler yields something that I cannot understand. I know this must...

How do I force GAS to generate output identical to input?

c,optimization,mips,gas
I want to write code that has a public C interface, but is otherwise implemented entirely in MIPS, mainly as a learning exercise. However, I'm stuck fighting GAS because it seems to assume it knows better than I do. To illustrate, let's say I want to implement the following in...

Assembly 64bit - movl, movq. Interchanging is okay?

assembly,64bit,x86-64,gas,instructions
Context: Learning GAS assembly on 64 bit linux. Many tutorials are for 32-bit assembly. Difficult to bushwhack through x86_64 assembly. Question: When I compile a c program with gcc, I still see some %eax and movl. I mostly play with int32_t. But I thought that one had to use the...

Error: Junk at EOL, first unrecognised character is '('

assembly,gas,quake
I am trying to compile Quake 1 (QW) from source code and have run into the following problem when compiling client/d_copy.s : Error: Junk at EOL, first unrecognised character is '('. The file in question is here (please excuse the syntax highlighting, pastebin only supports NASM). I am attempting to...

Substituting for a .SET on the the command line

gcc,assembly,gas,microblaze
I have some (Microblaze) assembly I need to build (via the GCC cross-assembler and linker) and execute many times with the (same) constants, currently fixed via .SET commands, changed each time. Is there a way to automate the setting of in-assembly constants in this way and so avoid the dull...

Excluding GNU as (GAS) standard startup code [closed]

c,gcc,gnu,gas,gnu-arm
I want the GCC to exclude the startup code it link automatically with building process what should i do? So that i have my Own Startup assembly code defining labels (_start, _exit,..etc)...

How to repeat an instruction in GNU assembler on Xcode 6.1.1?

xcode,assembly,gas
I'm trying to compile a code using Xcode6.1.1(I guess with GNU assembler), with target to iPad air2(aarch64) .macro saving_callee_prsv_regi used_regi_index .if \used_regi_index >= 19 i = 19 .rept \used_regi_index - 19 str x\i,[sp,#-8*(\i-18)] // fail here: x\i i = i + 1 .endr .endif .endm But above code compile failure....

Assembly - extract specific bit

assembly,x86,gas,att
I want to extract 17th bit from my 32bit (int) value. Am I doing this right? I'm using AT&T syntax. movl $0x11112222,%eax movb $0b01000000,%bl andb %ah,%bl I put 32bit number into 32 bit register. Now 17th bit is in ah register (as well as other 16-23 bits). Now as it...

why aarch64 force qword aligned even transferred size is dword?

xcode,assembly,gas,arm64
Below assembler code will cause "exc_bad_access code=259" on Xcode6.1.1 target on iPad air2. // SP default 16 aligned on function entry, sub sp,sp,#8 st1 {v8.1d},[sp],#8 while new version will not sub sp,sp,#16 st1 {v8.1d},[sp],#8 I find ARMv8_ISA document mention "aligned" on chapter $3:unaligned address are permitted for most loads and...

Protected mode, setting segment registers

assembly,operating-system,gas,protected-mode
I'm recently playing with gnu-assembler in simple os development. I'm using code below to switch CPU to protected mode. In order to do this I set GDT as follow and performed far jump to given label wit 0x08 as GDT offset (to set CS). CPU did not reset itself after...

Assembler char Output

assembly,gas
At the moment I'm working a bit with the Assembler language. I want to print a char to the console and my program runs without errors but it comes to no output. Here is my current code: movl $4, %eax #Defines Output movl $1, %ebx #STDOUT as first parameter movl...

Segmentation fault in x86 example program

assembly,x86,segmentation-fault,ld,gas
I'm reading this book Programming From the Ground Up, Jonathan Bartlett. On this program that shows the function calling conventions for the first time I'm getting a segmentation fault when running it after typing it just like in the book. The function just takes 2 numbers from the stack, and...