40 CHAPTER 3. FUNCTIONS AND BIT MANIPULATIONS
JSR RAND
JSR PRBINARY
SWI
;;; INSERT YOUR CODE FOR PRBINARY HERE
;;; INSERT YOUR CODE FOR RAND HERE
ORG $D000
;;; INSERT ALL YOUR DATA (FCB, FCC, RMB etc.) here
ABOUTME FCC / INFORMATION ABOUT YOU /
FCB 4
SEED FCB 0
;;;;;;;;;;;;;;;;;;;;;;;end of code ;;;;;;;;;;;;;;;;;;;;;;;;
3.6 Setting bits
We will now write a function that will set a particular bit in some memory location.
The function should modify the value in the memory in such a way that it only
affects the specific bit without changing any other bit. For definiteness, we will
set bit #4 in memory location $00. Recall that the bits are numbered right to left
starting with bit #0. To set a bit, we use the ORA instruction. Write the following
program, and test it by repeating the call to $C100 from the BUFFALO prompt.
;;;;;;;;;;;;;;;;;;;;;;;start of code ;;;;;;;;;;;;;;;;;;;;;;;;
;; Insert standard buffalo equates here
ORG $C100
JSR OUTCRLF *NEED THIS FOR OUTPUTS TO LINE UP!
JSR RAND
STAA $00
JSR PRBINARY *PRINT BEFORE
JSR SETBIT4
LDAA $00
JSR PRBINARY *PRINT AFTER
SWI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Function: SETBIT4
; Purpose: SETS bit #4 in memory location $00
; Registers modified none
;
Comentarios a estos manuales