*****************************************************************************
UCR2=0x10000208
|UART 2 Command register
UMR12=0x10000200
|UMR mode register
UMR22=0x10000200
|UMR mode register
USR2=0x10000204
|Status Register
UCSR2=0x10000204
|Clock Select register
URB2=0x1000020c
|Receiver buffer
UTB2=0x1000020c
|Transmitter buffer
UBG12=0x10000218
|Baud Rate Generator MSB
UBG22=0x1000021c
|Baud Rate Generator LSB
UIVR2=0x10000230
|Interrupt Vector Register
move.l
#0x10000000,%d0
move.l
%d0,MBAR |initialize MBAR
move.l
#0,%a6
move.l
%a6,VBR |initialize vector base register
move.l
#0x1000c040,%d0
move.l
%d0,ACR0
move.l
#0x80008000,%d0
move.l
%d0,CACR
move.l
#_UARTInterrupt,%d0
move.l
%d0,0x0100
move.b
#0x20,%d0 |UART 2 receiver reset
move.b
%d0,UCR2
move.b
#0x30,%d0 |UART 2 transmitter reset
move.b
%d0,UCR2
move.b
#0x10,%d0 |UART 2 register reset
move.b
%d0,UCR2
move.b
#0xB3,%D0 |set up the UMR1 (UART1 mode register)
move.b
%D0,UMR12 |see pg 14-18,19 of the users manual
move.b
#0x07,%D0 |set up the UMR2 (UART1 mode register)
move.b
%D0,UMR22 |see pg 14-20,21 of the users manual
move.b
#0xDD,%D0 |select timer mode as the Tx/Rx clocking
move.b
%D0,UCSR2 |see pg 14-24 of the users manual
move.b
#0x00,%D0 |Disable interrupts for the COS&/CTS
move.b
%D0,UACR2 |see pg 14-30 of the users manual
move.b
#0x02,%D0 |Interrupt only when FIFO is full
move.b
%D0,UIMR2 |see pg 14-31 of the users manual
move.b
#65,%D0 |Interrupt vector set to 65
move.b
%D0,UIVR2 |see pg 14-33 of the users manual
|65 was
a random choice.
|65
decimal is converted by the processor
|to the
vector offset hex value of 0x104
move.b
#0x00,%D0 |Set baud rate to 33,600 (25 mhz clk)
move.b
%D0,UBG12 |see pg 14-32 of the users manual
move.b
#0x2A,%D0 |HEX value $0017
move.b
%D0,UBG22
move.l
#0x40000,%a0
move.l
#0, %d4
TMR1 =
0x10000140
TRR1 =
0x10000144
move.w
#0x362b, %d6
move.w
%d6, TMR1
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
move.l
#0x30000,%a1
test_transmit:
move.w #0x2a,%d1 |Display *
move.l #0x0013,%d0
trap #15
loop1: clr.l %D0 |clear the registers
clr.l %D1
move.b #0x04,%D1 |enable the
transmitter (pg 14-25,26)
move.b %D1,UCR2 |and disable
receiver
move.l #0x0010,%d0 |Wait for input
char
trap #15
cmp.l #0x0d,%d1 |If end of line:
"Return" is pressed
beq finish
move.b %d1,UTB2
move.l #0x0013,%d0 |Display the char
in the window
cmp.l #0x61,%d1 |If 'a': play a c
note
beq cNote
cmp.l #0x77,%d1 |If 'w': play a c#
note
beq cfNote
cmp.l #0x73,%d1 |If 's': play a d
note
beq dNote
cmp.l #0x65,%d1 |If 'e': play a d#
note
beq dfNote
cmp.l #0x64,%d1 |If 'd': play a e
note
beq eNote
cmp.l #0x66,%d1 |If 'f': play a f
note
beq fNote
cmp.l #0x74,%d1 |If 't': play a ff
note
beq ffNote
cmp.l #0x67,%d1 |If 'g': play a g
note
beq gNote
cmp.l #0x79,%d1 |If 'y': play a gf
note
beq gfNote
cmp.l #0x68,%d1 |If 'h': play a a
note
beq aNote
cmp.l #0x6a,%d1 |If 'j': play a b
note
beq bNote
cmp.l #0x6b,%d1 |If 'k': play a c1
note
beq HCNote
cmp.l #0x30,%d1 |If '0': stop
recording
beq Stop_Rec
cmp.l #0x21,%d1 |If '!': start
recording
beq rec1
cmp.l #0x23,%d1 |If '#': start
recording
beq rec3
cmp.l #0x24,%d1 |If '$': start
recording
beq rec4
cmp.l #0x25,%d1 |If '%': start
recording
beq rec5
cmp.l #0x31,%d1 |If '1': start
recording
beq play1
cmp.l #0x32,%d1 |If '3': start
recording
beq play3
cmp.l #0x33,%d1 |If '4': start
recording
beq play4
cmp.l #0x34,%d1 |If '5': start
recording
beq play5
come:
wait: move.b USR2,%d1
btst #0x03,%d1
beq wait
bra loop1
finish:
move.l #0x0a,%d1 |To output 1 line
feed
bra NoNoise
move.l #0x0013,%d0
trap #15
move.l #0x0d,%d1 |To output 1
carriage return
move.l #0x0013,%d0
trap #15
move.b #0x76, %d0
move.b %d0, UCR2
bra test_transmit
*******************************************************************************************
NoNoise:
move.w #0x0003, %d6
move.w %d6, TRR1
move.w TMR1, %d5
bset #0, %d5
move.w %d5, TMR1
bra come
aNote:
move.w #0x03a2, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret1
move.w %d6, (%a5)+
ret1:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
addq.l #1, %d4
bra elapsed
bNote:
move.w #0x033c, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret2
move.w %d6, (%a5)+
ret2:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
cNote:
move.w #0x0619, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret3
move.w %d6, (%a5)+
ret3:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
cfNote:
move.w #0x05c5, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret3f
move.w %d6, (%a5)+
ret3f:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
dNote:
move.w #0x056f, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret4
move.w %d6, (%a5)+
ret4:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
dfNote:
move.w #0x0523, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret4f
move.w %d6, (%a5)+
ret4f:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
eNote:
move.w #0x04d8, %d6
move.w %d6, TRR1
cmp.l
#1, %d3
bne ret5
move.w %d6, (%a5)+
ret5:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
fNote:
move.w #0x0494, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret6
move.w %d6, (%a5)+
ret6:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
ffNote:
move.w #0x0452, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret6f
move.w %d6, (%a5)+
ret6f:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
gNote:
move.w #0x0414, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret7
move.w %d6, (%a5)+
ret7:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
gfNote:
move.w #0x03da, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret7f
move.w %d6, (%a5)+
ret7f:
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
HCNote:
move.w #0x030e, %d6
move.w %d6, TRR1
cmp.l #1, %d3
bne ret8
move.w %d6, (%a5)+
ret8: move.w
TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
bra elapsed
elapsed:
move.l #0x4ffff, %d6
lop:
subq.l #1, %d6
bne lop
bra NoNoise
play:
subq.l #1, %d3
play11: move.w
(%a5)+, %d6
cmp.l #0x0000, %d6
beq NoNoise
move.w %d6, TRR1
move.w TMR1, %d6
bset #0, %d6
move.w %d6, TMR1
move.l #0x4ffff, %d5
lop1:
subq.l #1, %d5
bne lop1
bra play11
rec1:
move.l #0x1000, %a5
bsr empty
move.w #0x31,%d1 |Display 1
move.l #0x0013,%d0
trap #15
move.l #0x1000, %a5
move.l #1, %d3
bra NoNoise
rec3:
move.l #0x2000, %a5
bsr empty
move.w #0x33,%d1 |Display 3
move.l #0x0013,%d0
trap #15
move.l #0x2000, %a5
move.l #1, %d3
bra NoNoise
rec4:
move.l #0x3000, %a5
bsr empty
move.w #0x34,%d1 |Display 4
move.l #0x0013,%d0
trap #15
move.l #0x3000, %a5
move.l #1, %d3
bra NoNoise
rec5:
move.l #0x4000, %a5
bsr empty
move.w #0x35,%d1 |Display 5
move.l #0x0013,%d0
trap #15
move.l #0x4000, %a5
move.l #1, %d3
bra NoNoise
Stop_Rec:
move.l #0x0000, %d3
move.l #0x0a,%d1 |To output 1
line feed
move.l #0x0013,%d0
trap #15
move.l #0x0d,%d1 |To output 1
carriage return
move.l #0x0013,%d0
trap #15
move.w #0x53,%d1 |Display S
move.l #0x0013,%d0
trap #15
move.w #0x74,%d1 |Display t
move.l #0x0013,%d0
trap #15
move.w #0x6f,%d1 |Display o
move.l #0x0013,%d0
trap #15
move.w #0x70,%d1 |Display p
move.l #0x0013,%d0
trap #15
move.w #0x20,%d1 |Display
move.l #0x0013,%d0
trap #15
move.w #0x52,%d1 |Display R
move.l #0x0013,%d0
trap #15
move.w #0x65,%d1 |Display e
move.l #0x0013,%d0
trap #15
move.w #0x63,%d1 |Display c
move.l #0x0013,%d0
trap #15
move.w #0x6f,%d1 |Display o
move.l #0x0013,%d0
trap #15
move.w #0x72,%d1 |Display r
move.l #0x0013,%d0
trap #15
move.w #0x64,%d1 |Display d
move.l #0x0013,%d0
trap #15
move.w #0x69,%d1 |Display i
move.l #0x0013,%d0
trap #15
move.w #0x6e,%d1 |Display n
move.l #0x0013,%d0
trap #15
move.w #0x67,%d1 |Display g
move.l #0x0013,%d0
trap #15
move.w #0x20,%d1 |Display
move.l #0x0013,%d0
trap #15
move.l #0x0a,%d1 |To output 1
line feed
move.l #0x0013,%d0
trap #15
move.l #0x0d,%d1 |To output 1
carriage return
move.l #0x0013,%d0
trap #15
bra NoNoise
play1:
move.l #0x1000, %a5
move.l #0, %d3
bsr disp
move.w #0x31,%d1 |Display 1
move.l #0x0013,%d0
trap #15
bra play
play3:
move.l #0x2000, %a5
move.l #0, %d3
bsr disp
move.w #0x33,%d1 |Display 3
move.l #0x0013,%d0
trap #15
bra play
play4:
move.l #0x3000, %a5
move.l #0, %d3
bsr disp
move.w #0x34,%d1 |Display 4
move.l #0x0013,%d0
trap #15
bra play
play5:
move.l #0x4000, %a5
move.l #0, %d3
bsr disp
move.w #0x35,%d1 |Display 5
move.l #0x0013,%d0
trap #15
bra play
empty:
move.l #0x0a,%d1 |To output 1
line feed
move.l #0x0013,%d0
trap #15
move.l #0x0d,%d1 |To output 1
carriage return
move.l #0x0013,%d0
trap #15
move.w #0x52,%d1 |Display R
move.l #0x0013,%d0
trap #15
move.w #0x65,%d1 |Display e
move.l #0x0013,%d0
trap #15
move.w #0x63,%d1 |Display c
move.l #0x0013,%d0
trap #15
move.w #0x6f,%d1 |Display o
move.l #0x0013,%d0
trap #15
move.w #0x72,%d1 |Display r
move.l #0x0013,%d0
trap #15
move.w #0x64,%d1 |Display d
move.l #0x0013,%d0
trap #15
move.w #0x69,%d1 |Display i
move.l #0x0013,%d0
trap #15
move.w #0x6e,%d1 |Display n
move.l #0x0013,%d0
trap #15
move.w #0x67,%d1 |Display g
move.l #0x0013,%d0
trap #15
move.w #0x20,%d1 |Display
move.l #0x0013,%d0
trap #15
move.w #0x69,%d1 |Display i
move.l #0x0013,%d0
trap #15
move.w #0x6e,%d1 |Display n
move.l #0x0013,%d0
trap #15
move.w #0x74,%d1 |Display t
move.l #0x0013,%d0
trap #15
move.w #0x6f,%d1 |Display o
move.l #0x0013,%d0
trap #15
move.w #0x20,%d1 |Display
move.l #0x0013,%d0
trap #15
move.l #0, %d3
move.l #0x200, %d2
potty:
move.l %d3, (%a5)+
subq.l #1, %d2
bne potty
rts
disp:
move.l #0x0a,%d1 |To output 1
line feed
move.l #0x0013,%d0
trap #15
move.l #0x0d,%d1 |To output 1
carriage return
move.l #0x0013,%d0
trap #15
move.l #0x50,%d1 |Display P
move.l #0x0013,%d0
trap #15
rts
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||