x86-64

Why va_arg() produce different effects on x86_64 and arm?

人走茶凉 提交于 2020-01-06 04:34:29
问题 The codes: #include <stdio.h> #include <stdarg.h> #include <stdlib.h> typedef unsigned int uint32_t; float average(int n_values, ... ) { va_list var_arg; int count; float sum = 0; va_start(var_arg, n_values); for (count = 0; count < n_values; count += 1) { sum += va_arg(var_arg, signed long long int); } va_end(var_arg); return sum / n_values; } int main(int argc, char *argv[]) { (void)argc; (void)argv; printf("hello world!\n"); uint32_t t1 = 1; uint32_t t2 = 4; uint32_t t3 = 4; printf("result

GCC Jump Table initialization code generating movsxd and add?

爱⌒轻易说出口 提交于 2020-01-06 04:12:27
问题 When I compile a switch statement with optimization in GCC, it sets up a jump table like this, (fcn) sym.foo 148 sym.foo (unsigned int arg1); ; arg unsigned int arg1 @ rdi 0x000006e0 83ff06 cmp edi, 6 ; arg1 0x000006e3 0f87a7000000 ja case.default.0x790 0x000006e9 488d156c0100. lea rdx, [0x0000085c] 0x000006f0 89ff mov edi, edi 0x000006f2 4883ec08 sub rsp, 8 0x000006f6 486304ba movsxd rax, dword [rdx + rdi*4] 0x000006fa 4801d0 add rax, rdx ; '(' ;-- switch.0x000006fd: 0x000006fd ffe0 jmp rax

Are x86-64 CPU registers shared among multiple cores? [duplicate]

家住魔仙堡 提交于 2020-01-05 08:43:29
问题 This question already has answers here : Does each core has its own private set of registers? (2 answers) What does multicore assembly language look like? (10 answers) Why each logical CPU has it's own CR3 register in case of multithreading? (1 answer) Can I temporarily enable FTZ and DAZ floating-point modes for a thread? (1 answer) Closed last year . I'm trying to read the Intel documentation on the CPU registers, and the question came up that I can't seem to find an answer to. Say, all of

Simple input to output program in Assembly

南笙酒味 提交于 2020-01-05 05:00:26
问题 So, I'm new to learning Assembly and am very confused on how the memory works in Assembly etc. I got the following code: .global main .text format_input: .asciz "%ld" main: subq $8, %rsp leaq -8(%rbp), %rsi movq $format_input, %rdi movq $0, %rax call scanf movq %rsp, %rdi call printf end: movq $0, %rax call exit What I wanted to do here is to input a number and output the same number. But here, I'm already having a problem. If I input a number , I get a Segmentation fault . If I input one

Intel x86_64 assembly, how to floor double from xmm register to int?

眉间皱痕 提交于 2020-01-05 04:28:10
问题 How can I do that? It would be best if result will be in e*x register. 回答1: You've asked several trivial questions which you could answer by just looking at how a C compiler does it. From there, you can look up the instructions it used, and decide which ones you want to actually use. (There are about a zillion different rounding functions in libm, so picking the right one in the first place isn't always easy). Using -O3 -ffast-math gets most simple libm functions inlined (since it doesn't

Rotating (by 90°) a bit matrix (up to 8x8 bits) within a 64-bit integer

帅比萌擦擦* 提交于 2020-01-04 15:15:10
问题 I have a bit matrix (of size 6x6, or 7x7, or 8x8) stored within one single 64-bit integer. I am looking for c++ code that rotates these matrices by 90, 180, 270 degrees, as well as c++ code for shifting (horizontally and vertically) and mirroring these matrices. The output must be again a 64-bit integer. Using some of the advanced CPU instruction sets would probably be okay, as well as using hash tables or similar techniques - speed is of highest importance, and RAM is available. I will run

Intel Reset Vector

烂漫一生 提交于 2020-01-04 14:28:37
问题 Possible duplicate: Software initialization code at 0xFFFFFFF0H When the system boots up (Intel), reset vector is at address 0xFFFFFFF0 (16 bytes less than 4G) (as mentioned in above link). That address contains FAR JUMP to where the BIOS is. I read the answer, comments and referenced link, also did some searching, but still cannot understand how 32-bit address can be map to 16-bit (Real Mode)? My confusion is that in this link: http://www.starman.vertcomp.com/asm/bios/index.html, author

Intel Reset Vector

自古美人都是妖i 提交于 2020-01-04 14:28:10
问题 Possible duplicate: Software initialization code at 0xFFFFFFF0H When the system boots up (Intel), reset vector is at address 0xFFFFFFF0 (16 bytes less than 4G) (as mentioned in above link). That address contains FAR JUMP to where the BIOS is. I read the answer, comments and referenced link, also did some searching, but still cannot understand how 32-bit address can be map to 16-bit (Real Mode)? My confusion is that in this link: http://www.starman.vertcomp.com/asm/bios/index.html, author

Compile Apache 2.4.2 in Solaris 10 in a x86 machine (64bits) errors

本秂侑毒 提交于 2020-01-04 09:04:39
问题 I'm having a hard time compiling Apache 2.4.2 in Solaris 10 in a x86 machine (64bits) I installed all the required programs without problems, but when configuring (or doing make) with apache it explode. I don't know if the problem is the env vairables. I don't know which one is failing -if this was the case-. Here is a mini script (ran it with: source script ) to illustrate what I'm doing ( Notice that I install everything in /opt using the prefix flag): #!/bin/sh #Set ENV variables export

Behind Windows x64's 44-bit virtual memory address limit

不羁岁月 提交于 2020-01-04 06:07:08
问题 http://www.alex-ionescu.com/?p=50. I read the above post. The author explains why Windows x64 supports only 44-bit virtual memory address with singly linked list example. struct { // 8-byte header ULONGLONG Depth:16; ULONGLONG Sequence:9; ULONGLONG NextEntry:39; } Header8; The first sacrifice to make was to reduce the space for the sequence number to 9 bits instead of 16 bits, reducing the maximum sequence number the list could achieve. This still only left 39 bits for the pointer — a