Advertisement
Guest User

Try Add with Carry

a guest
Dec 1st, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>                                                              
  2. #include <stdint.h>                                                            
  3. #include <inttypes.h>                                                          
  4.                                                                                
  5. int main(void) {                                                                
  6.                                                                                
  7. int64_t a    = 9223372036854775807;                                            
  8. int64_t b    = 1;                                                              
  9. int64_t res  = 0;                                                              
  10. int64_t res2 = 0;                                                              
  11. int64_t c = 0;                                                                  
  12.                                                                                
  13.   asm("addc. %0, %1, %2 \n"                                                      
  14.       : "=r"(res)                                                              
  15.       : "a"(a), "b"(b));                                                        
  16.                                                                                
  17.   asm("lis %0, 256 \n"                                                          
  18.       "ori %0, %0, 7552 \n"                                                    
  19.       "rldicr %0, %0,16,47 \n"                                                  
  20.       "ori %0,%0,7596 \n"                                                      
  21.       "nop \n"                                                                  
  22.       "bc 0xC,3,there\n"                                                        
  23.       "here:  addi %1, %1, 10\n"                                                
  24.       "there: addi %1, %1, 42 \n"                                              
  25.       : "=r"(res2),"=r"(c)                                                      
  26.       : "a"(c));                                                                
  27.                                                                                
  28.   printf("%" PRId64 "\n", res);                                                
  29.   printf("%" PRId64 "\n", res2);                                                
  30.   printf("%" PRId64 "\n", c);                                                  
  31.   return 0;                                                                    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement