return a value in asm functions
Posted: Tue Apr 06, 2010 12:13 pm
hey, I've just learned some basic asm and c. I've programmed a basic 16bit x86 os, but I'm trying to write a function in asm that'll return a byte.
I want to be able to call the function from c code like this:
The code I have for the asm function right now is:
However the code currently isn't working. Any ideas what's going on.
Im under the impression that the data in ah is the return value of the function... or am I mistaken?
I want to be able to call the function from c code like this:
Code: Select all
char a;
a = pullFromMemory(0xB000, 0x8000);
Code: Select all
.global _pullFromMemory
;char pullFromMemory (int segment, int address)
_pullFromMemory:
push bp
mov bp,sp
push ds
mov ax,[bp+4]
mov si,[bp+6]
mov ds,ax
mov cl,[si]
mov al,cl
mov al,#0 ;we only want Ah returned
pop ds
pop bp
ret
Im under the impression that the data in ah is the return value of the function... or am I mistaken?