Motorola Axiom CMD11E1 Guía de usuario Pagina 54

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 101
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 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
Vista de pagina 53
1 2 ... 49 50 51 52 53 54 55 56 57 58 59 ... 100 101

Comentarios a estos manuales

Sin comentarios