Here is the problem...
Write a subroutine ADDABC that performs the operation C:=A+B. Variables A,B,C are all word (ie. 16bit) values. Test you program on the 68k simulator.
The calling code should have the following features:
-Parameter a and b should be passed on the stack to the procedure by reference.
-Since parameter a and b are adjacent in memory, you need to pass only the address of parameter A to the subrouting (the address of b is 2 bytes away from parameter a)
-parameter c should be passed back tot he calling program on the stack by value
-before calling the subroutine, make room on the stack for the returned parameter(c)
-after calling the subroutine, read the parameter off the stack into data register d0. (it should end up containing a + b.
-subroutine ADDABC must not corrupt and registers. Save all working registers on the stack on entry to the subroutine and restore them before returning from the subroutine.
Ok, umm?.general start:
ORG $400
LEA $1500, A7 //SET UP THE STACK POINTER WITH AN EASY VLUE
----- // PASS THE PARAMETERS
BSR ADDABC //CALL THE SUBROUTINE
----- GET THE RESULT, C, IN D0
----- CLEAN UP THE STACK
STOP $#2700
*
ADDABC ------
-------
RTS
*
ORG $1200
A DC.W $1234
B DC.W $ABAB
END $400
----
any ideas on how to do this?
Write a subroutine ADDABC that performs the operation C:=A+B. Variables A,B,C are all word (ie. 16bit) values. Test you program on the 68k simulator.
The calling code should have the following features:
-Parameter a and b should be passed on the stack to the procedure by reference.
-Since parameter a and b are adjacent in memory, you need to pass only the address of parameter A to the subrouting (the address of b is 2 bytes away from parameter a)
-parameter c should be passed back tot he calling program on the stack by value
-before calling the subroutine, make room on the stack for the returned parameter(c)
-after calling the subroutine, read the parameter off the stack into data register d0. (it should end up containing a + b.
-subroutine ADDABC must not corrupt and registers. Save all working registers on the stack on entry to the subroutine and restore them before returning from the subroutine.
Ok, umm?.general start:
ORG $400
LEA $1500, A7 //SET UP THE STACK POINTER WITH AN EASY VLUE
----- // PASS THE PARAMETERS
BSR ADDABC //CALL THE SUBROUTINE
----- GET THE RESULT, C, IN D0
----- CLEAN UP THE STACK
STOP $#2700
*
ADDABC ------
-------
RTS
*
ORG $1200
A DC.W $1234
B DC.W $ABAB
END $400
----
any ideas on how to do this?