asmcode->c-fkt

This is a discussion on asmcode->c-fkt within the C Programming forums, part of the General Programming Boards category; Hello I have this code: Code: proc _gegeben1_171202asm ;Dies ist die gegebene ASM Prozedur fuer die 1.Aufgabe im Modul 1A171202.C. ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    13

    asmcode->c-fkt

    Hello
    I have this code:
    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
    ret
    endp	_gegeben1_171202asm
    I have to program a call in c of this asm-code.
    The solution is:

    Code:
    //variables i have got
    signed char s_c1;
    double d1;
    (*proz)(int)
    signed long int s_l1;
    
    //call
    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.

    regards
    sphreak

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    13
    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

    regards

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21