x86-64

Should using MOV instruction to set SS to 0x0000 cause fault #GP(0) in 64-bit mode?

半城伤御伤魂 提交于 2021-01-19 21:18:33
问题 This question is inspired by a Reddit question in r/osdev except that this question focuses on the SS register. One may say RTFM (ISA entry for MOV), but when this question comes up it can get varying answers even among OS developers. Question : Should using the MOV instruction to set SS to 0x0000 cause a general protection fault #GP(0) in 64-bit mode? For example: If I am in 64-bit mode with a Current Privilege level (CPL) of 0, should I expect to see a #GP(0) with this code snippet: NULL

Should using MOV instruction to set SS to 0x0000 cause fault #GP(0) in 64-bit mode?

血红的双手。 提交于 2021-01-19 21:17:51
问题 This question is inspired by a Reddit question in r/osdev except that this question focuses on the SS register. One may say RTFM (ISA entry for MOV), but when this question comes up it can get varying answers even among OS developers. Question : Should using the MOV instruction to set SS to 0x0000 cause a general protection fault #GP(0) in 64-bit mode? For example: If I am in 64-bit mode with a Current Privilege level (CPL) of 0, should I expect to see a #GP(0) with this code snippet: NULL

Assembly x86-64 get function parameters from stack

99封情书 提交于 2021-01-19 08:38:12
问题 Lately I've been learning x86 Assembly from the book Programming from the Ground Up, but I have an x86-64 computer, so things start to go wrong at one point (pretty early in the book). I got to the part where I'm dealing with functions, specifically the power example. In this example he pushes the parameters onto the stack and then copies them into registers later in the function. Here's what his code looks like: pushl $3 # second argument pushl $2 # first argument call power # call function

Assembly x86-64 get function parameters from stack

主宰稳场 提交于 2021-01-19 08:38:07
问题 Lately I've been learning x86 Assembly from the book Programming from the Ground Up, but I have an x86-64 computer, so things start to go wrong at one point (pretty early in the book). I got to the part where I'm dealing with functions, specifically the power example. In this example he pushes the parameters onto the stack and then copies them into registers later in the function. Here's what his code looks like: pushl $3 # second argument pushl $2 # first argument call power # call function

Is segmentation completely not used in x64?

我怕爱的太早我们不能终老 提交于 2021-01-19 06:15:15
问题 In x86, when you want to access a memory address, you would specify an address that would be translated into a memory address through two stages: segmentation , and paging : But is segmentation also used in x64? (I think it is not used, but I am not sure if it is not used in all cases, or are there some cases where it is used). 回答1: For the purpose of the picture you posted, segmentation is only used when the addressing mode uses the registers fs or gs (because these were being actively

Writing a portable SSE/AVX version of std::copysign

蹲街弑〆低调 提交于 2021-01-18 12:07:07
问题 I am currently writing a vectorized version of the QR decomposition (linear system solver) using SSE and AVX intrinsics. One of the substeps requires to select the sign of a value opposite/equal to another value. In the serial version, I used std::copysign for this. Now I want to create a similar function for SSE/AVX registers. Unfortunately, the STL uses a built-in function for that, so I can't just copy the code and turn it into SSE/AVX instructions. I have not tried it yet (so I have no

How to determine the appropriate MOV instruction suffix based on the operands?

社会主义新天地 提交于 2021-01-16 03:52:01
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

How to determine the appropriate MOV instruction suffix based on the operands?

一世执手 提交于 2021-01-16 03:51:07
问题 The answer is 1. movl 2. movw 3. movb 4. movb 5. movq 6. movw But how do we determine that? 回答1: Simply look at the destination operand and specify its size. Case 1 : You are moving the value at address specified by register rsp to the register eax. Therefore, you should use movl which means move a long value. This is done because the eax register is 4 bytes wide which make up a long. The same applies to the other cases. movb - move byte. movw - move word (2 bytes). 来源: https://stackoverflow

NASM: How to create/handle basic bmp file using intel 64 bit assembly?

Deadly 提交于 2021-01-07 10:41:22
问题 How do I create/handle simple bmp file filling it with one color only using intel 64 bit assembly and nasm assembler? 回答1: The steps that include such operation are: Create bmp file header with fixed values (explanation of specific fields below) Create buffer which contains enough space - three bytes per pixel (one color = red + green + blue) Open/create file Fill the buffer Write header to file Write buffer to file Close file Exit program Ad. 2: This is a bit more tricky - if the number of

NASM: How to create/handle basic bmp file using intel 64 bit assembly?

你离开我真会死。 提交于 2021-01-07 10:40:52
问题 How do I create/handle simple bmp file filling it with one color only using intel 64 bit assembly and nasm assembler? 回答1: The steps that include such operation are: Create bmp file header with fixed values (explanation of specific fields below) Create buffer which contains enough space - three bytes per pixel (one color = red + green + blue) Open/create file Fill the buffer Write header to file Write buffer to file Close file Exit program Ad. 2: This is a bit more tricky - if the number of