rdx

X64的函数调用规则

允我心安 提交于 2020-03-17 11:25:14
某厂面试归来,发现自己落伍了!>>> 闲着没事想研究一下gcc的函数调用方式和m$的__stdcall、__fastcall之类有何区别,本想是了解一下关于参数的入栈顺序和清理方,就随便写了个C函数,编译成.s文件,一看发现根本就没有push和pop之类的指令...两个int参数都是利用rsi和rdi传递!网上百度了一个关于m$平台x64的调用约定 看完ddk里相关的部分,总结下吧,规则倒是不复杂,相对x86时代的stdcall cdecl fastcall 三分天下要简明的多。按ddk里的说法,m$就是要趁这次统一调用规则…… -__- 在x64下函数调用的前4个参数总是放在寄存器中传递,剩余的参数则压入堆栈中。而x86上则是全部压入堆栈中(除了fastcall方式)。这4个用于存放参数的寄存器分别是:存放整数参数的RCX,RDX,R8,R9;存放浮点数参数的XMM0,XMM1,XMM2,XMM3。 按照所传参数是整数还是浮点数的不同,寄存器的使用规则如下: 全部整数参数: func1(int a, int b, int c, int d, int e); 参数a放入RCX,参数b放入RDC,参数c放入R8,参数d放入R9,参数e么压栈。 参数传递规则:按照参数表声明的顺序,从左向右,前4个参数依次放入RCX,RDX,R8,R9中。 全部浮点数参数: func1(float a,

记一次Typescript+react的match的坑

本秂侑毒 提交于 2020-01-20 12:06:00
1 import React from "react"; 2 import { match } from 'react-router-dom' 3 4 interface Props { 5 match: match<{id?: string}> 6 } 7 8 const Rdx: React.FC<Props> = ({ match }: Props) => { 9 const id = match.params.id; 10 return ( 11 <div> 12 我是Rdx页面,id是 {id} 13 </div> 14 ); 15 } 16 export default Rdx 来源: https://www.cnblogs.com/ywenhao/p/12217334.html

Assembler instruction: rdtsc

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Could someone help me understand the assembler given in https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html It goes like this: uint64_t msr ; asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX. "shl $32, %%rdx\n\t" // Shift the upper bits left. "or %%rdx, %0" // 'Or' in the lower bits. : "=a" ( msr ) : : "rdx" ); How is it different from: uint64_t msr ; asm volatile ( "rdtsc\n\t" : "=a" ( msr )); Why do we need shift and or operations and what does rdx at the end do? EDIT: added what is still unclear to the original

Memcpy vs Memmove - Debug vs Release

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got really strange behavior for my x64 multithreading application. The execution time in debug mode is faster than in release mode. I break the problem down and found the issue: The debug modus optimize (!Note optimition is off!) the memcpy to memmove, which peforms faster. The release mode use still memcpy (!note optimition is on). This problem slows down my multithreading app in release mode. :( Anyone any idea? #include <time.h> #include <iostream> #define T_SIZE 1024*1024*2 int main() { clock_t start, end; char data[T_SIZE]; char store

binary bomb lab phase 6

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 0x000000000040106b <+0>: push %r12 0x000000000040106d <+2>: push %rbp 0x000000000040106e <+3>: push %rbx 0x000000000040106f <+4>: sub $0x50,%rsp 0x0000000000401073 <+8>: lea 0x30(%rsp),%rsi 0x0000000000401078 <+13>: callq 0x40159a <read_six_numbers> 0x000000000040107d <+18>: mov $0x0,%ebp 0x0000000000401082 <+23>: lea 0x30(%rsp),%r12 0x0000000000401087 <+28>: mov (%r12,%rbp,4),%eax 0x000000000040108b <+32>: sub $0x1,%eax 0x000000000040108e <+35>: cmp $0x5,%eax 0x0000000000401091 <+38>: jbe 0x401098 <phase_6+45> 0x0000000000401093 <+40>:

128-bit division intrinsic in Visual C++

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm wondering if there really is no 128-bit division intrinsic function in Visual C++? There is a 64x64=128 bit multiplication intrinsic function called _umul128(), which nicely matches the MUL x64 assembler instruction. Naturally, I assumed there would be a 128/64=64 bit division intrinsic as well (modelling the DIV instruction), but to my amazement neither Visual C++ nor Intel C++ seem to have it, at least it's not listed in intrin.h. Can someone confirm that? I tried grep'ing for the function names in the compiler execuable files, but

How do I translate x86 GCC-style C inline assembly to Rust inline assembly?

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have the following inline assembly in C: unsigned long long result ; asm volatile ( ".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" : "=a" ( result ) :: "%rdx" ); return result ; I tried to rewrite it in Rust: let result : u64 ; unsafe { asm !( ".byte 15\n\t .byte 49\n\t shlq 32, rdx\n\t orq rdx, rax" : "=a" ( result ) : : "rdx" : "volatile" ); } result It doesn't recognize the =a constraint an it gives me an invalid operand error for rdx and rax at shlq and orq instructions. What is the proper way to rewrite the above C

解释QStringLiteral

匿名 (未验证) 提交于 2019-12-03 00:22:01
QStringLiteral explained o->setObjectName( "MyObject" ); if (action == "rename" ) string.replace( "%FileName%" , filename); bool operator==( const QString &, const QString &); bool operator==( const QString &, const char *); bool operator==( const char *, const QString &) QLatin1String o->setObjectName( QLatin1String ( "MyObject" )); if (action == QLatin1String ( "rename" )) string.replace( QLatin1String ( "%FileName%" ), filename); QStringLiteral QString returnAString() { return QStringLiteral ( "Hello" ); } . text . globl _Z13returnAStringv . type _Z13returnAStringv, @function