Thread: asmcode->c-fkt

  1. #1
    Registered User
    Join Date
    Dec 2002


    I have this code:
    proc	_gegeben1_171202asm
    ;Dies ist die gegebene ASM Prozedur fuer die 1.Aufgabe im Modul 1A171202.C.
    ;Dort ist der C   Aufruf dieser gegebenen ASM Prozedur zu programmieren.
    ;Die Prozedur hat einen Rueckgabewert.
    push bp
    mov	 bp,sp
    push di
    	mov	al,[bp+6]	;signed char
    	cbw			;ax=signed int
    	cwd			;dx,ax=signed long int
    	push	ax
    	call	[word ptr bp+8]
    	add	sp,2
    	mov  di,[bp+4]
    	fstp [qword ptr di]     ;store and pop
    pop	di
    mov	sp,bp
    pop	bp
    endp	_gegeben1_171202asm
    I have to program a call in c of this asm-code.
    The solution is:

    //variables i have got
    signed char s_c1;
    double d1;
    signed long int s_l1;
    s_l1 = gegeben1_171202asm (&d1,s_c1,proz);
    I unterstand the order of the parameters, s_c1 and proz, but i don`t understand, why i have a "*d1" instead of "d1" and why the surrender value is from type "long int" instead of "double"(qword is the lenght of a double)
    I hope somebody can helps me.

    many thanks in advance.


  2. #2
    Registered User
    Join Date
    Dec 2002
    today, i got the explanation.
    if somebody is interest in that:
    1) i can only intepret the surrender value. In this example you can read it by this line: "cwd ;dx,ax=signed long int"
    2) double has a length of two words. a pointer has a length of one word.
    my mistake: i thought that my double is from bp+2 up to bp+6. but thats wrong. bp+4 means from bp+2 up to bp+4 (one word). because of fstp(it`s only for double and float) and qword(length of double) it`s a pointer of a double


Popular pages Recent additions subscribe to a feed