Advertisement
olgierd

ASK_ZAD7

Dec 10th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Zadanie 7: Napisz kod w asemblerze odpowiadający poniższemu fragmentowi kodu w C.
  2. //Y = a*b
  3. unsigned char a = 0x03;
  4.     unsigned char b = 0x02;
  5.     unsigned short wynik;
  6.     _asm {
  7.         mov cl, a;
  8.         mov ch, 0x0;
  9.         mov bl, b;
  10.         mov ax, 0x0;
  11.     poczatek:
  12.         test bl, 0x1;
  13.         jz skok_przez_sume;
  14.         add ax, cx;
  15.     skok_przez_sume:
  16.         shl cx, 0x1;
  17.         shr bl, 0x1;
  18.         jnz poczatek;
  19.  
  20.         mov wynik, ax;
  21.     }
  22.     printf("%d * %d = %d", a, b, wynik);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement