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

📄 utils.inc

📁 一个操作系统启动代码
💻 INC
字号:
;###################################################################
; Fucnctions
;###################################################################



;********************************************************************
; func_GetWord_DX
;  Returns word in DX
;  
;********************************************************************
func_GetWord_DX:

	push	ax
	push	cx
	pushf
	

	xor	dx,	dx
	xor	cx,	cx


GetWord_DX_Top:

	mov	ah,	0
	int	16h

	cmp	al,	'0'
	jl	GetWord_DX_Top

	cmp	al,	'9'
	jle	GetWord_DX_KeyOK


	cmp	al,	'q'
	je	GetWord_DX_Quit

	cmp	al,	'a'
	jl	GetWord_DX_Top

	cmp	al,	'f'
	jle	GetWord_DX_KeyOK


	jmp	GetWord_DX_Top


GetWord_DX_KeyOK:
	mov	ah,	0eh
	int	10h


	shl	dx,	4

	cmp	al,	'9'
	jle	GetWord_DX_Is_A_Number
	

GetWord_DX_Is_A_Letter:
	sub	al,	'a'
	add 	al,	0ah
	jmp	GetWord_DX_Update_DX


GetWord_DX_Is_A_Number:
	sub	al,	'0'

GetWord_DX_Update_DX:
	add	dl,	al


	inc	cx
	cmp	cx,	4
	jl	GetWord_DX_Top
	jmp	GetWord_DX_Exit
	

GetWord_DX_Quit:


GetWord_DX_Exit:

	popf
	pop	cx
	pop	ax
	ret	
;********************************************************************



;********************************************************************
; func_PrintDX
;  dx = number to print
;  bl = attrib
;
;  Writes number in dx to screen as text
;********************************************************************
func_PrintDX:
	pusha

	xchg 	dl, 	dh
 	rol 	dl, 	4
 	rol 	dh, 	4

	xor 	bx, 	bx
	mov 	ah, 	0Eh
	mov 	cx, 	4
ploop:
	mov 	al, 	dl
	and 	al, 	0Fh
	shr 	dx, 	4
	add 	al, 	'0'

	cmp 	al, 	'9'
	jbe 	nochange

	add 	al, 	'A' - '9'-1

nochange:

	int 	10h

	loop 	ploop

	popa
	ret
;********************************************************************



;********************************************************************
; func_ClearScreen
;
;
;********************************************************************
func_ClearScreen:


	mov	al,	10	; new line
	mov	cx,	25	; 25 times
	mov	bl,	0	; black

cls_top:
	call	func_BiosShowChar
	loop	cls_top
	ret

;********************************************************************



;********************************************************************
; func_BiosShowChar
;  al = char
;  bl = attrib
;
;  function counts length of ASCIIZ string and displays it
;********************************************************************
func_BiosShowChar:

	 ;int 10h func 0eh : Display char
	mov	ah,	0eh
	int	10h
	ret

;********************************************************************



;********************************************************************
; func_BiosShowMessage
;  es:bp = pointer to string
;  dh = cursor row
;  dl = cursor col
;
;  function counts length of ASCIIZ string and displays it
;********************************************************************
func_BiosShowMessage:


	;
	; start string length count
	;

	push	bp
	xor	cx,	cx
	mov	bx,	bp

check_for_0:

	mov	dl,	es:[bp]
	cmp	dl,	0
	je	found_0

	inc	cx
	inc	bp
	jmp	check_for_0
	
found_0:
	pop	bp


	;
	; end string length count
	;



	 ;Get video info
   	 ;  display page in BH
	mov	AH,	0Fh
	int	10h


	 ;int 10h func 13h : Display string
	mov	ah,	13h
	mov	al,	1	;mode 1 = cursor moves + attrib in BL
	mov	bl,	07h	;char attrib (07 = white on black)
;	mov	dh,	5	;cursor row
;	mov	dl,	5	;cursor col

	int	10h

	ret

;********************************************************************

⌨️ 快捷键说明

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