Motorola Axiom CMD11E1 Guía de usuario Pagina 37

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 101
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 36
3.5. YOUR SECOND FUNCTION 37
code for 0 or the code for 1 depending on whether the carry is cleared or set
5
.
Note the function involves a counting loop.
We now have to decide register usage: We will use the A register to pass the
value to the function. Internally, this value will be moved to B as A is needed in
all the calls to BUFFALO routines. We need a counter, and we will use the X
register to keep count. As a good programming practice, we will store and restore
all registers we will use.
Here is the complete code for the function.
;;;;;;;;;;;;;;;;;;;;;Start: PRBINARY;;;;;;;;;;;;;;;;;;;;
; Function: PRBINARY
; Purpose: To print a value in binary
;
; Inputs: Value to be printed is passed in the A register
;
; Returns: None
;
; Registers affected: None. The values in the registers are stored
; first and these values are restored at the end.
;
; Notes: The output consists of two parts. The value in A is first
; printed in HEX, and then in binary
;
PRBINARY
; first save the registers we will be using: a, b and x
PSHA
PSHB
PSHX
; copy a to be for later use
TAB
; print a as hex number (2 digits).
; print the left digit
JSR OUTLHLF
5
Conveniently, the code for 1 is one more than the code for 0. So we load A with the code
for 0 and add the carry to it
Vista de pagina 36
1 2 ... 32 33 34 35 36 37 38 39 40 41 42 ... 100 101

Comentarios a estos manuales

Sin comentarios