⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spdj.asm

📁 8051单片机汇编语言编写的UPD6464视频叠加遥控接收解码点歌程序。用于KTV房遥控点歌。
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;****** 视频迭加点歌程序****************************
;------ 口线定义 -----------------------------------
DATAS           bit     p1.2
CS              bit     p1.3
CLK             bit     p1.4
LED             bit     p1.6
CTLAMP          bit     p1.7
IRM             bit     p3.2
BEEP            bit     p3.4
SERVICE         bit     p3.5

;----------- RAM 单元定义 --------------------
pulsetime       equ     10h             ;INT0中断次数
tmpth0          equ     11h             ;T0-th0临时存放单元
tmptl0          equ     12h             ;T0-tl0临时存放单元
codemark        equ     13h             ;遥控码标志
coderam0        equ     14h             ;输入遥控码1
coderam1        equ     15h             ;输入遥控码2
coderam2        equ     16h             ;输入遥控码3
coderam3        equ     17h             ;输入遥控码4
orderram0       equ     18h             ;遥控命令存放单元起始地址
orderram1       equ     19h
orderram2       equ     1ah
orderram3       equ     1bh
orderram4       equ     1ch
orderram5       equ     1dh
orderram6       equ     1eh
orderram7       equ     1fh
insertmark      equ     69h             ;=00h,未进插入,=0ffh,进入插入
songmark        equ     6ah             ;=00h:未进屏幕点歌,=0ffh:进屏幕点歌
ordermark       equ     6bh             ;ordermark=00h:未有请求需发送
                                        ;ordermark=0ffh:已有请求需发送
vodovermark     equ     24h             ;=00h,无可播歌曲;=0ffh,有可播歌曲
line            equ     25h             ;点歌时当前行号
column          equ     26h             ;点歌时当前列号
dispram0        equ     27h             ;送至6464芯片的数据存储单元起始地址
dispram1        equ     28h
dispram2        equ     29h
dispram3        equ     2ah
dispram4        equ     2bh
dispram5        equ     2ch
dispram6        equ     2dh
dispram7        equ     2eh
dispram8        equ     2fh

dpofftl         equ     30h
dpoffth         equ     31h
dpoffhh         equ     32
tmp             equ     33h             ;临时单元
temp0           equ     34h
temp1           equ     35h
temp2           equ     36h
temp3           equ     37h
blinkmark       equ     38h             ;=00h,不闪烁;=02h,闪烁
recram0         equ     39h
recram1         equ     3ah
recram2         equ     3bh
recram3         equ     3ch
recram4         equ     3dh
recram5         equ     3eh
recram6         equ     3fh

