www.pudn.com > 20.rar > test17.asm


//====================================================== 
//  The information contained herein is the exclusive property of 
//  Sunnnorth Technology Co. And shall not be distributed, reproduced, 
//  or disclosed in whole in part without prior written permission. 
//              (C) COPYRIGHT 2003  SUNNORTH TECHNOLOGY CO. 
//                         ALL RIGHTS RESERVED 
//  The entire notice above must be reproduced on all authorized copies. 
//======================================================== 
 
//============================================================ 
//  工程名称:test17.scs 
//  功能描述: SPCE061 2K SRAM 的读写。A口低8位控制LED,当读写错误时,点亮LED 
//  文件来源:《实验仪实验指导书》 "实验二十  片内 2K SRAM 读写"   
//  IDE环境:   SUNPLUS u'nSPTM  IDE 1.8.4 
// 
//  涉及的库: 
//  组成文件: 
//    	      test17.asm          
//============================================================ 
 
//============================================================ 
// 文件名称:test17.asm     
// 实现功能: SPCE061 2K SRAM 的读写.A口接LED,当读写错误时,点亮LED 
//============================================================ 
 
		.include hardware.inc 
		.define SRAM_SIZE  0x0800; 
 
		.code  
		.public  _main; 
//=============================================================  
// 函数名称:  _main 
// 功能描述:  SPCE061 2K SRAM 的读写.A口接LED,当读写错误时,点亮LED。 
// 语法格式:  _main 
//入口参数:     无 
// 出口参数:    无 
// 注意事项:    仅为用户模型 
//================================================================= 
_main: 
		r1=0x00ff;                           	 //初始化A0-A7口为同相低电平输出端口       
		[P_IOA_Dir]=r1; 
		[P_IOA_Attrib]=r1; 
		r1=0x0000; 
		[P_IOA_Data]=r1; 
		r1=0x0040;					         	//初始化IOB6为同相高电平输出 
		[P_IOB_Dir]=r1; 
		[P_IOB_Attrib]=r1; 
		[P_IOB_Data]=r1; 
		call sramWrite; 
		call sramRead; 
loop: 
		jmp loop;  
     
//===================================================================================// 
//描述:向0~0x7fa中写数据7fa~0 
//===================================================================================// 
		.public  sramWrite ; 
sramWrite: .proc 
		r3 = 0x0000; 
		r1 = sp; 
		r2 = 0x0000; 
loopWR: 
		[r1] = r2; 
		r2 += 1; 
		r1 -= 1; 
		jnz loopWR;    
		retf; 
		.endp; 
//===================================================================================// 
//描述:从0~0x7fa中读数据0x7fa~0,失败,则点亮LED 
//===================================================================================// 
sramRead: 
		r1 += 1; 
		r2 -= 1; 
		F_sramRead:       
		r3 = [r1]; 
		cmp r3,r2; 
		jne Fail_LED;    
		r2 -= 1; 
		r1 += 1;   
		cmp r1,sp; 
		jne  F_sramRead;  
		retf; 
    
Fail_LED:                               	//点亮与IOA0~IOA7相连的LED灯 
		r1 = 0x00ff; 
		[P_IOA_Data] = r1; 
		retf;