x86-64 Questions

6

I read that a 64-bit machine actually uses only 48 bits of address (specifically, I'm using Intel core i7). I would expect that the extra 16 bits (bits 48-63) are irrelevant for the address, and w...
Ruelas asked 24/4, 2013 at 17:40

3

I'm working through Computer Systems, A Programmer's Perspective (3rd edition), and Practice Problem 3.3 contains the following line: movb $0xF, (%ebx) I'm supposed to find out what's wrong with...
Rowen asked 26/7, 2015 at 2:32

1

Solved

I already learned that on the x86-64 platform using any 64-bit register would need a REX prefix, and any address less than 64 bits would require an address-size prefix. On x86-64 bit: E3 rel8 is jr...
Donothing asked 1/10, 2023 at 9:4

0

I'm learning assembly and facing the following problem: In the function asm_func4: push rbp ; preserve rbp call _strlen ; get rdi strlen mov rdx, rax ; copy strlen to reverse counter sub...
Charleen asked 26/9, 2023 at 21:20

2

Solved

Consider inline assembly like this: uint64_t flags; asm ("pushf\n\tpop %0" : "=rm"(flags) : : /* ??? */); Nonwithstanding the fact that there is probably some kind of intrinsic to get the conten...
Procrastinate asked 26/8, 2016 at 7:14

1

typedef struct foo { void (*const t)(struct foo *f); } foo; void t(struct foo *f) { } void (*const myt)(struct foo *f) = t; foo f = {.t = t}; int main(void) { f.t(&f); myt(&f); r...
Bedspring asked 10/9, 2023 at 20:13

2

Solved

I have this simple python/numba code: from numba import njit import numba as nb @nb.njit(nb.uint64(nb.uint64)) def popcount(x): b=0 while(x > 0): x &= x - nb.uint64(1) b+=1 return b @...
Garret asked 14/9, 2023 at 11:36

11

Solved

In a book I read the following: 32-bit processors have 2^32 possible addresses, while current 64-bit processors have a 48-bit address space My expectation was that if it's a 64-bit processor, ...
Header asked 16/7, 2011 at 11:9

0

While watching this talk by Matt Godbolt, I was astonished to see that Clang, if instructed to compile for the Haswell¹ architecture, works out that the following code int foo(int a) { int count =...
Bingle asked 28/8, 2023 at 7:47

0

I have this simple function that is called from many inner-most loops. uint16_t getBit(uint16_t val, uint16_t n) { return (val & (1 << n)) >> n; } This version of the programs tak...
Checked asked 13/8, 2023 at 12:29

0

I've been reverse engineering the EnterCriticalSection function on Windows 10 and found this interesting spin-loop: It goes: lbl_loop: mov ecx, [rsp+60h] mov ecx, [rsp+60h] mov ecx, [rsp+60h] pau...
Chekiang asked 9/8, 2023 at 19:12

2

Solved

I am trying to call a function - that should have an absolute address when compiled and linked - from machine code. I am creating a function pointer to the desired function and trying to pass that ...
Lakieshalakin asked 15/8, 2016 at 18:54

2

Solved

I am experimenting with the way parameters are passed to a function when compiling C++ code. I tried to compile the following C++ code using the x64 msvc 19.35/latest compiler to see the resulting ...
Floria asked 29/7, 2023 at 23:33

1

I debug a program with gdb for fun, with stack guard so it writes the canary to the stack from fs:28h. Out of curiosity, I trying to find the memory address that fs:28h points to. I encounter two p...
Branum asked 22/7, 2023 at 20:10

1

My primary development machine is x86_64 while some of my deploy environments are arm7vl (Raspberry Pi). For most Python development, this isn't a problem, but some Python libraries are are only av...
Ever asked 3/1, 2022 at 10:9

3

Solved

Is there a way to remove the array bounds check in C#? here is what I want to achieve: public static int F(int[] M, int i) { return M[i]; // I can guarantee that [i] will never be outside of [0, ...
Keslie asked 4/4, 2021 at 7:51

1

Solved

I have the following Java code (all arrays are initialized before we call "arrays" and all are of size "arraySize") int arraySize = 64; float[] a; float[] b; float[] result; p...
Ultann asked 8/7, 2023 at 17:19

1

Solved

I have stumbled upon this kernel page: https://www.kernel.org/doc/html/v5.9/x86/x86_64/fsgs.html and wanted to play around with LD_PRELOAD to see whether I can allocate a value at a load-time and r...
Wafd asked 8/7, 2023 at 22:36

1

Solved

I want to replace the lowest byte in an integer. On x86 this is exactly mov al, [mem] but I can't seem to get compilers to output this. Am I missing an obvious code pattern that is recognized, am I...
Patten asked 22/6, 2023 at 10:38

2

Solved

I have the following code, which doesn't compile with x86_64 GCC 13: #include <iostream> #include <stdfloat> int main() { std::cout << std::float128_t{1} << '\n'; } This ...
Goodhen asked 18/6, 2023 at 10:44

1

Solved

given this code lp: vpaddq ymm0, ymm1 vpaddq ymm3, ymm4 add rbx, rax add rcx, rax vpaddq ymm1, ymm2 vpaddq ymm4, ymm5 sub rax, 0xA jge lp according to the https://uica.uops.info this is ...
Friesland asked 17/6, 2023 at 9:57

1

Consider the following almost leaf function: int almost_leaf(int* x) { if (__builtin_expect(*x >= 0, true)) { return *x; } return x_was_negative() + 1; } It is almost leaf in the sense that...
Eugenides asked 15/6, 2023 at 5:40

3

At the C level, the recommendation is typically to pass anything bigger than word size (8 bytes on x86-64) by pointer, and anything smaller by value (implying by register). The argument is supposed...
Marivaux asked 10/6, 2023 at 21:43

8

Solved

According to Wikipedia: A page fault is a trap to the software raised by the hardware when a program accesses a page that is mapped in the virtual address space, but not loaded in physical memor...
Surmise asked 16/4, 2011 at 3:59

4

Solved

Profiling suggests that this function here is a real bottle neck for my application: static inline int countEqualChars(const char* string1, const char* string2, int size) { int r = 0; for (int j...
Halfdan asked 24/3, 2013 at 13:23

© 2022 - 2025 — McMap. All rights reserved.