system.asm

来自「凌阳单片机实现时钟并语音报时的源代码 很有趣 当毕业设计不错」· 汇编 代码 · 共 166 行

ASM
166
字号

.include resource.inc;
.include hardware.inc;
.include key.inc;
.EXTERNAL  _Interrupt_2Hz_flag         //1秒标识符
.public 	R_SpeechType;
.PUBLIC	G_Sum;
.RAM 
.VAR G_Sum                             // 进入中断的计数器
.var		R_SpeechType;
.DATA
    C_Address: .DW 0x003f,0x0006,0x005b,0x004f, 0x0066,0x006d,0x007d,0x0007,0x007f,0x006f;//'0''1''2''3''4''5''6''7''8''9'的代码
    C_Dig:     .DW 0x0000,0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x3F00;//选中LED管

.CODE
.public _Set_SpeechType;
.public F_Set_SpeechType;
F_Set_SpeechType:
_Set_SpeechType:	.PROC
		push	BP,BP to [SP];				//add if some parameters in
  		BP = SP + 1;						//
		r1 = [BP+3];						//
		[R_SpeechType] = r1;				//
		pop		BP,BP from [SP];			//
		retf;
		.ENDP


.public _System_Initial;
.public	F_System_Initial;
_System_Initial: .PROC
F_System_Initial:
		
		push	BP,BP to [SP];				//add if some parameters in
  		
		call	F_Key_Scan_Initial;			// For keyboard scan
		// Add other general initialization here
		
		//BP = SP + 1;
		//r1 = [BP+3];
			
		call	F_User_Init_IO;
		
		//r1 =0x0001;						// return value
	
		pop		BP,BP from [SP];		
		retf;
		.ENDP;

//****************************************************************
// Function: Main Loop of system                     
// Input: None
// Output: None
// Using:
// 	call F_System_ServiceLoop; (in assembly domain)
//  System_ServiceLoop(); (in C domain) 	
//****************************************************************
.public _System_ServiceLoop;
.public	F_System_ServiceLoop;
_System_ServiceLoop: .PROC                  
F_System_ServiceLoop:
		call	F_Key_DebounceCnt_Down;		// calling debounce subroutine for key scan subroutine
		call    F_Key_Scan_ServiceLoop;		// calling key scan subroutine 1 scan line
		//call    F_Key_Scan_ServiceLoop_2;		// calling key scan subroutine 2 scan line
		// Add other general service functions here	
		R1 = 0x0001;                      // Clear watch dog
		[P_Watchdog_Clear] = R1;       	//	
        retf;
        .ENDP;

.public F_User_Init_IO;        
F_User_Init_IO:        
		R1 = 0xFE00;				// IOB: b8 input, b9 output for PC-Play / SRAM addr.
        [P_IOB_Dir] = R1;			// IOB: output b15 .. b10 output
        [P_IOB_Attrib] = R1;
        R1 = 0x01FF;
        [P_IOB_Data] = R1;
        
        R1 = 0xff80;				// IOA: b15 .. b8 :output SRAM data
        [P_IOA_Dir] = R1;			// IOA: b7: Key scan line	
        [P_IOA_Attrib] = R1;		// IOA: b6 .. b4: CS*,OE*,WR
        R1 = 0x0000;				// IOA: b3 .. b0: Key input
        [P_IOA_Data] = R1; 
        RETF; 
       


//============================================================================================
//函数: SP_INT_IRQ5()
//语法:void SP_INT_IRQ5(void)
//描述:初始化中断为2HZ定时中断源
//参数:无
//返回:无
//=============================================================================================
.PUBLIC _SP_INT_IRQ5;  		       //初始化中断为2HZ定时中断源
_SP_INT_IRQ5: .PROC
    FIQ OFF
	r1 = 0x0004;
    [P_INT_Ctrl] = r1; 
    INT IRQ;          		      //开中断
   	RETF
.ENDP;


//============================================================================================
//函数: SP_INT_TIMEA()
//语法:void SP_INT_TIMEA(void)
//描述:初始化中断为1s定时中断源
//参数:无
//返回:无
//============================================================================================
.PUBLIC _SP_INT_TIMEA;
_SP_INT_TIMEA: .PROC
	r1 = 0x0000;                  //CPU选频
    [P_SystemClock] = r1;
	r1= 0xFFFF;                   //置TimeA 为 0.25s
    r1-= 0x3000;
	[P_TimerA_Data]=r1;
	r1 = 0x0000;
	[P_TimerA_Ctrl]=r1;           //4096Hz
	r1 = C_FIQ_TMA;
	[P_INT_Ctrl] = r1;            //开TimeA 中断
	INT FIQ;
    RETF
    .ENDP
    
//============================================================================================
//函数: F_Show()
//语法:void F_Show(int A,int B)
//描述:点亮LED
//参数:A,LED的位数(C_Dig),B,LED的显示值
//返回:无
//============================================================================================  
.PUBLIC _F_Show;
_F_Show: .PROC
    PUSH bp TO  [sp];  		      //弹出入口参数共两个入口参数
    bp = sp + 1   
L_Loop: 
    r1 = [bp+3]                   //取出第一个入口参数
    r3 = [bp+4]                   //取出第二个入口参数
    r2 =  r1 + C_Dig;             //取LED管的片选地址    
    r2  = [r2]   
    r4 =  r3 + C_Address          //取显示数据的地址 
    r4 = [r4] 
    r2 |= r4     
    [P_IOB_Data] = r2;            //显示数据  
    POP bp FROM [sp]
    RETF;
.ENDP

//============================================================================================
//函数: Clear_WatchDog()
//语法:void Clear_WatchDog(void)
//描述:清看门狗
//参数:无
//返回:无
//============================================================================================
.PUBLIC _Clear_WatchDog;
_Clear_WatchDog:  .PROC
	r1 = 0x01;
 	[P_Watchdog_Clear] = r1;
 	RETF
.ENDP


⌨️ 快捷键说明

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