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

📄 caldisp.asm

📁 这是用台湾KingB 8位单片机开发的科学计算器程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:

MACRO Clear_Mem(%1,%2,%3)        
 	lda	#%3
 	sta	PP       
        
        
        lda     #%1       ;0807
        sta     DP
1$:
        lda     #00h
        sta     i
        incdp             ;Clear page 0 (02h to 0cfh)
	lda	DP
        cmpe    #%2     
        brnz    1$
        lda	#00h
    	sta	PP     
        ENDM
MACRO PP2One()    
    	lda	#01h
    	sta	PP
        ENDM
        
MACRO PP2Zero()    
    	lda	#00h
    	sta	PP
        ENDM        
        
        

MACRO PP2store(%1)    
 
    	lda	PP
    	sta0	%1
        ENDM
        
MACRO PP2pop(%1)    
 
    	lda0	%1
    	sta	PP
    	
        ENDM        
		.area   caldisp_use2(data,abs)
;------------------------------------------------------------------------
;------------------------------------------------------------------------

		.org	0x100 	;0x1d0
GetCount::	.ds	1
BasenFlag::	.ds	1
blankCount::	.ds	1
t1count::	.ds	1
cmpFlag::	.ds	1
cmpDP::		.ds	1
cmpPP::		.ds	1

pointcount::	
chklengthbf::	.ds	1
displength::
pointbf::	.ds	1	
startbf::
dispcount::	.ds	1
EngFlag::	.ds	1
T1Flag::	.ds	1
pzdispbf::	.ds	7
DispFlag::	.ds	1
StateFlag::	.ds	1

		.area   caldisp_use3(data,abs)
		.org	0x1fa
t1dispbf::	.ds	1
t1fontbf::	.ds	1
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
		
		.area	forcaldisp(code)
CalDispLib::        	
        	       	
ErrorChk:        	
        	lda	#>ErrorFlag
        	sta	PP
        	lda	#<ErrorFlag
        	sta	DP
        	lda	i
        	cmpe	#C_ZERO
        	brnz	Allerrordisp
ModeChk:        	
        	lda0	.ModeFlag
		anda	#MASKLO
		brnz	Modedisp

StoRclallChk:       	
        	PP2One()
        	lda	.SFlag
        	anda	#STOCHK|RCLCHK
        	brnz	StoRcldisp 
        	
LogicChk:       	
        	PP2One()
        	lda	BasenFlag
		anda	#MASKHI
		brnz	LogicDisp
		
		
CalDispchk:    
        	PP2One()
        	lda	.SFlag
		anda	#CALCCHK
		brnz	CalDisp

NoStepChk:
       		lda0	.DataDP
       		cmpe	#C_ZERO
       		brnz	EngAllChk
       		sta0	.SFDP
       		br	CalDispLibend

EngAllChk:             	
        	lda0	.KeyPos
        	cmpe	#ENGKEY1
        	brz	Eng1Chk
        	cmpe	#ENGKEY2
        	brz	Eng2Chk
        	br	InsetModeChk
Eng1Chk:
        	lda	.SetFlag
		anda	#BLANKCHK
		brz	CalDispLibend
		lda	T1Flag
		ora	#ENG1GO
		sta	T1Flag
        	br	ENG1Disp
Eng2Chk:
		lda	.SetFlag
		anda	#BLANKCHK
		brz	CalDispLibend
		lda	T1Flag
		ora	#ENG2GO
		sta	T1Flag
        	br	ENG2Disp        	        					
InsetModeChk:	
		PP2One()
		lda	.SetFlag
		anda	#BLANKCHK
		brz	1$
		lda	#>.SRFlag
		sta	PP
		lda	.SRFlag
       		anda	#C_ONE
        	brnz	CalDispLibend
1$:				
		PP2One()
		lda	Insetflag
        	cmpe	#C_ONE
		brz	Insetmode
		lda0	.KeyPos
		cmpe	#MODEKEY
		brz	CalDispLibend		;keep the modekey do not to do eveything
		cmpe	#LOGICKEY
		brz	CalDispLibend		;keep the logickey do not to do eveything
