assembly

Assembly copying from one array to another

独自空忆成欢 提交于 2020-02-06 07:24:26
问题 and sorry for the title, i couldn't imagine a way to express this in english. So i'm writing a little game in assembly for a course, and, inside of two for loops, i copy the pixel data from the "bomb" vector of pixels, to the "area" vector of pixels, which will later be drawn to the screen. In C, it should look like this: int x, y; for(int i=0;i<32;i++) for(int j=0;j<32;j++) area[x+i][y+j]=bomb[i][j]; Using masm assembler and notepad++ to write the code, i got mov ecx, 0 ; my i outerloop: cmp

How to obtain reliable Cortex M4 short delays

蓝咒 提交于 2020-02-06 04:54:34
问题 I am porting some code from an M3 to an M4 which uses 3 NOPs to provide a very short delay between serial output clock changes. The M3 instruction set defines the time for a NOP as 1 cycle. I notice that NOPs in the M4 do not necessarily delay any time at all. I am aware that I will need to disable compiler optimisation but I'm looking for a low level command that will give me reliable, repeatable times. In practice in this particular case the serial is used very occasionally and could be

problems while importing freeRTOS to AT32UC3A0512

梦想的初衷 提交于 2020-02-06 04:22:13
问题 i am attempting to integrate freeRTOS to my application that run on AT32UC3A0512. I downloaded a freeRTOS project example for EVK1100 (it Supports the AT32UC3A) and try to include the kernel source file so my application hierarchy looks like : src |ASF |APP_FOLDER |freertos |freertos-7.0.0 this hierarchy is different than the the hierarchy provided in the freeRTOS project example which looks like src |ASF |thirdparty |freertos |freertos-7.0.0 /********** freertos-7.0.0 is under ASF***********

How to add numbers and display them to the console in a bootloader?

删除回忆录丶 提交于 2020-02-05 15:49:28
问题 I'm creating bootloader that should plus 512 to variable and print result until reaching the specified number. For me, it is 4194304, but the problem is that I really don't understand how to plus these numbers, because at the end I always get nothing or corrupted string. So how should I plus numbers correct? cpu 386 bits 16 org 0h start: cld xor ax,ax mov ss,ax mov sp,7c00h ; setup stack mov ax,8000h mov es,ax ; initialize es w/ 8000h mov ds,ax ; initialize ds w/ 8000h ;======================

ADD or SUB with only two operands in ARM

∥☆過路亽.° 提交于 2020-02-05 08:31:27
问题 I am learning ARM Assembly Language. I'v read ADD should have 3 operands. However, I'v seen many cases in reality there are only two. such as: STR R1, [SP,#0x20+var_1C] LDR R1, =(a_lua - 0x1DE4E6) MOVS R0, R4 ; haystack ADD R1, PC BLX strstr CMP R0, #0 BNE loc_1DE4FA Can any one help me with the meaning of ADD with two operands? Many thanks! 回答1: Given the information in the comments that this really is ARM code, not 16-bit Thumb, then the answer is that your reference material predates UAL.

FPTAN Example x86

僤鯓⒐⒋嵵緔 提交于 2020-02-05 06:15:07
问题 According to Intel documentation, this is what FPTAN does: Replace ST(0) with its approximate tangent and push 1 onto the FPU stack. And this is a code I wrote in NASM: section .data fVal: dd 4 fSt0: dq 0.0 fSt1: dq 0.0 section .text fldpi fdiv dword[fVal] ; divide pi by 4 and store result in ST(0). fptan fstp qword[fSt0] ; store ST(0) fstp qword[fSt1] ; store ST(1) At this point the values of fSt0 and fSt1 , I find are: fSt0 = 5.60479e+044 fSt1 = -1.#IND But, shouldn't fSt0 and fSt1 be both

How can I Move Two Words Into a Double Word Variable?

↘锁芯ラ 提交于 2020-02-05 05:36:48
问题 How can I go about moving two words into a double word variable? Specifically, I would like one word to go in the top-half of this variable, and the other to go in the bottom half. 回答1: Next code does the job (explanation comes right after) : .stack 100h .data upper dw 195 lower dw 22 .code mov ax, @data mov ds, ax ;MOVE TWO WORDS TO ONE DWORD. mov ax, upper mov cl, 16 shl eax, cl mov ax, lower mov ax, 4c00h int 21h Using register EAX, you assign the upper word to AX. AX is the lower word of

Stacks in MIPS. What is the purpose of 4 in addi $sp,$sp,-4?

。_饼干妹妹 提交于 2020-02-03 10:38:53
问题 I am studying a MIPS code that uses procedure but I can not understand what is the purpose of stack (sp) and frame pointer (fp). For example the code I study have this below. It prints the all the numbers before the number you entered, e.g. 3. 3,2,1,0 and shows how much stack size it used. In this example it used 16. I changed the -4 to -8 and I got an error. However, I noticed some other codes that uses -8 . The question is what am I missing? proc: addi $sp,$sp,-4 # sw $ra,0($sp) # push $ra

Why don't x86 16-bit addressing modes have a scale factor, while the 32-bit version has it?

爷,独闯天下 提交于 2020-02-03 09:39:28
问题 I'm trying to figure out a reason for the scale factor not being present in the x86 16-bit addressing modes (MASM assembly). While the 32-bit and 64-bit addressing modes have a scale factor. Is there an actual reasoning behind this or it doesn't need it? I would appreciate it if you could explain. All possible ways different components can be combined to create an effective address: Differences between 16- and 32-bit addressing modes 回答1: 16-bit addressing modes only allow a single ModRM byte

How does this program know the exact location where this string is stored?

断了今生、忘了曾经 提交于 2020-02-03 04:28:07
问题 I have disassembled a C program with Radare2. Inside this program there are many calls to scanf like the following: 0x000011fe 488d4594 lea rax, [var_6ch] 0x00001202 4889c6 mov rsi, rax 0x00001205 488d3df35603. lea rdi, [0x000368ff] ; "%d" ; const char *format 0x0000120c b800000000 mov eax, 0 0x00001211 e86afeffff call sym.imp.__isoc99_scanf ; int scanf(const char *format) 0x00001216 8b4594 mov eax, dword [var_6ch] 0x00001219 83f801 cmp eax, 1 ; rsi ; "ELF\x02\x01\x01" 0x0000121c 740a je