x86-64

Problems with non-atomic access example on GNU website

偶尔善良 提交于 2021-01-29 01:32:31
问题 On the website of GNU there is a simple example available which is supposed to demonstrate the problems appearing with non-atomic access. The example contains a small mistake, they have forgotten #include <unistd.h> : #include <signal.h> #include <stdio.h> #include <unistd.h> struct two_words { int a, b; } memory; static struct two_words zeros = { 0, 0 }, ones = { 1, 1 }; void handler(int signum) { printf ("%d,%d\n", memory.a, memory.b); alarm (1); } int main (void) { signal (SIGALRM, handler

Problems with non-atomic access example on GNU website

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 01:31:43
问题 On the website of GNU there is a simple example available which is supposed to demonstrate the problems appearing with non-atomic access. The example contains a small mistake, they have forgotten #include <unistd.h> : #include <signal.h> #include <stdio.h> #include <unistd.h> struct two_words { int a, b; } memory; static struct two_words zeros = { 0, 0 }, ones = { 1, 1 }; void handler(int signum) { printf ("%d,%d\n", memory.a, memory.b); alarm (1); } int main (void) { signal (SIGALRM, handler

Is it possible to output a string to the console in C without including the standard library?

半腔热情 提交于 2021-01-28 21:46:56
问题 I'm trying to get better understanding of how assembly and machine code works. So I'm compiling this simple snipet with gcc : #include <stdio.h> int main(){ printf("Hello World!"); return 0; } But this includes the default library. I would like to output hello world without using printf but by inlining some assembly in the C file, and adding -nostdlib and -nodefaultlibs options to gcc. How can I do that ? I'm using Windows 10 and mingw-w64 with Intel core i7 6700 HQ (laptop processor). Can I

Is it possible to output a string to the console in C without including the standard library?

时光怂恿深爱的人放手 提交于 2021-01-28 21:16:41
问题 I'm trying to get better understanding of how assembly and machine code works. So I'm compiling this simple snipet with gcc : #include <stdio.h> int main(){ printf("Hello World!"); return 0; } But this includes the default library. I would like to output hello world without using printf but by inlining some assembly in the C file, and adding -nostdlib and -nodefaultlibs options to gcc. How can I do that ? I'm using Windows 10 and mingw-w64 with Intel core i7 6700 HQ (laptop processor). Can I

Assembly x86-64 setting carry flag for sub instruction

人走茶凉 提交于 2021-01-28 18:00:25
问题 I am working through Richard Detmer's Assembly Language book. The first chapter states: A borrow occurs in the subtraction a - b when b is larger than a as unsigned numbers. Computer hardware can detect a borrow in subtraction by looking at whether a carry occurred in the corresponding addition. If there is no carry in the addition, then there is a borrow in the subtraction. If there is a carry in the addition, then there is no borrow in the subtraction. The carry flag is the 0th bit of the

Assembly x86-64 setting carry flag for sub instruction

老子叫甜甜 提交于 2021-01-28 18:00:19
问题 I am working through Richard Detmer's Assembly Language book. The first chapter states: A borrow occurs in the subtraction a - b when b is larger than a as unsigned numbers. Computer hardware can detect a borrow in subtraction by looking at whether a carry occurred in the corresponding addition. If there is no carry in the addition, then there is a borrow in the subtraction. If there is a carry in the addition, then there is no borrow in the subtraction. The carry flag is the 0th bit of the

Assembly x86-64 setting carry flag for sub instruction

有些话、适合烂在心里 提交于 2021-01-28 17:51:02
问题 I am working through Richard Detmer's Assembly Language book. The first chapter states: A borrow occurs in the subtraction a - b when b is larger than a as unsigned numbers. Computer hardware can detect a borrow in subtraction by looking at whether a carry occurred in the corresponding addition. If there is no carry in the addition, then there is a borrow in the subtraction. If there is a carry in the addition, then there is no borrow in the subtraction. The carry flag is the 0th bit of the

How to log CPU instructions executed by program with x64dbg?

百般思念 提交于 2021-01-28 13:50:50
问题 How to log CPU instructions executed by program with x64dbg? I saw https://reverseengineering.stackexchange.com/questions/18634/x64dbg-see-the-current-position question, but I can't find the way to log instructions. 回答1: As far as I understand - you want to log all the executed instructions. The easiest would be to log them in the file. To do this you need to: Pause the program, either via Pause option (F12) or using breakpoints Select Trace menu and then Trace into... (Ctrl+Alt+F7) or Trace

Integer describing number of floating point arguments in xmm registers not passed to rax

安稳与你 提交于 2021-01-28 09:30:59
问题 I have got a function which is declared as follows: double foo(int ** buffer, int size, ...); The function is a part of cpp implementation of a program. I use last parameter to pass multiple double variables to the function. The problem is that on Mac I do not receive valid number in rax register, on the other hand on ubuntu it works as expected. A simple example: CPP #include <iostream> extern "C" double foo(int ** buffer, int buffer_size, ...); int main() { int* buffer [] = {new int(2), new

What's 'new' in a 'new' processor when viewed from programmer's point

好久不见. 提交于 2021-01-28 09:30:52
问题 I have recently been interested in understanding low level computing. I understand that today's widely used computers follow x86/x86-64 architecture. To my understanding, architecture, more specifically Instruction Set Architecture (ISA) is the set of instructions that the programmer is able to issue to the CPU. The first question, Is the ISA keeps evolving or remains the same? I think that it keeps evolving (meaning new instructions keeps getting added/previous instructions modified?) but