DelModeChk:	cmpe	#DELKEY
		brz	Delmode
LeftKeyChk:	cmpe	#LEFTKEY
		brz	Leftchk
RightKeyChk:	cmpe	#RIGHTKEY
		brz	Rightchk
Dispchk:
		lda	#C_ZERO		
		sta	t1count
FullStepChk:
       		lda0	.DataDP
       		cmpe	#STEPCHK+1
       		brnc	1$
       		br	CalDispLibend
1$:
       		lda	.SetFlag
		anda	#~BLANKCHK
		sta	.SetFlag
ReplaceFontChk:
		lda0	.SFDP
		cmpe	#C_ZERO
		brnz	Replace
DispFontChk:
		call	Fulldisp
CalDispLibend:
        	ret
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
.DispInitial::						
		PP2One()		
		lda	#NORAM1DISP
		sta	DispFlag
		lda	#COMPSTATE|DEGSTATE
		sta	StateFlag
		lda	#DECMODE
		sta	BasenFlag
		lda	#C_ZERO
		sta0	.SFDP
.DispInitial2::
		lda	#MODESTART
		sta0	.ModeFlag
		call	Clrfullmatrix
		call	Clrfullseg
		call	DispAnsZero
		PP2One()
		lda	BasenFlag
		anda	#MASKLO
		sta	BasenFlag								
		lda	#C_ZERO	
		sta	Insetflag
		sta	T1Flag
		lda	#STARTENG
		sta	EngFlag		
		lda	#C_ZERO
		sta	t1count
		sta	t1dispbf
		lda	#C_11
		sta	GetCount
		sta	blankCount
		call	Clr_signm
		call	Clr_expm			 	
		ret		
;------------------------------------------------------------------------
;------------------------------------------------------------------------				
Fulldisp:
		call	Clrfullmatrix
fullchk:		
		PP2One()
		lda	#C_TEN
		sta	GetCount
			
		lda	#C_TWO
		sta	cmpPP
		lda	#C_ZERO
		sta	cmpDP
fullloop:
		call	Addplace
		call	Chklength
		PP2One()
        	lda	GetCount
        	suba	displength
        	sta	GetCount
        	brnc	Alldisp 	
		lda0	.DataDP
        	cmpe	cmpDP
        	brnz	fullloop
		br	Allnotfdisp
		
Allnotfdisp:
		PP2One()
		lda	#C_11
		sta	GetCount
			
		lda	#C_TWO
		sta	cmpPP
		lda	#C_ZERO
		sta	cmpDP			
Allnotfloop:
		call	Addplace
		call	Font2disp
		PP2One()
		lda0	.DataDP
		cmpe	cmpDP
		brnz	Allnotfloop
		lda	GetCount
		sta	blankCount
		br	Fulldispend1

Alldisp:
		PP2One()
		lda	#C_11
		sta	GetCount
		
		lda	#C_TWO
		sta	cmpPP
		lda0	.DataDP
		sta	cmpDP
subloop:
        	call	Decplace
        	PP2One()
		call	Chklength
        	lda	GetCount
        	suba	displength
        	sta	GetCount
        	brnc	set2disp
        	br	subloop
set2disp:	 
		PP2One()
		lda	#C_11
		sta	GetCount
		call	Addplace
Fulldisploop:
		call	Addplace
		call	Font2disp
		PP2One()
		lda0	.DataDP
		cmpe	cmpDP
		brnz	Fulldisploop
Fulldispend1:
		lda	GetCount
		sta	blankCount
Fulldispend:
		ret
;------------------------------------------------------------------------
;------------------------------------------------------------------------
RightGetCount:
		PP2One()
		lda	GetCount
		cmpe	#MAX
		brz	RightGetCountend
		deca
		sta	GetCount
