delay.asm

来自「yampp mp3 source code」· 汇编 代码 · 共 81 行

ASM
81
字号
/* ***********************************************************************
**
**  Copyright (C) 2002  Jesper Hansen <jesperh@telia.com> and 
**			Romuald Bialy (MIS) <romek_b@o2.pl>.
**
**
**  Yampp-7/USB - low level support library
**
**
*************************************************************************
**
**   This file is part of the yampp system.
**
**  This program is free software; you can redistribute it and/or
**  modify it under the terms of the GNU General Public License
**  as published by the Free Software Foundation; either version 2
**  of the License, or (at your option) any later version.
**
**  This program is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with this program; if not, write to the Free Software Foundation, 
**  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
**
*************************************************************************
**
**  Revision History
**
**  when         what  who	why
**
**  2002-09-22   1.0   MIS      initial public release
**
*********************************************************************** */



;********************************************************************
;*
;*  Delay stuff 
;*  Fixed for a 4.000 MHz crystal on yampp-7
;*
;********************************************************************

;			r25/r24
;void delay(u16 us) 

.global delay
delay:
 		sbiw	r24,1		; 2 cycles
 		brne	delay		; 2 (1) cycle
 		ret			; + 7 cycles for call and ret

.global delay10
delay10:
 		clr	r25
 		ldi 	r24,10
 		rjmp 	delay


;			r25/r24
;void delayms(u16 ms)
.global delayms
delayms:
		push 	r24
		push	r25
		
 		ldi 	r25,hi8(1000)
 		ldi 	r24,lo8(1000)
 		rcall 	delay
 		wdr
		pop	r25
		pop	r24
 
 		sbiw	r24,1
 		brne	delayms
 		
		ret

⌨️ 快捷键说明

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