I've been playing around with assembler, trying to get the basic feel for it, just for the fun of it. I'm trying just to make a function that adds two numbers and returns the result. I think I have the function correct so far, but I don't know how to return a value. So far:
using namespace std;
void addnums(short int i, short int j)
short int a;
mov ax, i
mov bx, j
add ax, bx
mov a, ax
cout << a << '
add esp, 8
Is there anything wrong so far?
Also, in this code, will i be 3, and j be 1, because of how paramaters are pushed?
Another thing, without the
[code]add esp, 8[/code]
line, the program runtime errors, and I'm not sure why this is necessary. I know that esp is the stack pointer (extended?), but why must it be after the function call?