Cirrus Logic CS485 Instrukcja Użytkownika Strona 19

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 67
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 18
CS485G Spring 2015 19
1 int absdiff(int x, int y)
2 {
3 int result;
4 if (x > y) {
5 result = x-y;
6 } else {
7 result = y-x;
8 }
9 return result;
10 }
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 # x = x - y
movl %edx, %eax # a = x - y
jmp .L7 # jump
.L6:
subl %edx, %eax # a = y - x
.L7:
popl %ebp # restore %ebp
ret # return
10. Example:
1 int absDiff(int x, int y)
2 {
3 int result;
4 if (x <= y) goto elsepoint;
5 result = x-y;
6 goto exitpoint;
7 elsepoint:
8 result = y-x;
9 exitpoint:
10 return result;
Przeglądanie stron 18
1 2 ... 14 15 16 17 18 19 20 21 22 23 24 ... 66 67

Komentarze do niniejszej Instrukcji

Brak uwag