Menu

JWasm211

habran
2013-07-11
2013-07-11
  • habran

    habran - 2013-07-11

    Congrat Japheth
    great job!
    there is still a bug when option STACKBASE:RSP is used if first Local is 16 bit it is not aligned to 16 bit
    here is example:
    testproc2 PROC FRAME val:QWORD
    LOCAL myVector:XMMWORD ; here xmm0 will die..
    LOCAL xVar:QWORD

    movaps xmm0,myVector
    mov rax,val 
    mov xVar,rax 
    ret
    

    testproc2 endp

    I have solved it in my version with:
    proc.c
    line 2206

    if 1

        /* save xmm registers */
        if ( sizexmm ) {
            int i;
        if (ModuleInfo.win64_flags & W64F_STATICRSP) sizestd += 8; this solves it
            AddLineQueueX( "sub %r, %d", T_RSP, NUMQUAL sizexmm + sizestd );
            AddLineQueueX( "%r %d", T_DOT_ALLOCSTACK, NUMQUAL sizexmm + sizestd );
            sizestd = 0; /* stack is aligned now. Don't use sizestd anymore */
            regist = info->regslist;
    

    It must be fixed than here:
    expreval.c
    line 725

                if ( sym->state == SYM_STACK ) {
                  if (ModuleInfo.win64_flags & W64F_STATICRSP){               
                      struct proc_info    *info = CurrProc->e.procinfo;
                      int         cnt = info->pushed_reg;
                      if (sym->isparam == TRUE){
                            cnt = cnt<<3;
                            cnt += sym->offset + sym_ReservedStack->value + info->localsize + info->xmmsize;
                            if (!(info->xmmsize)) cnt -= 8; here is resolved
                            opnd->llvalue = cnt;
                            }
                        else 
                            opnd->llvalue = sym->offset + sym_ReservedStack->value;
                        }
                    else opnd->llvalue = sym->offset;
    
     
  • japheth

    japheth - 2013-07-11

    I assume you meant 16 bytes, not bits?

    However, isn't this a very generic issue, inherent to MOVAPS and not at all related to "frame pointer omission" or Win64? IIRC, the source operand of MOVAPS has to be 16-byte-aligned in 16- and 32-bit as well.

    Also, does your fix still work if another local variable of type QWORD is defined before the XMMWORD?

     
  • habran

    habran - 2013-07-11

    I assume you meant 16 bytes, not bits?
    yes, sorry

    does your fix still work if another local variable of type QWORD is defined before the XMMWORD?

    no, but it is logical to allocate XMMWORD in the beginning of LOCALS
    that way we can be sure that they are aligned properly

    EG if we need only XMMWORD's we don't need to write: "LOCAL dummy :QWORD" to make 16 byte alignment

     

Log in to post a comment.