Questions tagged [assembly]

Assembly language questions. Please tag the processor and/or the instruction set you are using, as well as the assembler, a valid set should be like this: (assembly, x86, gnu). Use the [.net-assembly] tag instead for .NET assemblies, [cil] for .NET assembly language, and for Java bytecode, use the tag java-bytecode-asm instead.

40,661 questions
0votes
0answers
13views

cmpxchgl opcode: when did EAX get loaded in this code example?

I understand that the cmpxchgl opcode compares an operand with the accumulator. In this asm statement the accumulator doesn't seem to be loaded before the lock. How did the accumulator get loaded with ...
0votes
0answers
25views

Assembly code for C++ virtual function call in perf report?

I'm doing some profiling for virutal function call performance and when read the perf report, I got this: mov (%rbx),%rdi # move "this" pointer to %rdi mov (%rdi),%rax # move vtable ...
0votes
0answers
18views

Is there a tag or remark feature in arm assembly for debugging?

It's a bit of a silly questions... Is there a tag or remark system in arm-gcc compiler? To figure out how to arm compiler interpret instructions. For example if i mark something in the code such as... ...
0votes
1answer
20views

Reading number and change it into a binary

So I have a practice exam for assemblyx86 language Write a void function, encryptStr(), that will encrypt a string. To encrypted the string, simply add one to each alphabetic (upper and lower case ...
0votes
0answers
20views

ARM equivalent of x86 Heaven's Gate

It's possible to mix 32-bit and 64-bit x86 code in the same process by changing the code segment between 0x23 and 0x33, like this: BITS 32 ; do 32-bit stuff call 0x33:foo ; do more 32-bit stuff BITS ...
2votes
2answers
29views

Segmentation fault when calling printf from C, after executing some x64 assembler

I tried to implement the quicksort in x86-64 Assembler, on Linux. Since I'm not fully comfortable with it yet, I wrote the partition algorithm in C. It seems to work but something must be off, because ...
0votes
0answers
24views

How does supervisor mode address translation get done? [duplicate]

Intel System Programming manual vol. 3 clearly documents that 4-level paging uses the first 48 bits of the virtual address to get the actual physical address. When connecting to the Linux Kernel with ...
0votes
1answer
23views

difference between simple ret and _exit function in nasm x8664

I have been in pain for the last couple of days with x8664 assembly (using nasm on macOs). I’d like to show two pieces of code So let’s say that I have an array and I want to print it. This is the ...
1vote
1answer
40views

Optimal bit twiddling for the One's complement absolute value operation on modern x86 processors

The fastest way to compute the absolute value of a twos complement number is a common enough operation that optimized implementations are widely available. So let's consider another case. What if we ...
0votes
0answers
24views

Problem with Assembly (EMU8086): It doesn't print the right value

I have this problem: when i try to compile and execute the code with emu8086 it doesn't print the right value but it prints the values 0. I don't understand why. Can someone explain me the reason? ...
0votes
1answer
30views

finding out if there is a pair of elements in the array that sums to exactly K

i am trying to write a for loop using MARIE that can find a pair of integers that sum to k. then it must output the index of the two numbers that add up to k. For Example: Input: [3, 7, 11, 5, -2, 1] ...
-1votes
0answers
30views

How is the short jump instruction encoded in x86? [duplicate]

I've been messing around with some low-level stuff, like small compilers and simple bootloader programs. I'm trying to figure out how the operands of jump instructions are encoded in binary, ...
0votes
0answers
36views

The value is weird after using `.int` or `.long` initialize data in data section [duplicate]

I know .int and .long occupy 4 bytes, and I should use movl. But what is the like 0x20, 0x30, 0x40, 0x2c? It's dirty data? .section .data iary: .int 1, 2 lary: .long 3, 4 .section .text ....
2votes
0answers
38views

What happens on ARM when double to int64_t conversion overflows?

With x86 you get the magic value 1 << 63 (MSB set, rest clear, i.e. the most-negative number, which Intel calls the "integer indefinite" value) when you convert a double to an int64_t ...
0votes
0answers
30views

Why can `%rip + displacement` access data section? [duplicate]

The usage of this is that I saw after used gcc -S. I know ary represents the first address of the sequence, then I also know leaq ary(, %rdi, 4) has the same effect(assume %rdi equals 0). But I don't ...

153050per page