Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include "reg51.h"
  2.  
  3. int main()
  4. {
  5.     unsigned char A, B;
  6.     unsigned int S;
  7.     unsigned int R;
  8.     int i;
  9.    
  10.     A = P0;
  11.     B = P1;
  12.    
  13.     if(A > B) return -1;
  14.     S = 0;
  15.     R = A;
  16.     for(i = 8; i > 0; i--) {
  17.         R *= 2;
  18.         S *= 2;
  19.         if (R / B != 0) {
  20.             R -= B;
  21.             S += 1;
  22.         }
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement