microprocessors

Why is x86 little endian?

≯℡__Kan透↙ 提交于 2019-11-27 06:48:28
A real question that I've been asking myself lately is what design choices brought about x86 being a little endian architecture instead of a big endian architecture? Largely, for the same reason you start at the least significant digit (the right end) when you add—because carries propagate toward the more significant digits. Putting the least significant byte first allows the processor to get started on the add after having read only the first byte of an offset. After you've done enough assembly coding and debugging you may come to the conclusion that it's not little endian that's the strange

Negative numbers are stored as 2's complement in memory, how does the CPU know if it's negative or positive?

大城市里の小女人 提交于 2019-11-27 05:33:28
问题 -1 can be represented in 4 bit binary as (2's complement) 1111 15 is also represented as 1111. So, how does CPU differentiate between 15 and -1 when it gets values from memory? 回答1: The CPU doesn't care whether a byte holds -1 or 15 when it moves it from one place to another. There's no such thing as a "signed move" (to a location of the same size - there is a signed move for larger or smaller destinations). The CPU only cares about the representation when it does arithmetic on the byte. The

What is the role of stack in a microprocessor?

ⅰ亾dé卋堺 提交于 2019-11-27 03:36:12
问题 What is the role of stack in a microprocessor? 回答1: Stack is used largely during a function call but depending on the language and level of programming it may be used to temporarily store processor register data or other variables. Further, the stack may also be used for short-term large-scale storage of data when using recursive functions that store partial data in the stack and call themselves again. The generic use of stack is for, Return address return value parameters to called function

CPU TSC fetch operation especially in multicore-multi-processor environment

倾然丶 夕夏残阳落幕 提交于 2019-11-27 01:13:15
In Linux world, to get nano seconds precision timer/clockticks one can use : #include <sys/time.h> int foo() { timespec ts; clock_gettime(CLOCK_REALTIME, &ts); //--snip-- } This answer suggests an asm approach to directly query for the cpu clock with the RDTSC instruction. In a multi-core, multi-processor architecture, how is this clock ticks/timer value synchronized across multiple cores/processors? My understanding is that there in inherent fencing being done. Is this understanding correct? Can you suggest some documentation that would explain this in detail? I am interested in Intel Nehalem

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

What is the difference between FIQ and IRQ interrupt system?

若如初见. 提交于 2019-11-26 23:31:32
I want to know the difference between FIQ and IRQ interrupt system in any microprocessor, e.g: ARM926EJ. A feature of modern ARM CPUs (and some others). From the patent: A method of performing a fast interrupt in a digital data processor having the capability of handling more than one interrupt is provided. When a fast interrupt request is received a flag is set and the program counter and condition code registers are stored on a stack. At the end of the interrupt servicing routine the return from interrupt instructions retrieves the condition code register which contains the status of the

Instruction decoding when instructions are length-variable

最后都变了- 提交于 2019-11-26 23:03:46
问题 Here are some instructions and their corresponding encodings: 55 push %ebp 89 e5 mov %esp,%ebp 83 ec 18 sub $0x18,%esp a1 0c 9f 04 08 mov 0x8049f0c,%eax 85 c0 test %eax,%eax 74 12 je 80484b1 <frame_dummy+0x21> b8 00 00 00 00 mov $0x0,%eax 85 c0 test %eax,%eax 74 09 je 80484b1 <frame_dummy+0x21> c7 04 24 0c 9f 04 08 movl $0x8049f0c,(%esp) Today's microprocessors are often 32- or 64-bit and I guess that they usually read data from memory in 4 byte or 8 byte chunks. However, instructions can

What is a stack pointer used for in microprocessors?

冷暖自知 提交于 2019-11-26 18:56:52
问题 I am preparing for a microprocessor exam. If the use of a program counter is to hold the address of the next instruction, what is use of stack pointer? 回答1: A stack is a LIFO (last in, first out - the last entry you push on to the stack is the first one you get back when you pop) data structure that is typically used to hold stack frames (bits of the stack that belong to the current function). This includes, but is not limited to: the return address. a place for a return value. passed

Why is x86 little endian?

假如想象 提交于 2019-11-26 10:28:49
问题 A real question that I\'ve been asking myself lately is what design choices brought about x86 being a little endian architecture instead of a big endian architecture? 回答1: Largely, for the same reason you start at the least significant digit (the right end) when you add—because carries propagate toward the more significant digits. Putting the least significant byte first allows the processor to get started on the add after having read only the first byte of an offset. After you've done enough

CPU TSC fetch operation especially in multicore-multi-processor environment

ぐ巨炮叔叔 提交于 2019-11-26 09:32:42
问题 In Linux world, to get nano seconds precision timer/clockticks one can use : #include <sys/time.h> int foo() { timespec ts; clock_gettime(CLOCK_REALTIME, &ts); //--snip-- } This answer suggests an asm approach to directly query for the cpu clock with the RDTSC instruction. In a multi-core, multi-processor architecture, how is this clock ticks/timer value synchronized across multiple cores/processors? My understanding is that there in inherent fencing being done. Is this understanding correct?