RightGetCountend:
		ret				
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
Addplace::				
		PP2One()
		lda	cmpDP
		sta	DP
		lda	cmpPP
		sta	PP
		lda	i
		sta0	.DataBuf
		PP2One()
		lda	cmpDP
		inca
		sta	cmpDP		
		lda0	.DataBuf
		sta	font			
Addplaceend:	
		ret	
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
Decplace::				
		PP2One()		
		lda	cmpDP
		deca
		sta	cmpDP
		sta	DP		
		lda	cmpPP
		sta	PP
		lda	i
		sta0	.DataBuf		
		PP2One()						
		lda0	.DataBuf	
		sta	font
		
		ret			
;------------------------------------------------------------------------         		
;------------------------------------------------------------------------        	
Font2disp:
		PP2One()
		lda	font		
		anda	#MASKLO
		brz	Numberdisp						
		br	Otherkeychk		
;------------------------------------------------------------------------
Numberdisp:
		lda	font
		cmpe	#C_TEN
		brc	SetA2F
		adda	#30h
		sta	font
        	br	DispZERO2F
SetA2F:
		lda	font
        	suba	#C_TEN
        	adda	#HALFMAX
        	sta	font
DispZERO2F:
        	lda     GetCount
        	sta     dig_num
        	call    Display_5X7
        	call	RightGetCount
        	ret
;------------------------------------------------------------------------          	
Otherkeychk:				
		call	ChangeKeychk
		call	Getstart
		PP2One()
		lda	startbf
		cmpe	#MAX
		brz	chkkeyend
		call	Chklength
		lda	displength
		cmpe	#C_ZERO
		brz	chkkeyend
		sta	chklengthbf
dispwordloop:		
		PP2One()
		;lda	#^Dispwordtable
		;sta	tab_ptr+2	
		lda	#>Dispwordtable
		sta	tab_ptr+1		
		lda	#<Dispwordtable		
		sta	tab_ptr

		lda	startbf
		adda	tab_ptr
		sta	tab_ptr	
				
		call	GetLdv
		sta	font
			
		lda     GetCount
        	sta     dig_num        	
        	call    Display_5X7
        	PP2One()
        	call	RightGetCount		
		lda	startbf
		inca
		sta	startbf	
        	lda	chklengthbf
        	cmpe	#C_ONE
        	brz	chkkeyend
        	deca
        	sta	chklengthbf        		     	   	                	        	
		br	dispwordloop     	
chkkeyend:        			
		ret
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
GetLdv:		
		lda	tab_ptr+1
		addc	#C_ZERO
		sta	tab_ptr+1
		;lda	tab_ptr+2
		;addc	#C_ZERO
		;sta	tab_ptr+2
		
		;lda	tab_ptr+2
		lda	#C_ZERO
		sta	TPP
		lda	tab_ptr+1
		sta	TPH
		lda	tab_ptr
		sta	TPL
		ldv	
		ret			
;------------------------------------------------------------------------
;------------------------------------------------------------------------	
ChangeKeychk:
		PP2One()				
		lda	StateFlag
		anda	#MP2MASK
		cmpe	#COMPSTATE
		brz	2$
		cmpe	#BASENSTATE
		brz	2$
		cmpe	#SDSTATE
		brz	1$
		cmpe	#C_ZERO
		brz	2$		
1$:
		lda	font
		cmpe	#MCLCHK
		brnz	2$
		lda	#SCLDISP
		sta	font
		br	ChangeKeychkend				
2$:
		lda	StateFlag
		anda	#MP2MASK
		cmpe	#REGSTATE6
		brnz	ChangeKeychkend
		lda	font
		cmpe	#ESTIMATEXCHK
		brnz	ChangeKeychkend
		lda	#>DaltaXcnt
		sta	PP
		lda	DaltaXcnt
		cmpe	#C_ZERO
		brz	SetX1
		cmpe	#C_ONE
		brz	SetX1
		cmpe	#C_TWO
		brz	SetX2
		br	ChangeKeychkend	
				
SetX1:
		PP2One()
		lda	#EX1DISP
		sta	font
		br	ChangeKeychkend	
