Menu

Structure Error

vengy
2013-04-02
2013-04-20
  • vengy

    vengy - 2013-04-02

    Hi,

    Strange Struct Bug?

    StructBug.asm(26) : Error A2145: INVOKE argument type mismatch: argument 1
    StructBug.asm: 44 lines, 1 passes, 15 ms, 0 warnings, 1 errors

    Why does jwasm report Error A2145?

    See simple code example below:

    Thanks!

    ;--- assemble: JWasm -coff /FlStructBug.lst StructBug.asm
        .386
        .MODEL FLAT, stdcall
        option casemap:none
    ExitProcess   proto :dword
    MySub PROTO :DWORD
    MyStructA STRUCT
    FieldA DWORD ?
    MyStructA ENDS
    MyStructB STRUCT
    FieldA DWORD ?
    FieldB DWORD ?
    MyStructB ENDS
        .CODE
    main proc c
        INVOKE MySub,MyStructA
    ;why does MyStructB generate an error but MyStructA doesn't
        INVOKE MySub,MyStructB
        ret
    main endp
    MySub PROC argA:DWORD
    RET
    MySub ENDP
    ;--- entry
    mainCRTStartup proc c
        invoke  main
        invoke  ExitProcess, eax
    mainCRTStartup endp
        END mainCRTStartup
    
     
  • japheth

    japheth - 2013-04-03

    > Why does jwasm report Error A2145?

    It's a bug - a struct name as argument for INVOKE is supposed to push the struct's size. jwasm erroneously checks this size and wants it to match the parameter's size.

    workaround: use SIZEOF before the struct name: invoke MySub, sizeof MyStructB

     
  • vengy

    vengy - 2013-04-03

    Thanks for the quick response.
    Took a QUICK look at Invoke.c - INVOKE_ARGUMENT_TYPE_MISMATCH
    If you have a the general area of where the bug is, I can try to resolve it. :)

     
  • japheth

    japheth - 2013-04-03

    > If you have a the general area of where the bug is, I can try to resolve it. :)

    Thanks for the offer, but this bug is relatively simple to fix! The next prerelease will contain this fix in invoke.c:

                    asize = SizeFromRegister( opnd.base_reg->tokval );
                //} else if ( opnd.mem_type == MT_EMPTY ) { /* v2.10: a TYPE may return mem_type != MT_EMPTY! */
                } else if ( opnd.kind == EXPR_CONST || opnd.mem_type == MT_EMPTY ) {
                    asize = psize;
    
     
  • vengy

    vengy - 2013-04-03

    Tested it and it works…. Thanks again!

     

Log in to post a comment.