assembly

Non-recursive Fibonacci Sequence in Assembly

梦想与她 提交于 2021-02-11 15:45:04
问题 In some homework, I have to create a Fibonacci Sequence program in Assembly. I created this code, but it doesn't seem to be working correctly and I am not sure as to why. I believe that I am doing this correctly, but EAX remains "2" every loop. INCLUDE Irvine32.inc .data prev DWORD ? next DWORD ? val DWORD ? count DWORD ? total DWORD ? myMsg BYTE "Fibonacci Sequence ",0dh,0ah,0 .code main PROC mov ecx,15 mov val,1 mov prev,-1 mov eax,1 mov edx,OFFSET myMsg call WriteString L1: mov count,ecx

Who creates and owns the call stack and how does call stack works in multithread?

牧云@^-^@ 提交于 2021-02-11 15:19:54
问题 I know that each thread usually have one call stack, which is just a chunk of memory and controlled by using esp and ebp. 1, how are these call stacks created and who's responsible for doing this? My guess is the runtime, for example Swift runtime for iOS application. And is it the thread directly talks to its own call stack by esp and ebp or through runtime? 2, for each call stack, they have to work with the esp and ebb cpu registers, if I have a CPU with 2 cores 4 threads, then let's say it

How to understand macro `likely` affecting branch prediction?

吃可爱长大的小学妹 提交于 2021-02-11 13:59:49
问题 I noticed if we know there is good chance for control flow is true or false, we can tell it to compiler, for instance, in Linux kernel, there are lots of likely unlikely , actually impled by __builtin_expect provided by gcc , so I want to find out how does it work, then checked the assembly out there: 20:branch_prediction_victim.cpp **** if (array_aka[j] >= 128) 184 .loc 3 20 0 is_stmt 1 185 00f1 488B85D0 movq -131120(%rbp), %rax 185 FFFDFF 186 00f8 8B8485F0 movl -131088(%rbp,%rax,4), %eax

Understanding ARM relocation (example: str x0, [tmp, #:lo12:zbi_paddr])

左心房为你撑大大i 提交于 2021-02-11 13:21:58
问题 I found this line of assembly in zircon kernel start.S str x0, [tmp, #:lo12:zbi_paddr] for ARM64. I also found that zbi_paddr is defined in C++: extern paddr_t zbi_paddr; So I started looking about what does #:lo12: mean. I found https://stackoverflow.com/a/38608738/6655884 which looks like a great explanation, but it does not explain the very basic: what is a rellocation and why some things are needed. I guess that since zbi_paddrr is defined in start.S and used in C++ code, since start.S

Understanding ARM relocation (example: str x0, [tmp, #:lo12:zbi_paddr])

一个人想着一个人 提交于 2021-02-11 13:21:56
问题 I found this line of assembly in zircon kernel start.S str x0, [tmp, #:lo12:zbi_paddr] for ARM64. I also found that zbi_paddr is defined in C++: extern paddr_t zbi_paddr; So I started looking about what does #:lo12: mean. I found https://stackoverflow.com/a/38608738/6655884 which looks like a great explanation, but it does not explain the very basic: what is a rellocation and why some things are needed. I guess that since zbi_paddrr is defined in start.S and used in C++ code, since start.S

Execution freezes when I try to allocate Array in Armv8 assembly

你。 提交于 2021-02-11 13:14:55
问题 So I am programming in assemply, this is just a simple code so I can learn how to allocate arrays in order to use them on NEON programming later. ASM_FUNC(FPE) .data .balign 8 array: .skip 80 array1: .word 10,20,30,40 .text ldr x0,=array mov x1,#10 check: cmp x1,#1 bne loop b exit loop: str x1,[x0],#8 //Stores the value in x1 into x0 and moves the address +8 bytes sub x1,x1,#1 //x1-- b check exit: mov x0,#11 ret So, some parts are commented so I could try to find where the code is breaking (I

Execution freezes when I try to allocate Array in Armv8 assembly

这一生的挚爱 提交于 2021-02-11 13:14:28
问题 So I am programming in assemply, this is just a simple code so I can learn how to allocate arrays in order to use them on NEON programming later. ASM_FUNC(FPE) .data .balign 8 array: .skip 80 array1: .word 10,20,30,40 .text ldr x0,=array mov x1,#10 check: cmp x1,#1 bne loop b exit loop: str x1,[x0],#8 //Stores the value in x1 into x0 and moves the address +8 bytes sub x1,x1,#1 //x1-- b check exit: mov x0,#11 ret So, some parts are commented so I could try to find where the code is breaking (I

Execution freezes when I try to allocate Array in Armv8 assembly

戏子无情 提交于 2021-02-11 13:14:17
问题 So I am programming in assemply, this is just a simple code so I can learn how to allocate arrays in order to use them on NEON programming later. ASM_FUNC(FPE) .data .balign 8 array: .skip 80 array1: .word 10,20,30,40 .text ldr x0,=array mov x1,#10 check: cmp x1,#1 bne loop b exit loop: str x1,[x0],#8 //Stores the value in x1 into x0 and moves the address +8 bytes sub x1,x1,#1 //x1-- b check exit: mov x0,#11 ret So, some parts are commented so I could try to find where the code is breaking (I

How do I raise a number x to the power y in MARIE?

纵然是瞬间 提交于 2021-02-11 12:38:14
问题 I'm trying to create a MARIE program that raises a number (x) to a power (y) and provides an output. I have tried many alterations of the idea I have in mind but I am still facing errors. The code below is the closest I have gotten to solving this problem INPUT STORE X STORE XNUM INPUT STORE Y MULTIPLIERA,LOAD PROD ADD X STORE PROD LOAD XNUM SUBT ONE STORE XNUM SKIPCOND 400 JUMP MULTIPLIERA JUMP NEWPRODUCT NEWPRODUCT, LOAD X STORE XNUM LOAD PROD STORE X LOAD Y SUBT ONE STORE Y SKIPCOND 400

DosBox is buggy with int 15h ah = 86h

你。 提交于 2021-02-11 08:46:36
问题 I am currently working on an assembly program, but I need to make the program wait every once in a while. So, I have been using int 15h/ah = 86h, but for some reason DosBox is giving me a hard time, and the program either gets confused with pixels (wierd colors) or in the worse case; crash. Can someone please help me? 回答1: I had this issue as well. Based on the answer at Problems with BIOS delay function (INT 15h / AH = 86h), I was able to get it working by making sure to set AL to zero