;以下为存放歌曲序号的RAM单元地址,每首歌采用4个数字BCD码,压缩成2字节BCD码
songnub10       equ     40h             ;第1首歌BCD码高位
songnub11       equ     41h
songnub12       equ     42h
songnub13       equ     43h
songnub20       equ     44h             ;第2首歌BCD码高位
songnub21       equ     45h
songnub22       equ     46h
songnub23       equ     47h
songnub30       equ     48h             ;第3首歌BCD码高位
songnub31       equ     49h
songnub32       equ     4ah
songnub33       equ     4bh
songnub40       equ     4ch             ;第4首歌BCD码高位
songnub41       equ     4dh
songnub42       equ     4eh
songnub43       equ     4fh
songnub50       equ     50h             ;第5首歌BCD码高位
songnub51       equ     51h
songnub52       equ     52h
songnub53       equ     53h
songnub60       equ     54h             ;第6首歌BCD码高位
songnub61       equ     55h
songnub62       equ     56h
songnub63       equ     57h
songnub70       equ     58h             ;第7首歌BCD码高位
songnub71       equ     59h
songnub72       equ     5ah
songnub73       equ     5bh
songnub80       equ     5ch             ;第8首歌BCD码高位
songnub81       equ     5dh
songnub82       equ     5eh
songnub83       equ     5fh
songnub90       equ     60h             ;第9首歌BCD码高位
songnub91       equ     61h
songnub92       equ     62h
songnub93       equ     63h
songnuba0       equ     64h             ;第10首歌BCD码高位
songnuba1       equ     65h
songnuba2       equ     66h
songnuba3       equ     67h
tvmark          equ     68h             ;=00h,备份;=0ffh,Ktv
;----------- 常数定义 -----------------------
;****** 遥控码定义 ****************
usercode1       equ     00h             ;用户码
usercode2       equ     0ffh            ;用户反码
code0           equ     60h             ;"0"的遥控码
code1           equ     38h             ;"1"的遥控码
code2           equ     18h             ;"2"的遥控码
code3           equ     0a8h            ;"3"的遥控码
code4           equ     48h             ;"4"的遥控码
code5           equ     0c8h            ;"5"的遥控码
code6           equ     28h             ;"6"的遥控码
code7           equ     0d8h            ;"7"的遥控码
code8           equ     7ah             ;"8"的遥控码
code9           equ     0aah            ;"9"的遥控码
codeCAll        equ     0d2h            ;"呼叫"的遥控码
codeEJT         equ     0b0h            ;"出盒"的遥控码
codeMUTE        equ     88h             ;"静音"的遥控码
codeTV          equ     20h             ;"电视/TV"的遥控码
codePAUSE       equ     30h             ;"暂停"的遥控码
codeRL          equ     0a0h            ;"声道"的遥控码
codeFOWARD      equ     40h             ;"快进"的遥控码
codeTOWARD      equ     80h             ;"快退"的遥控码
codePRE         equ     90h             ;"上首"的遥控码
codeNEXT        equ     50h             ;"下首"的遥控码
codeCONT1       equ     52h             ;"目录"的遥控码
codeCONT2       equ     62h             ;"目录"的遥控码
codeFREUP       equ     42h             ;"音调大"的遥控码
codeFREDW       equ     08h             ;"音调小"的遥控码
codeUP          equ     78h             ;"↑"的遥控码
codeDOWN        equ     68h             ;"↓"的遥控码
codeLEFT        equ     0c2h            ;"←"的遥控码
codeRIGHT       equ     0b2h            ;"→"的遥控码
codeVOLUP       equ     0f0h            ;"音量大"的遥控码
codeVOLDW       equ     0e8h            ;"音量小"的遥控码
codeINS         equ     58h             ;"插入"的遥控码
codeDEL         equ     10h             ;"删除"的遥控码
;********** uPD6464 命令定义 ******************
VCLR            equ     00h             ;Video ram batch clear command
DISPON          equ     1eh             ;Display on,Blinking off
DISPOFF         equ     10h             ;Display off,Blinking off
CHARCOLOR       equ     24h             ;Character is green
BACKGROUND      equ     30h             ;No background
EIXMODE         equ     41h             ;External video signal mode,Xosc On
VIDEOMODE       equ     49h             ;Video mode:PAL
OSCMODE         equ     52h             ;OSC method control command-4fsc cry. osc

;*********************************************************************
		org	0000h
                ljmp    init
                org     0003h
		ljmp	remote
                org     0013h
                ljmp    displayoff
                org     0023h
                ljmp    comm

;*********** INIT: 程序初始化 ****************************
                org     0028h
init:           mov     sp,#6ch
		mov	psw,#0
                mov     tcon,#00000101b         ;设置EX0,EX1为负沿触发
                mov     tmod,#00100001b         ;T0为定时方式1,T1为方式2
                mov     scon,#01010000b         ;串行方式1
                mov     pcon,#00000000b
                mov     ip,#00010000b           ;串行中断为最高优先级
                lcall   iniirf
		mov     vodovermark,#00h
                mov     insertmark,#00h
                mov     tvmark,#00h
                mov     line,#01h
                mov     column,#00h
                setb    IRM
                clr     LED
                clr     BEEP
                clr     SERVICE
                setb    DATAS
                setb    CS
                setb    CLK
                mov     r0,#songnub10           ;初始化歌曲序号(无歌)
                mov     r1,#40
                mov     a,#'-'
initsongnum:    mov     @r0,a
                inc     r0
                djnz    r1,initsongnum
                lcall   clrscreen
                mov     r6,#1                   ;字符为绿色
                mov     dispram0,#CHARCOLOR
                lcall   sendbyte
                mov     r6,#1                   ;字符无背景
                mov     dispram0,#BACKGROUND
                lcall   sendbyte
                mov     r6,#1                   ;选择4fsc crystal OSC 方式
                mov     dispram0,#OSCMODE
                lcall   sendbyte
                mov     r6,#1                   ;选择PAL制
                mov     dispram0,#VIDEOMODE
                lcall   sendbyte
                mov     r6,#1                   ;选择外部视频信号模式
                mov     dispram0,#EIXMODE
                lcall   sendbyte
                lcall   switv
                setb    ea                      ;开中断
		setb	ex0
		clr	et0
                clr     et1
                mov     tl1,#0e8h               ;11.0592MHz,1200bps
                mov     th1,#0e8h
                setb    tr1
                setb    es
loop:		nop
		nop
		setb	IRM
                nop
                ajmp	loop

;************** EX0中断:遥控接收处理中断程序 *********************
remote:         clr     ex0
		setb	LED
		setb	tr0
		mov	pulsetime,#00h
		nop
                nop
		nop
		jb	IRM,error
