All Questions
Tagged with assembly gnu-assembler
911
questions
0
votes
2
answers
56
views
RISC V : I don't understand what the GNU assembler does with labels in the .data segment
I am making my own risc V core as a personal project using the RV32I ISA, I am using a Harvard memory architecture meaning I have a program memory that starts at address 0x0 and a separate data memory ...
1
vote
0
answers
66
views
Assembling with gcc gives error operand type mismatch for `cmp' for some integers, not others
This is a weird one. I'm using gcc to assemble a program and I want to know if the value in register rsi fits in 32 bits, so I use this instruction:
cmpq $0xffffffff, %rsi
I get back an error that ...
2
votes
0
answers
67
views
Ways to perform bitwise operations with symbols inside Assembly constants?
I am working on learning to write ARM firmware and am trying to create a Vector Table. I am using the GNU toolchain.
I have assembly code like the following:
MY_VECTOR_TABLE:
.long 0 ...
0
votes
1
answer
37
views
Why LI becomes LBU opcode after MIPS assembler
I'm trying to assemble code for MIPS R2000 (MIPS I ISA).
I'm using LI pseudo instruction to initiate a register. After running the assembler on the following code:
li $v1, 1
The binary .text ends up ...
2
votes
2
answers
61
views
AVR instructions LDS and STS 16 bit versions with GNU assembler
the AVR 8bit core instruction set includes the more efficient 16bit versions of the "load data from memory" (LDS) and "store data to memory" (STS) instructions, as opposed to the ...
2
votes
1
answer
74
views
GNU as: when to use '$'
After a long time I have to use the GNU assembler again. Ever since I had trouble with the '$'.
The manual just says:
3.6.2.1 Integers
A decimal integer starts with a non-zero digit followed by zero ...
1
vote
1
answer
51
views
If-Else in assembly doesn't seem to work or I'm doing smth wrong
.section .note.GNU-stack,"",@progbits
.section .data
cf_msg:
.string "CF = %d\n"
of_msg:
.string "OF = %d\n"
sf_msg:
.string "SF = %d\n"
less_msg:
.string &...
1
vote
1
answer
37
views
How to change a single bit of an address at assemble time?
Arch is SuperH. I have some variables specified like this:
buffer_address: .long buffer
buffer: .zero 1024
However, for certain buffer reads, I need to read as cache-through. The way to do that on ...
1
vote
0
answers
48
views
GAS with AT&T syntax - creating a label by concatenating a variable of a macro
I have an assembly code that generates ISR (interrupt service routine) stubs. I want to automate this process, and for each of the interrupts (there are 256) generate it's own unique stub. This is ...
2
votes
1
answer
36
views
GNU Assembler identifier concatenation inside macro
I want to append a string to a macro argument in gcc assembler. Here is what I have currently:
The following macro to embed a file in my code which works just fine:
.macro add_resource resource_name, ...
2
votes
0
answers
48
views
Fastest "shift and duplicate" operation
Arch is SuperH, specifically SH-2. I don't know the name of this operation, but I have been calling it "shift and duplicate". Effectively what I am looking for is:
0x0000AB12 -> ...
1
vote
1
answer
112
views
How to determine which x86 memory operand width and type is used from an asm listing?
There are several versions of the same instruction: IDIV M32, IDIV R32, IDIV M64, IDIV R64 (https://www.felixcloutier.com/x86/idiv)
How to understand which one is used? Let's say
vdiv(std::vector<...
0
votes
1
answer
53
views
cannot find entry symbol _start when trying to link c main with assembly function
Can read assembly but trying to learn to write small functions in it, but I can't seem to link a main written in C that calls an extern function written with gas. The target is linux x64.
Here is main....
1
vote
0
answers
31
views
x86_64 - Using GDB on a code assembled with GAS causing strage error
I have this code written in Assembly x86_64:
.section .data
.equ SYS_CALL, $0x80
.set filename, "a.txt"
.section .text
.section .bss
.lcomm buffer, 20
.globl _start
_start:
mov $1,%rbx ...
0
votes
1
answer
17
views
GNU AS ASM to bytecode dump
Some time ago I created this function to dump a bytecode given an ASM instruction:
show_bytecode(){ echo "$@" | as -o temp.o && ld --oformat binary -o temp.bin temp.o 2>/dev/null &...