Does not truncate 32-bit variables when used in 16-bit computation

XMLWordPrintable

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Not Prioritized

      The attached test case has these two source lines ...

          iTempLAAx = (int)((int)CurU - (int)32612);
          ...
          iTempLAAx = (int)((int)CurW - (int)32612);
      

      Build it ...

      % cl2000 -@options.txt file.c
      

      Inspect the assembly code associated with these statements. Here is the code for the first statement ...

      ;----------------------------------------------------------------------
      ; 21044 | iTempLAAx = (int)((int)CurU - (int)32612);
      ;----------------------------------------------------------------------
              MOVL      ACC,@_CurU            ; [CPU_ALU] |21044| 
              SETC      SXM                   ; [CPU_ALU] 
              SUB       AL,#32612             ; [CPU_ALU] |21044| 
              MOV       ACC,AL                ; [CPU_ALU] |21044| 
              MOVL      *-SP[2],ACC           ; [CPU_ALU] |21044| 
      

      CurU is a 32-bit global variable. All of it is loaded into the accumulator. But because of the (int) cast, only the lower part should be loaded.

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-2940 - Does not truncate 32-bit variables ...
                SYNCHRONIZED
                • Last Sync Date: