es512.asm
来自「isd voice record and playback code」· 汇编 代码 · 共 1,955 行 · 第 1/3 页
ASM
1,955 行
nop
nop
djnz timeout1,usloop
ret
getkey:
clr newkey
setb EA
waithere:
nop
jnb keyup,waithere
jnb newkey,$
mov A,keycode
clr EA
ret
setaltmap:
clr bumpadd
mov altmapl,#0
mov altmaph,#0
mov addrl,#DATAMAPL
mov addrh,#DATAMAPH
if (m224)
mov R5,#16 ;for 224 msgs
else
mov R5,#8 ;for 96 msgs
endif
mov msg,#0
setmaploop:
mov R7,#32
setb emptyrow
rowmapsap:
call readdigital
jb empty,stillempty
clr emptyrow
stillempty:
call incaddr
djnz R7,rowmapsap
jnb emptyrow,thisone ;if row is empty, always choose alternate by setting alt bit
call setaltbit
thisone:
; call incrow
mov A,msg
add A,#16
mov msg,A
djnz R5,setmaploop
jnb mapbit,finsam
jnb bumpadd,itsus
setb mapbit
jmp finsam
itsus:
clr mapbit
finsam:
ret
incaddr: ;increments scan address (8 bytes)
inc addrl
mov A,addrl
jnz noincia
inc addrh
noincia:
ret
incrow: ;increments row address (32 scans or one recording row)
mov A,addrl
add A,#020h
mov addrl,A
jnc nocir
inc addrh
nocir:
ret
inccluster: ;increments cluster address by n rows
mov A,addrl
add A,#(020h * nrows)
mov addrl,A
jnc nocic
inc addrh
nocic:
ret
adjaddr: ;simple version assumes 8 or 16 row offset. general version would be two digit add
mov A,addrh
jnb bumpadd,finadjaddr
if (m224)
add A,#002h
else
add A,#001h
endif
finadjaddr:
mov datah,A
mov datal,addrl
ret
getmap1:
mov A,msg
swap A
anl A,#00fh
rl A
mov temp1,A
mov DPTR,#mapdecode
movc A,@A+DPTR
ret
getmap2:
inc DPTR
mov A,temp1
movc A,@A+DPTR
ret
setaltbit:
call getmap1
orl A,altmapl
mov altmapl,A
if (m224)
call getmap2
orl A,altmaph
mov altmaph,A
endif
ret
clraltbit:
call getmap1
cpl A
anl A,altmapl
mov altmapl,A
if (m224)
call getmap2
cpl A
anl A,altmaph
mov altmaph,A
endif
ret
togglealtbit:
call getmap1
xrl A,altmapl
mov altmapl,A
if (m224)
call getmap2
xrl A,altmaph
mov altmaph,A
endif
ret
checkaltbit:
clr bumpadd
call getmap1
anl A,altmapl
if (m224)
xch A,B
call getmap2
anl A,altmaph
orl A,B
endif
jz staylow
setb bumpadd
staylow:
ret
msg2addr: ;converts message number to a base row and scan address, sets bumpadd if this row is in high block
;msg# * 2 + base (before adjaddr)
mov temp1,#0
mov A,msg
clr C
rlc A
jnc nocm2a
mov temp1,#1
nocm2a:
add A,#DATAMAPL
mov addrl,A
mov A,temp1
addc A,#DATAMAPH
mov addrh,A
call checkaltbit
ret
getmsginfo: ;should display without clrscr, should set samprate
call msg2addr
setb freeform
mov R0,#bitmap
call readdigital
call incaddr
call readdigital
mov samprate,trailer
clr freeform
ret
printinfo:
mov R0,#bitmap
call clrscr
call printsr ;need new routine to unpack BCD. code F is stop, code B is dash
ret
setmsginfo:
call clrscr
mov A,#00fh ;display on, cursor and blink off
call wdc2
mov R0,#bitmap
mov R5,#16
clrinfo:
mov @R0,#0
djnz R5,clrinfo
mov R0,#bitmap
setb ET1
setb TR1
enterloop:
setb EA
call getkey
clr EA
mov A,keycode
rl A ;keycode is <80h, so rl is just sl
add A,keycode ;multiply by 3
mov DPTR,#keytable
jmp @A+DPTR
keytable:
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp enternmb
ljmp dash ;"star" key
ljmp cancel ;"pound" key
ljmp enterloop ;recorder buttons
ljmp enterloop ;not in matrix - can be if use dome keyboard
ljmp enterloop ;erase, for now
ljmp savekey ;also play key
dash:
mov B,#011h
mov A,#02dh
jmp finenter1
enternmb:
cjne R0,#(bitmap+15),beforesr
jmp enterloop
beforesr:
mov A,keycode
finenter:
mov B,A
add A,#030h ;still used for printd below
finenter1:
mov @R0,A ;replace this with nibble packing code - need half flag
xch A,B
inc R0
clr newkey
call printd
jmp enterloop
cancel:
dec R0
cjne R0,#(bitmap -1),inlimit
mov R0,#bitmap
jmp notinlimit
inlimit:
call backspace
notinlimit:
mov A,#blank
call printd
call backspace
jmp enterloop
savekey:
mov @R0,#NULL
mov (bitmap + 15),samprate
call msg2addr
setb freeform
mov R0,#bitmap
call writedigital
call incaddr
call writedigital
clr freeform
mov A,#00ch ;display on, cursor and blink off
call wdc2
mov cdh,#0
ret
clrscr:
mov A,#001h
call wdc2
mov dispctr,#0
mov A,#2
call waitms
ret
enabledisplay:
mov A,#100
call waitms ;guarantees 15ms delay after Vcc reaches 4.5V - put this in routine to power up sw reg
mov A,#030h
call wdc1
mov A,#4
call waitms
mov A,#030h
call wdc1
mov A,#030h
call wdc1
mov A,#020h ;sets interface length to 4 bits
call wdc1
mov A,#028h ;sets functions to 4 bits, 2 lines, 5x7. Needs two line mode to shift in data correctly
call wdc2
mov A,#001h ;clear display
call wdc2
mov A,#2
call waitms
mov A,#00ch ;display on, cursor and blink off
call wdc2
mov A,#006h ;increment address, do not shift display
call wdc2
mov dispctr,#0
ret
wdc1:
orl A,#00ch ;be sure int0, int1 lines remain input, others off
mov P3,A
setb ED
clr ED
mov A,#(100/4)
call waitus
ret
wdc2:
mov temp1,A
anl A,#00fh
swap A
mov temp2,A
mov A,temp1
anl A,#0f0h
orl A,#00ch
mov P3,A
setb ED
clr ED
mov A,#(100/4)
call waitus
mov A,temp2
orl A,#00ch
mov P3,A
setb ED
clr ED
mov A,#(100/4)
call waitus
ret
wdd:
mov temp1,A
anl A,#00fh
swap A
mov temp2,A
mov A,temp1
anl A,#0f0h
orl A,#(DCLKbit + RACbit)
setb RS
mov P3,A
setb ED
clr ED
mov A,#(100/4)
call waitus
mov A,temp2
orl A,#(DCLKbit + RACbit)
setb RS
mov P3,A
setb ED
clr ED
mov A,#(100/4)
call waitus
clr RS
ret
prints: ;assumes DPTR contains location of string, e.g. mov DPTR,#displaystring
clr A
movc A,@A+DPTR
jnz regchar
ret
regchar:
call wdd
inc DPTR
call incdispctr
jmp prints
incdispctr:
inc dispctr
mov A,dispctr
anl A,#007h
jz fixit
ret
fixit:
mov A,#0A8h ;set ddram address to 0x28
call wdc2
ret
printsr: ;assumes R0 contains location of string in RAM
mov A,@R0
jnz regchar1
ret
regchar1:
call wdd
inc R0
call incdispctr
jmp printsr
printd:
mov DPTR,#itoatab
movc A,@A+DPTR
call wdd
call incdispctr
ret
printhex:
mov DPTR,#itoatab
mov datah,A
swap A
anl A,#00fh
movc A,@A+DPTR
call wdd
call incdispctr
mov A,datah
anl A,#00fh
movc A,@A+DPTR
call wdd
djnz dispctr, finph
mov dispctr,#8
mov A,#0A8h ;set ddram address to 0x28
call wdc2
finph:
ret
spacebar:
mov A,#014h ;move cursor right
call wdc2
call incdispctr
ret
printloc:
call converta
mov A,addrh
call printhex
mov A,addrl
call printhex
call backspace
call backspace
call backspace
call backspace
ret
shownotvalid:
call clrscr
mov DPTR,#notvalid
call prints
call wait2s
ret
convertm:
mov B,#0
jmp convert
convertcc:
mov B,R7
mov A,R6
jmp convert
converta:
jb first,nobackup
call backspace
call backspace
call backspace
nobackup:
clr first
mov B,#0
mov A,addrh
mov C,addrl.7
rlc A
mov B.0,C
convert:
mov dig1,#0
mov dig2,#0
mov dig3,#0
jmp loop100
loop100i:
inc dig3
loop100:
add A,#09ch ;-100
jc loop100i
djnz B,donecvt2
jmp loop100i
donecvt2:
add A,#100
jmp loop10
loop10i:
inc dig2
loop10:
add A,#0f6h ;-110
jc loop10i
add A,#10
jmp loop1
loop1i:
inc dig1
loop1:
add A,#0ffh ;-1
jc loop1i
mov A,dig3
jnz dig3nz
mov A,#blank
call printd
mov A,dig2
jnz dig2nz
mov A,#blank
jmp dig2nz
dig3nz:
call printd
mov A,dig2
dig2nz:
call printd
mov A,dig1
call printd
ret
backspace:
dec dispctr
mov A,dispctr
anl A,#007h
cjne A,#007h,normbs
mov A,#087h ;set ddram address to 0x07
call wdc2
ret
normbs:
mov A,#010h
call wdc2
mov A,#1
call waitms
ret
wait2s:
mov temp2,#4
wait2loop:
mov A,#255
call waitms
djnz temp2,wait2loop
ret
initialize:
setb SCL
mov IE,#0 ;disable all interrupts
mov 0c0h,#0 ;kill le51 int2 and 3
; mov 08eh,#1 ;kill ALE
mov 0d8h,#0ffh ;float port 4
mov PSW,#0
mov PCON,#0
mov SP,#(stack-1)
setb SDA
mov PCON,#0
setb SHDN_
mov R0,#TOP
allinitialize:
mov A,#0
clrloop:
mov @R0,A
djnz R0,clrloop
mov P0,#0ffh ;keyboard drive lines off for now
mov P1,#0ffh ;make keyboard sense inputs, ext ifc inputs, SHDN_ an output (on for now)
mov P2,#0f7h ;put ISD5116 in neutral.., make display RS line low as before
mov P3,#00eh ;make RAC and N.C input, others outputs and off
mov IP,#005h ;set RAC interrupt to high priority
mov TCON,#005h ;clear interrupt flags, set ext ints to edge triggered
mov TMOD,#011h ;set timer 0 and 1 to 16bit mode
mov volume,#7 ;for starting (8.0kHz initial sample rate)
setb keyup
jmp main
CSEG
cfgtab0:
DW 02424h,0c424h,02429h,02424h,02424h,02424h,08424h,0840dh,02421h,02421h,02421h,02421h,08424h,0c42dh,0da3dh,00424h
; 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15
cfgtab1:
DW 04051h,040c1h,00140h,043d1h,043d1h,043d1h,040c1h,081e3h,039e3h,039e3h,039e3h,039e3h,040c1h,001e3h,00040h,00040h
itoatab:
db 030h,031h,032h,033h,034h,035h,036h,037h,038h,039h,041h,042h,043h,044h,045h,046h,020h,02dh
srdecode:
DB 000h,004h,008h,00ch
keydecode:
DB 1,4,7,10,2,5,8,0,3,6,9,11,15,14,13,12
mapdecode:
DB 001h,000h,002h,000h,004h,000h,008h,000h,010h,000h,020h,000h,040h,000h,080h,000h
DB 000h,001h,000h,002h,000h,004h,000h,008h,000h,010h,000h,020h,000h,040h,000h,080h
startstring:
db ' ISD ES512 V1.2',NULL
enterdata:
db 'ENTER REF NUMBER',NULL
inerase:
db 'ERASING...',NULL
enderase:
db ' ERASED',NULL
endinitmap:
db 'MAP INITIALIZED',NULL
notvalid:
db ' MESSAGE EMPTY',NULL
clsavail:
db 'AVAIL ',NULL
cls:
db 'CLSTRS ',NULL
msgno:
db 'MSG ',NULL
position:
db 'POS ',NULL
space:
db ' ',NULL
entered:
db 'ENTERED: ',NULL
length:
db ' LEN ',NULL
emptyphr:
db ' EMPTY',NULL
occupado:
db 'MSG USED; ERASE?',NULL
eraseall:
db 'ERASE ALL MSGS?',NULL
init:
db 'INITIALIZING...',NULL
setsrate:
db 'SET SR =',NULL
sr8:
db ' 8.0 kHz',NULL
sr6:
db ' 6.4 kHz',NULL
sr5:
db ' 5.3 kHz',NULL
sr4:
db ' 4.0 kHz',NULL
sure:
db 'ARE YOU SURE?',NULL
selftest:
setb P2.5
clr P2.5
selftestl:
setb P2.4
nop
clr P2.4
djnz R0,selftestl
; see if 5100 responds
; run display and ask for response(s)
; check keyboard (maybe voice prompt of "OK" when requested key is pressed to check output)
; flash record LED also as keys are pressed
; prompt, record, and playback section- checks mic and digital memory
ret
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?