Cirrus Logic CS485 Manual de usuario Pagina 20

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 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
Vista de pagina 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 ... 66 67

Comentarios a estos manuales

Sin comentarios