Motorola Axiom CMD11E1 Podręcznik Użytkownika Strona 54

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 101
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 53
54 CHAPTER 4. PROGRAMS
char v;
char total;
main() {
v = 0;
total = 0;
v = v+1;
total = total + v;
v = v+1;
total = total + v;
v = v+1;
total = total + v;
v = v+1;
total = total + v;
v = v+1;
total = total + v;
printf("%02X", (unsigned) total);
return 0;
}
2. Modify the program so that the initialization v = 0 is replaced by a call to
getchar(). Run your C program and try different inputs at the keyboard.
Make corresponding changes to the assembly language program and verify
your results.
3. Modify the assembly language program so that you use a counting loop to
loop 5 times over the basic code.
4. Modify the previous version (using a loop) where the number of times around
the loop is in an 8-bit variable called count. Your program should initialize
the variable to 5 so that the loop is executed 5 times.
5. A convenient way to get a value between 0 and 9 from the user is to use the
instruction sequence
jsr inchar
Przeglądanie stron 53
1 2 ... 49 50 51 52 53 54 55 56 57 58 59 ... 100 101

Komentarze do niniejszej Instrukcji

Brak uwag