x86-64

Floating point vs integer calculations on modern hardware

帅比萌擦擦* 提交于 2019-12-27 10:33:48
问题 I am doing some performance critical work in C++, and we are currently using integer calculations for problems that are inherently floating point because "its faster". This causes a whole lot of annoying problems and adds a lot of annoying code. Now, I remember reading about how floating point calculations were so slow approximately circa the 386 days, where I believe (IIRC) that there was an optional co-proccessor. But surely nowadays with exponentially more complex and powerful CPUs it

Floating point vs integer calculations on modern hardware

喜夏-厌秋 提交于 2019-12-27 10:33:13
问题 I am doing some performance critical work in C++, and we are currently using integer calculations for problems that are inherently floating point because "its faster". This causes a whole lot of annoying problems and adds a lot of annoying code. Now, I remember reading about how floating point calculations were so slow approximately circa the 386 days, where I believe (IIRC) that there was an optional co-proccessor. But surely nowadays with exponentially more complex and powerful CPUs it

Print register value to console

人盡茶涼 提交于 2019-12-26 21:39:49
问题 I want to print the value in %RCX directly to the console, let's say an ASCII value. I've searched through some wise books and tutorials, but all use buffers to pass anything. Is it possible to print anything without creating special buffer for that purpose? lets say i am here (all this answers are fat too complicated to me and use different syntax): movq $5, %rax ...???(print %rax) Output on console: \>5 in example, to print buffer i use code: SYSWRITE = 4 STDOUT = 1 EXIT_SUCCESS = 0 .text

CPU 的18条

孤街浪徒 提交于 2019-12-26 05:02:37
1.主频 主频也叫时钟频率,单位是MHz,用来表示CPU的运算速度。CPU的主频=外频×倍频系数。很多人认为主频就决定着CPU的运行速度,这不仅是个片面的,而且对于 服务 器来讲,这个认识也出现了偏差。至今,没有一条确定的公式能够实现主频和实际的运算速度两者之间的数值关系,即使是两大处理器厂家Intel和AMD,在这点上也存在着很大的争议,我们从Intel的产品的发展趋势,可以看出Intel很注重加强自身主频的发展。像其他的处理器厂家,有人曾经拿过一快1G的全美达来做比较,它的运行效率相当于2G的Intel处理器。 所以,CPU的主频与CPU实际的运算能力是没有直接关系的,主频表示在CPU内数字脉冲信号震荡的速度。在Intel的处理器产品中,我们也可以看到这样的例子:1 GHz Itanium芯片能够表现得差不多跟2.66 GHz Xeon/Opteron一样快,或是1.5 GHz Itanium 2大约跟4 GHz Xeon/Opteron一样快。CPU的运算速度还要看CPU的流水线的各方面的性能指标。 当然,主频和实际的运算速度是有关的,只能说主频仅仅是CPU性能表现的一个方面,而不代表CPU的整体性能。 2.外频 外频是CPU的基准频率,单位也是MHz。CPU的外频决定着整块主板的运行速度。说白了,在台式机中,我们所说的超频,都是超CPU的外频(当然一般情况下

Segmentation fault in assembly code + C

♀尐吖头ヾ 提交于 2019-12-25 12:47:15
问题 I am trying to debug a segmentation fault in my assembly code. Here is the GDB output Program received signal SIGSEGV, Segmentation fault. 0x0000000000424c50 in restore_context() (gdb) disassemble restore_context Dump of assembler code for function restore_context: 0x0000000000424c44 <+0>: mov 0x8(%rsp),%rax 0x0000000000424c49 <+5>: mov 0x38(%rax),%rsp 0x0000000000424c4d <+9>: mov (%rax),%rdx =>0x0000000000424c50 <+12>: mov %rdx,(%rsp) 0x0000000000424c54 <+16>: mov 0x18(%rax),%rbx

Which one will workload(usage) of the CPU-Core if there is a persistent cache-miss, will be 100%?

别等时光非礼了梦想. 提交于 2019-12-25 05:00:31
问题 That is, if the core processor most of the time waiting for data from RAM or cache-L3 with cache-miss, but the system is a real-time (real-time thread priority), and the thread is attached (affinity) to the core and works without switching thread/context, what kind of load(usage) CPU-Core should show on modern x86_64 ? That is, CPU usage is displayed as decrease only when logged in Idle ? And if anyone knows, if the behavior is different in this case for other processors: ARM, Power[PC],

Ubuntu 16.04 assembly code for shell

瘦欲@ 提交于 2019-12-25 04:23:21
问题 .global main main: call func .string "/bin/sh" func: push %rsp pop %rsi pop %rdi mov $0x00, %edx mov $0x3b, %eax syscall I wrote assembly lagunage like above for execute /bin/sh I compiled it but when I try to execute program, /bin/sh: 0: Can't open ???? this error is occur. It doesn't execute /bin/sh. I want to know why I can't execute /bin/sh I'm using Ubuntu 16.04 and x64 Architectures 回答1: Your code is needlessly hard to follow because of using push/pop in a weird way, but running your

Xcode Mach-O Linker errors with 64-bit simulator

倾然丶 夕夏残阳落幕 提交于 2019-12-25 03:05:07
问题 I have been developing an iOS app in Xcode. It compiled and ran perfectly in the regular simulator, but when I switched the simulator device to 64-bit, it failed with 13 new warnings and 37 new errors, all of which are associated (I think) with an external library I'm using called ObjectiveDDP (https://github.com/boundsj/ObjectiveDDP). People had similar problems, but my understanding is they were supposedly fixed in a recently-released update to the framework, but on my end this update is to

Moving contents of RAX to C variable (x86-64 asm)

北城余情 提交于 2019-12-25 01:53:38
问题 This is a rather naive question. I'm just playing around with allocating some executable memory and manually assembling some x86 code to run in it. I'm a bit confused by how addressing works in 64-bit mode. If I have a variable in my C code, and I want to move the contents of RAX into this variable, which form of the MOV instruction should I use? (This isn't using inline assembly, so I can't get the compiler to do it for me; I just have the value of &var to play with.) 回答1: Using Intel syntax

x86-64 Assembly to C

瘦欲@ 提交于 2019-12-25 00:49:55
问题 I tried translating this into C, but I'm stuck at the displacement of the memory address ( %rdi ): program: movq (%rdi), %rax testq %rax, %rax je L1 addq $8, %rdi movq %rax, %rdx L3: cmpq %rdx, %rax cmovl %rdx, %rax addq $8, %rdi movq -8(%rdi), %rdx testq %rdx, %rdx jne L3 L1: ret I've come up with following so far: int func(int *x){ int ret = *x; if(ret != 0){ x+=8; //is this true? y = ret; while(y!=0){ if(ret<y){ ret = y; } y=?? //What should this say? } } return ret; Possible solution