x86-64

Why are there no NAND, NOR and XNOR instructions in X86?

假如想象 提交于 2021-02-10 17:46:36
问题 They're one of the simplest "instructions" you could perform on a computer (they're the first ones I'd personally implement) Performing NOT(AND(x, y)) doubles execution time AND dependency chain length AND code size BMI1 introduced "andnot" which is a meaningful addition that is a unique operation - why not the ones in the title of this question? You usually read answers among the lines of "they take up valuable op-code space" but then I look at all of the kmask operations introduced with

Assembler code, need help understand what 'movzwl 0x40272e(,%rax,4),%esi' is doing

▼魔方 西西 提交于 2021-02-10 17:29:22
问题 i understand what the other calls are doing but when i get line 36, i don't get what's happening? my 3 parameters are rsi = 5, rdx = 6, rcx = 7 On line 26 my %rax = 25 then on line 30 my rsi changes from 5 to 37 can you explain why this happens? and what is 0x40272e 0x0000000000401212 <+0>: sub $0x8,%rsp # subtract 8 from rsp 0x0000000000401216 <+4>: lea -0x1(%rdx),%rax # rax = -1 + rdx 0x000000000040121a <+8>: cmp $0xf,%rax # rax ?? 0xf '-1' 'SI' 0x000000000040121e <+12>: ja 0x40124f <phase

Assembly clone syscall thread function not called

醉酒当歌 提交于 2021-02-10 14:47:00
问题 Im trying to create a thread using 'clone' syscall ... i searched toooooooo much ! for example, link1 link2 and now this is my source code in assembly for linux x64: FORMAT ELF64 EXECUTABLE ENTRY thread_linux_x64 THREAD_MEM_SIZE = 1024 define PROT_READ 0x1 define PROT_WRITE 0x2 define PROT_EXEC 0x4 define MAP_PRIVATE 0x02 define MAP_ANONYMOUS 0x20 define CLONE_VM 0x00000100 define CLONE_FS 0x00000200 define CLONE_FILES 0x00000400 define CLONE_SIGHAND 0x00000800 define CLONE_PARENT 0x00008000

Calling an assembly function from C

别等时光非礼了梦想. 提交于 2021-02-10 07:44:45
问题 One of my generated functions doesn't compute what it should and I am trying to debug it separately. I have the assembler for it and I try to call it from a stripped down C program. However, for some reason I end up getting segfaults in the function (so, calling the function seems to work, but execution fails). There might be something wrong with passing the arguments.. The functions signature is void func(int, int, float*, float*, float*); The function ignores the first two arguments and

Calling an assembly function from C

旧巷老猫 提交于 2021-02-10 07:44:08
问题 One of my generated functions doesn't compute what it should and I am trying to debug it separately. I have the assembler for it and I try to call it from a stripped down C program. However, for some reason I end up getting segfaults in the function (so, calling the function seems to work, but execution fails). There might be something wrong with passing the arguments.. The functions signature is void func(int, int, float*, float*, float*); The function ignores the first two arguments and

Build project targeting for both x86 and x64 platform

心已入冬 提交于 2021-02-10 05:42:27
问题 In my solution, there is a class library which is an excel add-in. When I build the solution or that project, I want this project will be built firstly targeting for x86 with outputing a file named xxx.dll , and then targeting for x64 with outputing a file named xxx_x64.dll . How should I do for this, or how could I edit the csproj file? Thanks. 回答1: How should I do for this, or how could I edit the csproj file? The name of assembly xxx.dll is defined by the property AssemblyName in the

Why am I allowed to exit main using ret?

杀马特。学长 韩版系。学妹 提交于 2021-02-10 05:14:20
问题 I am about to figure out how exactly a programm stack is set up. I have learned that calling the function with call pointer; Is effectively the same as: mov register, pc ;programcounter add register, 1 ; where 1 is one instruction not 1 byte ... push register jump pointer However, this would mean that when the Unix Kernel calls the main function that the stack base should point to reentry in the kernel function which calls main. Therefore jumping "*rbp-1" in the C - Code should reenter the

Why am I allowed to exit main using ret?

白昼怎懂夜的黑 提交于 2021-02-10 05:10:46
问题 I am about to figure out how exactly a programm stack is set up. I have learned that calling the function with call pointer; Is effectively the same as: mov register, pc ;programcounter add register, 1 ; where 1 is one instruction not 1 byte ... push register jump pointer However, this would mean that when the Unix Kernel calls the main function that the stack base should point to reentry in the kernel function which calls main. Therefore jumping "*rbp-1" in the C - Code should reenter the

Why am I allowed to exit main using ret?

独自空忆成欢 提交于 2021-02-10 05:07:11
问题 I am about to figure out how exactly a programm stack is set up. I have learned that calling the function with call pointer; Is effectively the same as: mov register, pc ;programcounter add register, 1 ; where 1 is one instruction not 1 byte ... push register jump pointer However, this would mean that when the Unix Kernel calls the main function that the stack base should point to reentry in the kernel function which calls main. Therefore jumping "*rbp-1" in the C - Code should reenter the

Error: use of overloaded operator '[]' is ambiguous while building for i386

送分小仙女□ 提交于 2021-02-09 08:34:02
问题 Consider the following code: #include <stdio.h> #include <stdint.h> class test_class { public: test_class() {} ~test_class() {} const int32_t operator[](uint32_t index) const { return (int32_t)index; } operator const char *() const { return "Hello World"; } }; int main(void) { test_class tmp; printf("%d\n", tmp[3]); return 0; } When I use command clang++ -arch i386 test.cc to build those codes, it yields the following on clang++ (Apple LLVM version 9.1.0 (clang-902.0.39.1)): test.cc:24:21: