You are on page 1of 2

AS11, an absolute assembler for Motorola MCU's, version 1.

2h
* FISH 7 segs!

1004 PORTB equ $1004 * Address of register ma
pped to Port B
1008 PORTD equ $1008 * Address of register mapped to
Port D
1009 DDRD equ $1009 * Address of register mapped to
DDRD (data direction for reg D)
0071 ssegF equ #$71 * Hex code for F on common catho
de 7-seg
0006 ssegI equ #$06 * Hex code for I on common catho
de 7-seg
006d ssegS equ #$6D * Hex code for S on upside-down
common cathode 7-seg
0076 ssegH equ #$76 * Hex code for H on upside-down
common cathode 7-seg
001f dig3 equ #$1F * Hex code 5th bit 0, activating
digit 3, deactivating the rest
002f dig2 equ #$2F * Hex code 4th bit 0, activating
digit 2, deactivating the rest
00f7 dig1 equ #$F7 * Hex code 3rd bit 0, activating
digit 1, deactivating the rest
00fb dig0 equ #$FB * Hex code 2nd bit 0, activating
digit 0, deactivating the rest
00ff OUTPUT equ #$FF * Hex code for all 1s, all outpu
t

8800 org $8800 * start code at address 8800

8800 96 ff start: ldaa OUTPUT * load accumulator A with OUTPUT
8802 b7 10 09 staa DDRD * store accumulator A value at D
DRD
8805 8d 08 loop: bsr dispF * branch to dispF, display F on
digit 3
8807 8d 13 bsr dispI * branch to dispI, display I on
digit 2
8809 8d 1e bsr dispS * branch to dispS, display S on
digit 1
880b 8d 29 bsr dispH * branch to dispH, display H on
digit 0
880d 20 f6 bra loop * branch back to loop to repeat

880f 96 1f dispF: ldaa dig3 * load accumulator A with dig3
8811 b7 10 08 staa PORTD * store accumulator A value at P
ORTD
8814 96 71 ldaa ssegF * load accumulator A with ssegF
8816 b7 10 04 staa PORTB * store accumulator A calue at P
ORTB
8819 8d 28 bsr delay * branch to delay, delays for 0.
5ms
881b 39 rts * return from subroutine

881c 96 2f dispI: ldaa dig2 * load accumulator A with dig2
881e b7 10 08 staa PORTD * store accumulator A value at P
ORTD
8821 96 06 ldaa ssegI * load accumulator A with ssegI
8823 b7 10 04 staa PORTB * store accumulator A calue at P
ORTB
8826 8d 1b bsr delay * branch to delay, delays for 0.
5ms
8828 39 rts * return from subroutine

8829 96 f7 dispS: ldaa dig1 * load accumulator A with dig1
882b b7 10 08 staa PORTD * store accumulator A value at P
ORTD
882e 96 6d ldaa ssegS * load accumulator A with ssegS
8830 b7 10 04 staa PORTB * store accumulator A calue at P
ORTB
8833 8d 0e bsr delay * branch to delay, delays for 0.
5ms
8835 39 rts * return from subroutine

8836 96 fb dispH: ldaa dig0 * load accumulator A with dig0
8838 b7 10 08 staa PORTD * store accumulator A value at P
ORTD
883b 96 76 ldaa ssegH * load accumulator A with ssegH
883d b7 10 04 staa PORTB * store accumulator A calue at P
ORTB
8840 8d 01 bsr delay * branch to delay, delays for 0.
5ms
8842 39 rts * return from subroutine

8843 c6 02 delay: ldab #2 * Immediately load accumulator B
with decimal 2
8845 ce 00 52 loopb: ldx #82 * Immediately load register X wi
th decimal 82
8848 09 loopx: dex * Decrement X
8849 26 fd bne loopx * Branch if zero is not flagged,
to loopx
884b 5a decb * Decrement B
884c 26 f7 bne loopb * Branch if zero is not flagged,
to loopb
884e 39 rts * return from subroutine
Executed: Mon Mar 24 22:50:49 2014
Total cycles: 155, Total bytes: 79
Total errors: 0, Total warnings: 0

You might also like