assembly

GCC generated assembly for unaligned float access on ARM

陌路散爱 提交于 2021-02-20 17:56:41
问题 Hello I am currently working on a program where I need to process a data blob that contains a series of floats which could be unaligned (and also are sometimes). I am compiling with gcc 4.6.2 for an ARM cortex-a8. I have a question to the generated assembly code: As example I wrote a minimal example: For the following test code float aligned[2]; float *unaligned = (float*)(((char*)aligned)+2); int main(int argc, char **argv) { float f = unaligned[0]; return (int)f; } the compiler (gcc 4.6.2 -

GCC generated assembly for unaligned float access on ARM

三世轮回 提交于 2021-02-20 17:56:12
问题 Hello I am currently working on a program where I need to process a data blob that contains a series of floats which could be unaligned (and also are sometimes). I am compiling with gcc 4.6.2 for an ARM cortex-a8. I have a question to the generated assembly code: As example I wrote a minimal example: For the following test code float aligned[2]; float *unaligned = (float*)(((char*)aligned)+2); int main(int argc, char **argv) { float f = unaligned[0]; return (int)f; } the compiler (gcc 4.6.2 -

x86 BSWAP instruction REX doesn't follow Intel specs?

风格不统一 提交于 2021-02-20 06:27:43
问题 I've been assembling (and disassembling) the BSWAP x64 instruction with both NASM and GAS, and both assemble the instruction BSWAP r15 as 490FCF in hex. Disassemblers also disassemble this to the same instruction. The REX prefix for the instruction ( 49 ) thus has the REX.W bit (bit 3) and the REX.B bit (bit 0) set. This is directly in contrast to the Intel documentation, which states: In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix in the form of REX.R

x86 BSWAP instruction REX doesn't follow Intel specs?

≯℡__Kan透↙ 提交于 2021-02-20 06:25:41
问题 I've been assembling (and disassembling) the BSWAP x64 instruction with both NASM and GAS, and both assemble the instruction BSWAP r15 as 490FCF in hex. Disassemblers also disassemble this to the same instruction. The REX prefix for the instruction ( 49 ) thus has the REX.W bit (bit 3) and the REX.B bit (bit 0) set. This is directly in contrast to the Intel documentation, which states: In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix in the form of REX.R

Why does the sys_read system call end when it detects a new line?

我们两清 提交于 2021-02-20 05:56:48
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

Why does the sys_read system call end when it detects a new line?

徘徊边缘 提交于 2021-02-20 05:56:46
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

Why does the sys_read system call end when it detects a new line?

蹲街弑〆低调 提交于 2021-02-20 05:55:00
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

mmap substitute for malloc

浪子不回头ぞ 提交于 2021-02-20 05:00:07
问题 I need to find a way to use mmap instead of malloc. How is this possible? (I am not using libc only syscalls) And yes brk() is possible. I used sbrk() but realized its not sys-call... (x86 inline assembly) I've been looking around and saw this: How to use mmap to allocate a memory in heap? But it didn't help for me, because I had a segfault. Basically, all I want to do a create 3 slabs of memory for storing characters. Say, char * x = malloc(1000); char * y = malloc(2000); char * z = malloc

What happens to registers when you manipulate them using asm code in C++?

我是研究僧i 提交于 2021-02-20 03:00:07
问题 Some code: int x = 1; for(int i = 1; i < 10; i++) { x *= i; __asm { mov eax, x }; } If this program uses eax in order to increase the value of i , what will happen when I manipulate eax ? Will the compiler save registers from before the __asm call and use them after the asm code was executed or will it ignore that eax was manipulated and continue producing some sort of strange behavior? What happens to eax internally? EDIT: Even if my code only works with Visual C++ I want to know what

What happens to registers when you manipulate them using asm code in C++?

北城余情 提交于 2021-02-20 03:00:07
问题 Some code: int x = 1; for(int i = 1; i < 10; i++) { x *= i; __asm { mov eax, x }; } If this program uses eax in order to increase the value of i , what will happen when I manipulate eax ? Will the compiler save registers from before the __asm call and use them after the asm code was executed or will it ignore that eax was manipulated and continue producing some sort of strange behavior? What happens to eax internally? EDIT: Even if my code only works with Visual C++ I want to know what