qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

test_addc.c (723B)


      1 #include <stdio.h>
      2 
      3 int main(void)
      4 {
      5     int a, b, c;
      6     int result;
      7 
      8     b = 0x01;
      9     c = 0xffffffff;
     10     result = 0;
     11     __asm
     12     ("l.add r1, r1, r0\n\t" /* clear carry */
     13      "l.addc   %0, %1, %2\n\t"
     14      : "=r"(a)
     15      : "r"(b), "r"(c)
     16     );
     17     if (a != result) {
     18         printf("first addc error\n");
     19         return -1;
     20     }
     21 
     22     b = 0x01;
     23     c = 0xffffffff;
     24     result = 0x80000001;
     25     __asm
     26     ("l.add r1, r1, r0\n\t" /* clear carry */
     27      "l.addc   %0, %1, %2\n\t"
     28      "l.movhi  %2, 0x7fff\n\t"
     29      "l.ori    %2, %2, 0xffff\n\t"
     30      "l.addc   %0, %1, %2\n\t"
     31      : "=r"(a)
     32      : "r"(b), "r"(c)
     33     );
     34     if (a != result) {
     35         printf("addc error\n");
     36         return -1;
     37     }
     38 
     39     return 0;
     40 }