The forum doesn't handle TABs well, you need hard spaces
Code:
*---------------------------------------*
* Program :text scroll *
* Written by :saraSupernova (easyV5.8)*
* Date :22 April 2011 *
*---------------------------------------*
* Description :This program is written as part of learning process in my microprocessor class.
* It uses 4 data registers, 4 address register. The minimum I could ever done.
* The codes is positioned by mean of compacting them through minimizing dummies.
* I don't really get Interrupt. How it should be used.
* The lecturer asked what can be improved. I think it depends on disadvantage of
* the codes which is not optimized enough.
* WARNING:This is really basic example. I realized, how hard it is but then the
* satisfaction on completing the program beats any accomplishment I made
* so far(literally saying). Good luck other newbies.
*-----------------------------------*
*-----------input storage-----------*
*-----------------------------------*
org $64 //initialize
dc.l input,input,input,input,input,input,finish //interrupt address
ORG $1000
input clr d3 compare purpose [need to be cleared]
lea tempStore,a1 initialize temporary storage position
lea index,a2 initialize real storage position which'll match and grab values from constants
move.b #13,d0
lea description,a1
trap #15
move.b #2,d0 //asking for
trap #15 //input //maximum input is #$FF=256
move.b d1,d3 backup total input
add.w #$1307,d3
move.w d3,a0 last character to show before looping the next char in string
realstoreLoop
move.b (a1)+,d2 from temporary storage
sub.b #$40,d2 modify ascii values from keyboard for index
jsr kmw check ascii for k/m/w
cont move.b d2,(a2)+ modified input go inside real storage
sub.b #1,d1 loop until all keyboard input is on index
bne realstoreLoop
move.w #$1300,a2 *---
jsr sevenBlank *---blank
move.w d3,a2 *---filler
jsr sevenBlank *---
*-----------------------------------*
*------seven segment display--------*
*-----------------------------------*
back lea data,a4 initialize data position
move.w #$1700,a2 alphanumeric position
round lea s8,a3 seven segment address
move.b #8,d1 8 segment 8 loop
loop move.b (a4)+,d4 //show //use data from memory
move.b (a2,d4),(a3) //in segment //and show in segment
add.w #2,a3 next segment
sub.b #1,d1
bne loop
DELAY move.b #23,d0 //delay //this kind
move.l #30,d1 //3/10 //of delay
trap #15 //second //save processing resource
sub.w #7,a4
cmp a4,a0
bne round
bra back
*-----------------------------------*
*-----------subroutine--------------*
*-----------------------------------*
kmw cmp #$2b,d2 //
beq k //
cmp #$0b,d2 //
beq k //check
cmp #$2d,d2 //for
beq m //k,m,w
cmp #$0d,d2 //because
beq m //each
cmp #$37,d2 //of them
beq w //use
cmp #$17,d2 //two
beq w //segment
rts //
k move.w #$1800,a3 //if k
bra seg2Char //
m move.w #$1802,a3 //if m
bra seg2Char //
w move.w #$1804,a3 //if w
bra seg2Char //they will go to be stored in memory
seg2Char
move.b (a3)+,d2 //
move.b d2,(a2)+ //put
move.b (a3)+,d2 //k1/k2/m1/m2/w1/w2
add.b #1,d1 //to
add.b #1,d3 //storage
add.w #1,a0 //
bra cont //
sevenBlank
movem.l d2/a0-a2,-(a7) //fill
move.b #7,d2 //seven blanks
loop7 move.b #$00,(a2)+ //to
sub.b #1,d2 //start and
bne loop7 //end of total input
movem.l (a7)+,d2/a0-a2 //it will look like this 000,0000,iheartcocacola,000,0000 in memory
rts // [blanks],iheartcocacola,[blanks] in hardware segment
*-----------------------------------*
*------------constants--------------*
*-----------------------------------*
s8 equ $e00000 point to seven segment
data equ $1300 point to data
tempStore equ $1200 point to temporary storage
index equ $1307 point to index storage
description dc.b 'Program to scroll text',$0D,$0A
dc.b 'Be warned, not all characters can be shown',$0D,$0A
dc.b 'Put text now',$0D,$0A
dc.b 'And press Enter',$0D,0
org $1700
ALPHABETupper dc.b $00,$77,$7c,$39,$5e,$79,$71,$6f,$74,$06 blank,a,b,c,...
dc.b $0e,$75,$38,$55,$37,$5c,$73,$67,$50,$6d
dc.b $78,$3e,$1c,$1d,$76,$6e,$5b ...,z
org $1720
alphabetLOWER dc.b $00,$77,$7c,$39,$5e,$79,$71,$6f,$74,$06 blank,a,b,c,...
dc.b $0e,$75,$38,$55,$37,$5c,$73,$67,$50,$6d
dc.b $78,$3e,$1c,$1d,$76,$6e,$5b ...,z
org $1740
dc.b $72,$44,$33,$27,$3c,$1e k1,k2,m1,m2,w1,w2
org $17e0
space dc.b $00 blank
org $17ec
dc.b $00,$40,$80 offset purpose, - and .
org $17f0
number dc.b $3f,$06,$5b,$4f,$66,$6d,$7d,$07,$7f,$67 0,1,2,3,4,5,6,7,8,9
org $1800
dc.w $4041,$4243,$4445 position of k1,k2,m1,m2,xxxx,w1,w2
finish reset
move.b #9,d0 terminate program
trap #15
end input