Posts

Showing posts from February, 2012

Class Notes 2012/02/17

; ASCII to packed BCD
; 1 3 5 8 7 6
; $31 $33 $35 $38 $37 $36
;
; |$31| <= ASCII
; |$33|
; |$35|
; |$38|
; |$36|
; |$13| <= PBCD
; |$58|
; |$76|
; | |
; | | ;Code:
ASCII dc.b '125876'
PBCD ds.b 3
count ds.b 1 ldx #ASCII
ldy #PBCD
movb #3,count ; initializes the loop counter
loop:
ldaa 1,x+ ; gets 1st char
lsla ; shift left
lsla ; shift left
lsla ; shift left
lsla ; shift left
ldab 1,x+ ;get next character
andb #$0F ;AND it with %0000 1111, which leaves us with the least signif bit of next character
aba ;add B to A
staa 1,y+ ;store in PBCD
dec count ;decrement loop counter
bne loop ;branch if != 0 ;================================================================
;HW #5
;The array "sample" contains 8 8-bit signed binary numbers (integers) as shown below. Write a program which computes the sum of positive numbers and the sum of negative number, and stores them in psum and nsum, respectively.
;It also computes the su…