SetX2:
		PP2One()
		lda	#EX2DISP
		sta	font
		
ChangeKeychkend:
		ret			
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
Getstart:	
		PP2One()	
		;lda	#^Getrealtable
		;sta	tab_ptr+2	
		lda	#>Getrealtable
		sta	tab_ptr+1		
		lda	#<Getrealtable		
		adda	font			
		sta	tab_ptr				
		call	GetLdv
		sta	startbf		
		ret		
;------------------------------------------------------------------------
;------------------------------------------------------------------------		
Chklength:
		PP2One()
		;lda	#^lengthtable
		;sta	tab_ptr+2	
		lda	#>lengthtable
		sta	tab_ptr+1		
		lda	#<lengthtable
		adda	font
		sta	tab_ptr	
		call	GetLdv
		sta	displength		
		ret	
;------------------------------------------------------------------------
;------------------------------------------------------------------------
Allerrordisp:
		PP2One()
		lda	.SFlag
        	anda	#~(RCLCHK|STOCHK)
        	sta	.SFlag
		lda0	ErrorFlag 	
        	cmpe	#C_ONE
        	brz	Maerror
        	cmpe	#C_TWO
        	brz	Synerror
        	cmpe	#C_THREE
        	brz	Stkerror
        	cmpe	#C_FOUR
        	brz	Argerror
        	br	Allerrordispend	
        	
Maerror:
		lda	#MASTART
		sta	startbf
		br	Errordispgo
		
Synerror:
		lda	#SYNSTART
		sta	startbf
		br	Errordispgo
Stkerror:      	
        	lda	#STKSTART
		sta	startbf
        	br	Errordispgo
Argerror:        	
        	lda	#ARGSTART
		sta	startbf        	
Errordispgo:		
		lda0	.KeyPos
		cmpe	#LEFTKEY
		brz	Errorlrchk
		cmpe	#RIGHTKEY
		brz	Errorlrchk
		br	disperrorgo

Errorlrchk:
		lda	.SFlag
		anda	#~EQUCHK
		sta	.SFlag
		lda	.SetFlag
		anda	#~BLANKCHK
		sta	.SetFlag
		PP2Zero()
		lda	.SFDP
		cmpe	#C_ZERO
		brz	3$
		cmpe	.DataDP
		brz	3$
		PP2One()
		lda0	ErrorFlag
     		cmpe	#C_ONE
     		brnz	3$
		lda0	.SFDP
		sta	cmpDP
		lda	#C_TWO
		sta	cmpPP
        	call	Addplace
		lda	cmpDP
		sta0	.SFDP		
3$:		call	Rightchk
		br	Allerrordispend1
		
			

disperrorgo:	
		call	Clr_signm
		call	Clr_expm
		call	Clrfullmatrix				
		call	Clrfullseg		
		PP2One()		
		lda	#C_EIGHT
		sta	GetCount
		lda	#C_NINE	
		sta	chklengthbf				
disperrorloop:		
		PP2One()
		;lda	#^ErrorTable
		;sta	tab_ptr+2	
		lda	#>ErrorTable
		sta	tab_ptr+1		
		lda	#<ErrorTable		
		sta	tab_ptr

		lda	startbf
		adda	tab_ptr		
		sta	tab_ptr	
		
		call	GetLdv
		sta	font
			
		lda     GetCount
        	sta     dig_num        	
        	call    Display_5X7
        	PP2One()
        	call	RightGetCount		
		lda	startbf
		inca
		sta	startbf	
        	lda	chklengthbf
        	cmpe	#C_ONE
        	brz	Allerrordispend
        	deca
        	sta	chklengthbf        		     	   	                	        	
		br	disperrorloop
		
Allerrordispend1:
		lda	#C_ZERO
		sta0	.KeyPos
        	sta0	ErrorFlag
        	call	.ClrZ
        	call	Clrfullseg
		call	ChkDispAns
		call	ShowAnschk
        	        			
Allerrordispend:	
		ret

⌨️ 快捷键说明

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