Subject Computer Science Assembly Language Programming

Question

;Create a function using assembly code to compute the value of
f(x,y).

;Your function will be equivalent to the following C/C++ code.

;int f(int x,int y)
;{
;   return y - 3*(x+1);
;}

;********************************************************

SECTION .text

GLOBAL f
f:
; prolog
push ebp ; save old base pointer
mov ebp,esp ; setup new base pointer
push ebx ; preserve EBX for caller

; [ebp+8] - x (arg1)
; [ebp+12] - y (arg2)

    ; ------------------------------------------
; perform actual function calculation here

mov eax,1

    ; ------------------------------------------

; %eax = return value fib(n)

; epilog
pop ebx ; restore EBX for caller
pop ebp ; restore old base pointer
ret

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

SECTION .text

GLOBAL f
f:
; prolog
push ebp ; save old base pointer
mov ebp,esp ; setup new base pointer
push ebx ; preserve EBX for caller

; [ebp+8] - x (arg1)...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Raid Simulation Program Using Assembly Language
Homework Solution
$150.00
Assembly Language
Programming
Computer Science
Algorithms
Strings
Files
XOR
Commands
Input
Output
Bytes
System Kernel
Loop Counter
Pointers
Memory
Variables
Binomial Coefficients Program
Homework Solution
$125.00
Assembly Language Programming
Binomial Coefficients
Mathematics
Loops
Conditions
Stack
Eax
Procedures
Integers
Pseudo-Code
Algorithm
Registers
Tests
Results
Encryption Library
Homework Solution
$35.00
Computer
Science
Assembly
Language
Programming
Encryption
Library
String
Characters
Assembly & Data Representation Questions
Homework Solution
$18.00
Mantissa
Sign
Bit
Exponent
Infinity
Assembly
Language
Binary
Instruction
Register
Ebx
Ecx
Edx
Memory
Location
Content
C
Statement
Equivalent
Get help from a qualified tutor
Live Chats