$include(reg96.asm) outbit equ 0e101h clk164 equ 0e102h dat164 equ 0e102h in equ 0e103h ad equ 0a000h ledbuf equ 60h time equ 40h:byte shift equ 42h:byte val equ 43h:byte cseg at 2080h di ld sp,#00c0h ld ax,#0e100h ldb 50h,#3 stb 50h,[ax] ld bx,#ledbuf ;设置显示缓冲区 ldb 50h,#0h stb 50h,[bx]+ ldb 50h, #8 stb 50h,[bl]+ ldb 50h,#0 stb 50h,[bl]+ ldb 50h,#9 stb 50h,[bl]+ ldb 50h,#10h stb 50h,[bx]+ stb 50h,[bx]+ ;显示"0809 " mloop: lcall displed ;显示 lcall delay lcall delay lcall ad_con ;调用A/D ldb al,val andb al,#0f0h ;拆字 shrb al,#4 ldb 64h,al ldb al,val andb al,#0fh ldb 65h,al ljmp mloop
ad_con: ld dx,#0a000h ;启动ADC0809 ldb 50h,#0h stb 50h,[dx] ldb 50h,#0ffh djnz 50h,$ ldb val,[dx] ;读AD结果 ret delay: ld time,#8000h djnz time,$ ret tt: ld time,#100 djnz time,$ ret displed:ld ax,#ledbuf ldb cl,#6h ldb shift,#20h loop0: ld dx,#outbit ldb 50h,#0h stb 50h,[dx] ldb bl,[ax]+ ldbze dx,bl ldb bl,disptab[dx] ldb ch,#8h dpl: shlb bl,#1 jnc ad1 ldb val,#0fdh ljmp ad2 ad1: ldb val,#0fch ad2: ld dx,#dat164 stb val,[dx] ld dx,#clk164 orb val,#2 stb val,[dx] nop nop andb val,#0fdh stb val,[dx] nop nop djnz ch,dpl ld dx,#outbit stb shift,[dx] shrb shift,#1 lcall tt ldb 50h,#0h stb 50h,[dx] djnz cl,loop0 ret disptab:dcb 3fh,06h,5bh,4fh,66h,6dh,7dh,07h dcb 7fh,6fh,77h,7ch,39h,5eh,79h,71h,0 end
|
|