8042 Keyboard Microcontroller

;--------------------------------------------------------------------------------------
; Project: info.asm
; Name: zwp
; Date: 2014/5
;--------------------------------------------------------------------------------------


data segment
	thirty	db	30		; value for mul instruction
	
	msg0	db	'-----------------------HeBei University of Enginging------------------------!'
	msg1	db	'----------------------- COMPUTER SCIENCE 2013-5 -----------------------------!'
	msg2	db	'-----------------------------------------------------------------------------!'
	msg3	db	'----- I LOVE YOU                                                             !'
	msg4	db	'----------------------I LOVE YOU                                             !'
	msg5	db	'----------------------------------------I LOVE YOU                           !'
	msg6    db      '------------------- Believe Yourself Your Will Cool--------------------------!'
	msg7	db	'One day I meet you                                                           !'
	msg8	db	'I am very happy, because I found a beautiful gril                            !'
	msg9    db      'Yes I am sure I like you!                                                    !'
	
	errmsg	db	'No You don't like me, I .......                                              !'
	
data ends

stack segment
	db	256 dup(0)
	tos	label word
stack ends

code segment
	
	main 	proc 	far
	
	assume cs:code, ds:data, ss:stack

start:
	
	mov ax, stack
	mov ss, ax
	mov sp, offset tos			; 设置堆栈

	push ds
	sub ax, ax
	push ax
	
	mov ax, data
	mov ds, ax				; 设置数据段
	
begin:
	mov ah, 1	
	int 21h					; call bios 21h 1 function 
	sub al, '0'
	jc error				; if <0 goto error
	cmp al, 9
	ja  error				; if (0, 9)‘s character is true
	
	mov bx, offset msg0			; point first message
	mul thirty				; ax = al * 30
	add bx, ax
	call display				; show message
	jmp begin	


;------------------------------------------------------------------
; if error will be executed
;-------------------------------------------------------------------
error:
	mov bx, offset errmsg			; bx = errmsg's offset address
	call display
	ret


;--------------------------------------------------------------------
; display character
;---------------------------------------------------------------------

display proc near
	
	mov cx, 30	

disp1:
	mov dl, [bx]
	call dispchar			; show char
	inc bx
	loop disp1			; cx--
	mov dl, 0dh			; 回车
	call dispchar
	mov dl, 0ah			; 换行
	call dispchar
	ret

display endp


dispchar proc near
	
	mov ah, 2
	int 21h				; show char
	ret

dispchar endp


main endp
code ends
end start


	




















写在前面:

 

  读了几本操作系统的书籍,发现一个不足。(预计也不算不足)那就是大多数讲操作系统原理的书。仅仅涵盖操作系统--这一软件层面的解释,像I/O, 内存管理,进程/线程管理,文件系统,网络(有些仅仅是略微略带一点介绍)等等。

向设备驱动,BIOS。内核层面涉及的非常少,详细的话就更是少之又少,预计和硬件联系的太紧密,所以难度大一些吧!

 

往详细了看事实上一个系统(软件 + 硬件)它们是密不可分的。仅仅要越往底层走越明显。

太紧密了。前些天翻了下模电发现(运算放大)涵盖了模电非常大一部分,最令我感觉模电 “吊炸天”的是 加法器。减法器,乘法器,除法器,积分。微分,指数....都能够在模电中实现。大家都知道(CPU中 + - * /)都是用加法实现的(详细可參看数电加法器一节)。。

越来越发现自己要学的太多了。没办法奋斗吧——少年!

 

进入正题:

                                            8042 Keyboard Microcontroller

详细细节请參阅 8042的数据手冊,我就不一一细说了。

 

来段汇编代码:

 

 

 

posted @ 2017-04-26 11:42  jzdwajue  阅读(158)  评论(0编辑  收藏  举报