instruction-set

alignment requirements for atomic x86 instructions

柔情痞子 提交于 2019-11-27 03:44:18
Microsoft offers the InterlockedCompareExchange function for performing atomic compare-and-swap operations. There is also an _InterlockedCompareExchange intrinsic . On x86 these are implemented using the cmpxchg instruction. However, reading through the documentation on these three approaches, they don't seem to agree on the alignment requirements. Intel's reference manual says nothing about alignment (other than that if alignment checking is enabled and an unaligned memory reference is made, an exception is generated) I also looked up the lock prefix, which specifically states that The

8086- why can't we move an immediate data into segment register?

我怕爱的太早我们不能终老 提交于 2019-11-27 01:51:48
问题 In 8086 assembly programming, we can only load a data into a segment register by, first loading it into a general purpose register and then we have to move it from this general register to the segment register. Why can't we load it directly? Is there any special reason for not being allowed? What is the difference between mov ax,5000H and mov ax,[5000H] ? Does [5000h] mean content in memory location 5000h? 回答1: Remember that the syntax of assembly language (any assembly) is just a human

How has CPU architecture evolution affected virtual function call performance?

岁酱吖の 提交于 2019-11-27 01:03:24
问题 Years ago I was learning about x86 assembler, CPU pipelining, cache misses, branch prediction, and all that jazz. It was a tale of two halves. I read about all the wonderful advantages of the lengthy pipelines in the processor viz instruction reordering, cache preloading, dependency interleaving, etc. The downside was that any deviation for the norm was enormously costly. For example, IIRC a certain AMD processor in the early-gigahertz era had a 40 cycle penalty every time you called a

What is the minimum instruction set required for any Assembly language to be considered useful?

跟風遠走 提交于 2019-11-27 00:44:42
问题 I am studying Assembly programming in general, so I've decided to try and implement a "virtual microprocessor" in software, which has registers, flags and RAM to work with, implemented with variables and arrays. But since I want to simulate only the most basic behavior of any microprocessor , I want to create an assembly language that has only the essential instructions, only those instructions without which it couldn't be useful. I mean, there are assembly languages that can do

Which arithmetic operations are the same on unsigned and two's complement signed numbers?

▼魔方 西西 提交于 2019-11-26 16:48:13
I'm designing a simple toy instruction set and accompanying emulator, and I'm trying to figure out what instructions to support. In the way of arithmetic, I currently have unsigned add, subtract, multiply, and divide. However, I can't seem to find a definitive answer to the following question: Which of the arithmetic operators need signed versions, and for which are the unsigned and two's complement signed versions equivalent? So, for example, 1111 in two's complement is equal to -1. If you add 1 to it and pretend that it's an unsigned number , you get 0000, which is correct even when thinking

Difference between movq and movabsq in x86-64

╄→尐↘猪︶ㄣ 提交于 2019-11-26 16:44:58
I'm a newcomer here and just starting to study assembly language. So please correct me if I'm wrong, or if this post doesn't make any sense I will delete. I'm talking about data movement instructions in the x86-64 Intel architecture. I have read that the regular movq instruction can only have immediate source operands that can be represented as 32-bit two's complement numbers, while the movabsq instruction can have an arbitrary 64-bit immediate value as its source operand and can only have a register as a destination. Could you please elaborate on this? Does that mean I can move 64-bit

Why IA32 does not allow memory to memory mov?

一世执手 提交于 2019-11-26 16:17:18
问题 In Intel architecture IA32, instructions like movl, movw does not allow operands that are both memory locations. For example, instruction movl (%eax), (%edx) is not permitted. Why? 回答1: The answer involves a fuller understanding of RAM. Simply stated, RAM can only be in two states, read mode or write mode. If you wish to copy one byte in ram to another location, you must have a temporary storage area outside of RAM as you switch from read to write. It is certainly possible for the

MOVZX missing 32 bit register to 64 bit register

匆匆过客 提交于 2019-11-26 14:48:03
问题 Here's the instruction which copies (converts) unsigned registers: http://www.felixcloutier.com/x86/MOVZX.html Basically the instruction has 8->16, 8->32, 8->64, 16->32 and 16->64. Where's the 32->64 conversion? Do I have to use the signed version for that? If so how do you use the full 64 bits for an unsigned integer? 回答1: Short answer Use mov eax, edi to zero-extend EDI into RAX if you can't already guarantee that the high bits of RDI are all zero. See: Why do x86-64 instructions on 32-bit

How do I enable SSE for my freestanding bootable code?

我的未来我决定 提交于 2019-11-26 14:47:34
问题 (This question was originally about the CVTSI2SD instruction and the fact that I thought it didn't work on the Pentium M CPU, but in fact it's because I'm using a custom OS and I need to manually enable SSE.) I have a Pentium M CPU and a custom OS which so far used no SSE instructions, but I now need to use them. Trying to execute any SSE instruction results in an interruption 6, illegal opcode (which in Linux would cause a SIGILL , but this isn't Linux), also referred to in the Intel

How to check if a CPU supports the SSE3 instruction set?

强颜欢笑 提交于 2019-11-26 14:12:09
Is the following code valid to check if a CPU supports the SSE3 instruction set? Using the IsProcessorFeaturePresent() function apparently does not work on Windows XP (see http://msdn.microsoft.com/en-us/library/ms724482(v=vs.85).aspx ). bool CheckSSE3() { int CPUInfo[4] = {-1}; //-- Get number of valid info ids __cpuid(CPUInfo, 0); int nIds = CPUInfo[0]; //-- Get info for id "1" if (nIds >= 1) { __cpuid(CPUInfo, 1); bool bSSE3NewInstructions = (CPUInfo[2] & 0x1) || false; return bSSE3NewInstructions; } return false; } Mysticial I've created a GitHub repro that will detect CPU and OS support