if_lead:	mov	tmpth0,th0
		mov	tmptl0,tl0
		lcall	leader
		mov	a,codemark
		cjne	a,#0fh,golead
error:		ljmp	exitint0
golead:         jnb     IRM,if_lead
leadt0:         mov     tmpth0,th0
		mov	tmptl0,tl0
		lcall	leader
		mov	a,codemark
		cjne	a,#0fh,gojblead
		ljmp	exitint0
gojblead:	jb	IRM,leadt0
		mov	tmpth0,th0
		mov	tmptl0,tl0
		mov	th0,#0
		mov	tl0,#0
		lcall	leader
		mov	a,codemark
		cjne	a,#0ffh,error
getcode:	inc	pulsetime
tocode:         mov     tmpth0,th0
		mov	tmptl0,tl0
		lcall	iscode
		mov	a,codemark
		cjne	a,#0fh,gocode
		ljmp	exitint0
gocode:         jnb     IRM,tocode
codezo:         mov     tmpth0,th0
		mov	tmptl0,tl0
		lcall	iscode
		mov	a,codemark
		cjne	a,#0fh,gojbcode
		ljmp	exitint0
gojbcode:	jb	IRM,codezo
		mov	tmpth0,th0
		mov	tmptl0,tl0
		mov	th0,#0
		mov	tl0,#0
		lcall	codezero
		mov	a,codemark
		cjne	a,#0aah,ifone
		lcall	codegather
		ljmp	if_codeend
ifone:		lcall	codeone
		mov	a,codemark
		cjne	a,#55h,error
		lcall	codegather
if_codeend:	mov	a,pulsetime
		cjne	a,#32,if_lt32
		ljmp	processkey
if_lt32:	jc	getcode
		ljmp	exitint0

processkey:     clr     tr0
                mov     a,#usercode1
                cjne    a,coderam0,toexit
                mov     a,#usercode2
                cjne    a,coderam1,toexit
                ljmp    whatcode
toexit:         ljmp    exitint0
whatcode:       setb    BEEP
                mov     a,coderam2
                cpl     a
                cjne    a,coderam3,toexit
                cpl     a
                cjne    a,#codeCALL,ifcommand
                cpl     SERVICE
                lcall   clrmark
                lcall   clrscreen
                lcall   predisp
                mov     dispram0,#0c0h                  ;Display "SERVICE"
                mov     dispram1,#'S'
                mov     dispram2,#'E'
                mov     dispram3,#'R'
                mov     dispram4,#'V'
                mov     dispram5,#'I'
                mov     dispram6,#'C'
                mov     dispram7,#'E'
                mov     r6,#08h
                lcall   sendbyte
                lcall   setex1
                ljmp    exitint0

ifcommand:      mov     dptr,#codetab1                  ;判断是否codetab1中的按键
gotcode:	clr	a
		movc	a,@a+dptr			;取遥控码
		cjne	a,#0ffh,nextdatacode
                ljmp    ifstart
nextdatacode:	cjne	a,coderam2,nextcode
                mov     r0,#orderram0
sordram:        clr     a
		inc	dptr
		movc	a,@a+dptr
                mov     @r0,a
                inc     r0
                cjne    a,#0ah,sordram
                lcall   clrmark
                mov     ordermark,#0ffh
                lcall   clrscreen
                mov     a,orderram1
                cjne    a,#'s',iftv
                lcall   predisp
                mov     dispram0,#0c0h                  ;Display "STOP"
                mov     dispram1,#'S'
                mov     dispram2,#'T'
                mov     dispram3,#'O'
                mov     dispram4,#'P'
                mov     r6,#5
                lcall   sendbyte
                ljmp    playnext

iftv:           cjne    a,#'T',goexitint0
                mov     a,tvmark
                cjne    a,#0ffh,totv
                mov     tvmark,#00h
                ljmp    wdc
totv:           mov     tvmark,#0ffh
wdc:            lcall   predisp
                mov     dispram0,#0c0h                  ;Display "TV"
                mov     dispram1,#'T'
                mov     dispram2,#'V'
                mov     dispram3,#'K'
                mov     r6,#4
                lcall   sendbyte
                lcall   setex1
                ljmp    exitint0
goexitint0:     ;lcall   delay5ms
                ;lcall   delay5ms
                ;lcall   delay5ms
                ;lcall   delay5ms
                ;lcall   delay5ms
                ljmp    exitint0
nextcode:       inc     dptr                            ;准备比较下一个遥控码
                clr     a
                movc    a,@a+dptr
                cjne    a,#0ah,nextcode

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -