hi people
i ve created a function that display texts in color. I import this function to C programe and works fine.
but the problem here is that i want to pass the msg,and other registers (like bl,cx,dh,dl) as arguments to c function
how can i do that ?????
but their is another problem this function works with tasm v 5.0. i'm currently working with tasm. but i'm using this forum to learn
assembly ,windows programming (with api).am i breaking the rules of this forum?? if so i'm sorry guys..
anyway here is the function
;----------------------------------------------------------------------------------------------------------------------------------;
; INPUTS ; ; ;
; al = subservice(1-3) ; ; ;
; bh = display page ;
; bl = color(Attributes) ;
; cx = length of the string ;
; dh = row postion ;
; dl = col position ;
; ;
; ;
; set bl= 0-black,1-blue,2-green,3-cyan,4-red,5-vilot,6-brown,7-white8-Grey ,9-Bri blue, ;
; 10-bri green,11-bir cyan,12-bri red,13-bri violet,14-bri yellow,15-bri white ;
;---------------------------------------------------------------------------------------------------------------------------------;
msg DB 'This is an Assebmly function' ; this should be in data segment
PROC _Cprint NEAR
push ax
push bx
push cx
push dx
xor ax,ax ;clears the ax register
mov ah,13h ;call the func 13h
mov al,0 ;subservice (1-3)
mov bh,0 ;display page
mov bl,14 ;Attribs (sub ser 0 and 1)
mov cx,28 ;length of the string
mov dh,8 ;col position to write string
mov dl,14 ;row position to write string
push ds
pop es
mov bp,offset msg
int 10h
pop dx
pop cx
pop bx
pop dx
ret
endp _Cprint
END
C functions have to follow the C calling convention - that means you push your parameters on the stack (in reverse, as usual), call the function, then fix the stack-pointer when it returns.
So your arguments must be on the stack, not as registers :P
(There may be a way to fiddle with the c-compiler and tell it to use the registers, but following the calling-convention is easiest :wink)
anuradha,
You are not breaking the rules of the forum. There is nothing wrong with your question.