Relative Content

Tag Archive for assemblyx86

need help finding offset between esp and ebp

I am trying to understand how the offset is calculated from ebp to esp in 32-bit.
My understanding is that when you push to the stack, esp is decremented and points to a lower address, 4 bytes at a time on 32-bit. I assumed that (ebp – 4) was right to get to a1fa1fa since that is decrementing–but then I did (esp + 4 + 4 + 4 + 4) to get offset of ebp from esp, which was incorrect.

need help finding offset between esp and ebp

I am trying to understand how the offset is calculated from ebp to esp in 32-bit.
My understanding is that when you push to the stack, esp is decremented and points to a lower address, 4 bytes at a time on 32-bit. I assumed that (ebp – 4) was right to get to a1fa1fa since that is decrementing–but then I did (esp + 4 + 4 + 4 + 4) to get offset of ebp from esp, which was incorrect.

What is the result of this Assembly program?

I’m preparing for an exam where I have to find the results of x86 Assembly programs without a computer, in particular I have a problem with an example our teacher gave us:

Factorial in assembly, output not correct

section .text global _start _start: mov eax, 15 mov ebx, 1 lb: imul eax, ebx inc ebx cmp ebx,15 jl lb mov ebx, eax mov eax, 1 int 80h I am new to assembly, I have this code to calculate factorial of 15, I know exit code in ebx should be between 0 and 255 […]

segfault is emerged in x86 assembly fibonacci sequence code

fibonacci: push ebp mov ebp, esp mov ecx, eax mov eax, 1 mov ebx, 1 mov edx, 1 cmp ecx, 2 jle finale loop: mov edx, ebx mov ebx, eax add eax, edx dec ecx cmp ecx, 2 jg loop finale: ret I wanted to implement the Fibonacci sequence through x86 assembly. I pass arguments […]

Segmentation Fault in x86 Assembly

#include <string> #include <vector> using namespace std; int Min(int A, int B) { return A < B ? A : B; } int solution(string s) { int answer = s.length(); for (int Len = 1; Len <= s.length() / 2; Len++) { string Result = “”; string Temp = s.substr(0, Len); int Cnt = 1; […]