Cirrus Logic CS485 Manuel d'utilisateur Page 20

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 67
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 19
CS485G Spring 2015 20
absDiff:
pushl %ebp # save base pointer
movl %esp,%ebp # new base pointer
movl 8(%ebp), %edx # d = x
movl 12(%ebp), %eax # a = y
cmpl %eax, %edx # x <> y?
jle .L6 # jump if x <= y
subl %eax, %edx # d = x - y
movl %edx, %eax # a = x - y
jmp .L7 # goto exitpoint
.L6: # elsepoint
subl %edx, %eax # a = y - x
.L7: # exitpoint
popl %ebp # restore %ebp
ret # return
11. C can sometimes use a single conditional expression to han-
dle such cases:
1 val = x>y ? x-y : y-x;
21 do while loops
1. C code to count how many 1’s in a parameter
1 int countOnes(unsigned x) {
2 int result = 0;
3 do {
4 result += x & 0x1;
5 x >>= 1;
6 } while (x);
7 return result;
8 }
2. Same thing, represented with goto
Vue de la page 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 ... 66 67

Commentaires sur ces manuels

Pas de commentaire