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

📄 timer.asm

📁 一个小型的操作系统,采用gcc进行开发,几千行的代码,方便初学者学习
💻 ASM
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Snixos Project version 1.0, 2003.6; (C) Copyright 2003,2004,2005 Jockeyson,KeqiangGao <Snallie@tom.com>; All Rights Reserved.; Distributed under the terms of the GNU General Public License.;; This program is a free and open source software and you can redistribute ; it and/or modify it under the terms of the GNU General Public License as; published by the Free Software Foundation. As no any liability is assumed ; for any incidental or consequential damages in connection with the ; information or program fragments contained herein,so any exception arised; is at your own risk. It is ABSOLUTELY WITHOUT ANY WARRANTY.; Bug report please send to Snallie@tom.com .;;  timer.asm : Programmable Interval Timer 8253 code for Snixos Project;  Author  : snallie@tom.com;  Time    : 2003.6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bits 32global setPITspeed, delayMSextern tickcount;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; setPITspeed; 	Set's the PIT Frequemcy, you'll get a timer interrupt ;	Hz times per second.  ; args: Push the frequency in Hz on to the stack;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;setPITspeed:	push ebp	mov ebp,esp	push eax	push ebx	push edx	xor edx, edx	mov eax, 0x1234DC		; PIT Frequency	mov ebx, [esp+20]	div ebx			        ; Our frequency	mov ebx, eax			; Save frequency	xor eax, eax	mov al, 0x36			; Command word	out 0x43, al			mov ax, bx	out 0x40, al			; New Frequency	mov al, ah	out 0x40, al	pop edx	pop ebx	pop eax	leave	ret ; End setPITspeed;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; delayMS; 	void delayMS( int duration); args: Push the amount of MS you want to delay on the stack; to call in C: delayMS(100);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;delayMS:	push ebp	mov ebp,esp	push eax	push ebx	push ecx	mov eax, [tickcount]		; Get Current tickcount	mov ecx, 1	mul ecx				; Mul 10 to get ms	mov ecx, [esp+20]		; Get arg.continue:	push eax			; Save the prvious tickcount	mov eax, [tickcount]		; Get current tickcount	mov ebx, 1	mul ebx				; Mul 10 to get ms	mov ebx, eax	pop eax				; Restore eax	sub ebx, eax			; Subtract earlier value	cmp ebx, ecx			; Are they equal yet?	jb .continue			; Nope, one more time	pop ecx	pop eax	pop ebx	leave	ret ; end of delayMS

⌨️ 快捷键说明

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