How bad am I doing with x86 assembly? #143697
-
BodySECTION .text
GLOBAL _addIntegers
GLOBAL _subIntegers
GLOBAL _mulInteger
GLOBAL _divInteger
_addIntegers:
push ebp
mov ebp, esp
mov eax, [ebp + 8]
mov ebx, [ebp + 16]
add eax, ebx
mov esp, ebp
pop ebp
ret
_subIntegers:
push ebp
mov ebp, esp
mov eax, [ebp + 8]
mov ebx, [ebp + 16]
sub eax, ebx
mov esp, ebp
pop ebp
ret
_mulInteger:
push ebp
mov ebp, esp
mov eax, [ebp + 8]
mul eax
mov esp, ebp
pop ebp
ret
_divInteger:
push ebp
mov ebp, esp
mov eax, [ebp + 8]
div eax
mov esp, ebp
pop ebp
ret Guidelines
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
There are some issues in your x86 assembly code, as well as a few improvements that can be made. Let's examine each function:
With these adjustments, your functions should work properly. Here’s a quick summary of each:
Overall, you're on the right track! Just a few tweaks are required for the multiplication and division functions to work correctly. |
Beta Was this translation helpful? Give feedback.
-
thank you. |
Beta Was this translation helpful? Give feedback.
There are some issues in your x86 assembly code, as well as a few improvements that can be made. Let's examine each function:
General Structure:
ebp
and setting up the stack), but there are some things that need fixing.Addition Function (
_addIntegers
):eax
.Subtraction Function (
_subIntegers
):Multiplication Function (
_mulInteger
):mul
instruction. Themul
instruction does not take an ar…