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

$30.00

or $1 if you
register a new account!

Related Homework Solutions

Get help from a qualified tutor
Live Chats