
3.4. WRITING YOUR FIRST FUNCTION 35
You use FCB to initialize consecutive memory loication (when you transfer the
code from the PC). The label associated with the instruction is needed to deter-
mine the address where the instruction forms the constant. The assembler will
automatically EQUate the label with the address associated with the FCB directive.
Type the following code, assemble it, transfer the S19 file to the HC11, and
test your program by CALL $C100. Repeat
4
the CALL statement and verify that
the value in the A changes after each call.
;;;;;;;;;;;;;;;;;;;;;;;start of code ;;;;;;;;;;;;;;;;;;;;;;;;
ORG $C100
JSR RAND
SWI
;;;;;;;;;;;;;;;;;;;;;;;;Start: RAND ;;;;;;;;;;;;;;;;;;
; Function: RAND
; Purpose: Generate a random number
;
; Inputs: None
; Outputs: A random value returned in A registers
;
; Registers modified: A register (which has a random value)
;
; Memory usage: The most recently generated random number is
; stored in memory with label LSTRAND
; This value is used to generate the next value
;
; Notes: Not the best random number generator around but does a
; halfway decent job.
;
; works as follows:
; shift the last random value left and add 20 with carry
;
;
RAND LDAA SEED
LSLA
4
In BUFFALO, if you press the enter key at the prompt, BUFFALO will repeat the last
instruction. So you don’t have to type the CALL every time. Just press the enter key.
Comentarios a estos manuales