Why is address 0x400000 chosen as a start of text segment in x86_64 ABI?

Bottom line: some technical limitations that amd64 has in using large addresses suggest dedicating the lower 2GiB of address space to code and data for efficiency. Thus the stack has been relocated out of this range. In i386 ABI1 stack is located before the code, growing from just under 0x8048000 downwards. Which provides “a little … Read more

x86_64 ASM – maximum bytes for an instruction?

The x86 instruction set (16, 32 or 64 bit, all variants/modes) guarantees / requires that instructions are at most 15 bytes. Anything beyond that will give an “invalid opcode”. You can’t achieve that without using redundant prefixes (e.g. multiple 0x66 or 0x67 prefixes, for example). The only instruction that actually takes 64-bits as a data … Read more

x86_64 best way to reduce 64 bit register to 32 bit retaining zero or non-zero status

Fewest uops (front-end bandwidth): 1 uop, latency 3c (Intel) or 1c (Zen). Also smallest code-size, 5 bytes. popcnt %rax, %rax # 5 bytes, 1 uop for one port # if using a different dst, note the output dependency on Intel before ICL On most CPUs that have it at all, it’s 3c latency, 1c throughput … Read more

How to include static library in makefile

use LDFLAGS= -L<Directory where the library resides> -l<library name> Like : LDFLAGS = -L. -lmine for ensuring static compilation you can also add LDFLAGS = -static Or you can just get rid of the whole library searching, and link with with it directly. Say you have main.c, fun.c and a static library libmine.a. Then you … Read more

Comparing Fortran & C++ assembler for int = floor(sqrt(…))

TL;DR: You’re hobbled by bad defaults and compatibility with obsolete machines: Bad defaults are gcc setting errno for floating-point computations (despite this not being required by the C language), and compatibility with x86 machines that don’t have any better SSE instructions than SSE2. If you want decent code generation, add -fno-math-errno -msse4 to the compiler … Read more

What does Intel mean by “retired”?

In the context “retired” means: the instruction (microoperation, μop) leaves the “Retirement Unit”. It means that in Out-of-order CPU pipeline the instruction is finally executed and its results are correct and visible in the architectural state as if they execute in-order. In performance context this is the number you should check to compute how many … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)