instructions

Create Delay in Arduino Uno using Assembly language without using timer

佐手、 提交于 2019-11-27 15:54:43
I just started learning about micro controllers and I was not able to understand how we could introduce delays in the code without using timers. My board has a clock of 16MHZ. Let's say I want to introduce 5ms delay before I check if a button is pressed. How would I identify how many instructions I need to execute to get 5 ms delay and how would I program it? Is there a standardized way of doing this? It looks like a very standard thing but I am not able to understand how it is done. I am programming using Assembly language on Atmega 328 Arduino uno. Generally you figure out how many clock

Number of executed Instructions different for Hello World program Nasm Assembly and C

吃可爱长大的小学妹 提交于 2019-11-27 15:47:36
I have a simple debugger (using ptrace : http://pastebin.com/D0um3bUi ) to count the number of instructions executed for a given input executable program. It uses ptrace single step execution mode to count instructions. For that when the program 1)'s executable (a.out from gcc main.c) is given as input to my test debuggger it prints around 100k as instructions executed. When I use -static option it gives 10681 instructions. Now in 2) I create an assembly program and use NASM for compiling and linking and then when this executable is given as test debuggers input it is showing 8 instructions as

What x86 instructions take two (or more) memory operands?

不打扰是莪最后的温柔 提交于 2019-11-27 09:35:33
I thought that there was zero. But, I see here, Instructions with two memory operands are extremely rare I can't find anything that explains what instructions, though rare, exist. What are the exceptions? Peter Cordes I can't find anything that explains the rarity. An x86 instruction can have at most one ModR/M + SIB + disp0/8/32. So there are zero instructions with two explicit memory operands. The x86 memory-memory instructions all have at least one implicit memory operand whose location is baked in to the opcode, like push which accesses the stack, or the string instructions movs and cmps .

C code loop performance

时间秒杀一切 提交于 2019-11-27 09:17:19
问题 I have a multiply-add kernel inside my application and I want to increase its performance. I use an Intel Core i7-960 (3.2 GHz clock) and have already manually implemented the kernel using SSE intrinsics as follows: for(int i=0; i<iterations; i+=4) { y1 = _mm_set_ss(output[i]); y2 = _mm_set_ss(output[i+1]); y3 = _mm_set_ss(output[i+2]); y4 = _mm_set_ss(output[i+3]); for(k=0; k<ksize; k++){ for(l=0; l<ksize; l++){ w = _mm_set_ss(weight[i+k+l]); x1 = _mm_set_ss(input[i+k+l]); y1 = _mm_add_ss(y1

Out-of-order instruction execution: is commit order preserved?

点点圈 提交于 2019-11-27 02:27:00
问题 On the one hand, Wikipedia writes about the steps of the out-of-order execution: Instruction fetch. Instruction dispatch to an instruction queue (also called instruction buffer or reservation stations). The instruction waits in the queue until its input operands are available. The instruction is then allowed to leave the queue before earlier, older instructions. The instruction is issued to the appropriate functional unit and executed by that unit. The results are queued. Only after all older

What is the 0x10 in the “leal 0x10(%ebx), %eax” x86 assembly instruction?

旧巷老猫 提交于 2019-11-27 01:24:52
What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else? leal 0x10(%ebx), %eax Can someone please clarify? This is x86 assembler on a Linux box. leal, or lea full name is "Load effective address" and it does exactly this: It does an address calculation. In your example the address calculation is very simple, because it just adds a offset to ebx and stores the result in eax: eax = ebx + 0x10 lea can do a lot more. It can add registers, multiply registers with the constants 2, 4 and 8 for address calculations of words, integers and

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

What x86 instructions take two (or more) memory operands?

天大地大妈咪最大 提交于 2019-11-26 11:38:13
问题 I thought that there was zero. But, I see here, Instructions with two memory operands are extremely rare I can\'t find anything that explains what instructions, though rare, exist. What are the exceptions? 回答1: I can't find anything that explains the rarity. An x86 instruction can have at most one ModR/M + SIB + disp0/8/32. So there are zero instructions with two explicit memory operands. The x86 memory-memory instructions all have at least one implicit memory operand whose location is baked

What is the 0x10 in the “leal 0x10(%ebx), %eax” x86 assembly instruction?

与世无争的帅哥 提交于 2019-11-26 09:36:45
问题 What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else? leal 0x10(%ebx), %eax Can someone please clarify? This is x86 assembler on a Linux box. 回答1: leal, or lea full name is "Load effective address" and it does exactly this: It does an address calculation. In your example the address calculation is very simple, because it just adds a offset to ebx and stores the result in eax: eax = ebx + 0x10 lea can do a lot more. It can add

Which arithmetic operations are the same on unsigned and two&#39;s complement signed numbers?

末鹿安然 提交于 2019-11-26 04:56:31
问题 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