Motorola Axiom CMD11E1 Guía de usuario Pagina 36

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 101
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 35
36 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONS
ADCA #20
STAA SEED ;don’t forget to save it back
RTS
;;;;;;;;;;;;;;;;;;;;;;;;End: RAND ;;;;;;;;;;;;;;;;;;;;
;
; DATA SECTION
;
ORG $D000
SEED FCB 0
;;;;;;;;;;;;;;;;;;;;;;;end of code ;;;;;;;;;;;;;;;;;;;;;;;;
3.4.1 On random sequences
When you are done running the program a few times, you reload the s19 file and
try again. You will get the same sequence all over again! Now this is useful when
you are debugging programs but is absolutely useless if you are writing a game
program. Every game will be 100% predictable! The way to overcome this is to
change the seed everytime you start your program in some unpredictable way.
One simple solution is to use the low order byte of the clock inside the HC11.
This clock is in locations $100E-$100F. So you can use the second location $100F
as the initial seed.
3.5 Your second function
For your second function, you will be writing a function that will print an 8-bit
value in HEX first and then in binary. We will call this function PRBINARY
An 8-bit number requires 2 hex-digits to print and BUFFALO has two routines
to help you, one to print the left digit and the other to print the right digit. These
are called OUTLHLF for out-left-half and OUTRHLF for out-right-half respectively.
To print it in binary, we will use the shift left instruction LSL . This instruction
will shift all bits left by 1 place and the (left most) bit that is shifted out will be
stored in the carry flag. I.e. if an 8-bit value before shifting was
abcdefgh
then
the value after shifting will be bcdefgh0. Here each of the letters a to h represent
bits. The carry flag will be set to a. Thus the value to be printed will be shifted
left 8 times. After each shift, the A register will be loaded with either the ascii
Vista de pagina 35
1 2 ... 31 32 33 34 35 36 37 38 39 40 41 ... 100 101

Comentarios a estos manuales

Sin comentarios