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

📄 serial.asm

📁 嵌入式系统基础课件
💻 ASM
字号:
		SECTION	.data
		EXTERN	_inbound_queue	; (defined in LAB6.C)
data		DB	0		; put rcvd byte here

		SECTION	.text
		ALIGN	16
		BITS	32

BASE_PORT	EQU	3F8h			; we have this in our lab

LSR_PORT	EQU	BASE_PORT+5
RBR_PORT	EQU	BASE_PORT
THR_PORT	EQU	BASE_PORT

; ---------------------------------------------------------------------
; void SerialPut(char ch)
; ---------------------------------------------------------------------
; This function uses programmed waiting loop I/O
; to output the ASCII character 'ch' to the UART.

		GLOBAL	_SerialPut

_SerialPut:	;<your code here>	; (1) Wait for THRE = 1
		;<your code here>	; (2) Output character to UART
		RET			; (3) Return to caller

; ---------------------------------------------------------------------
; void interrupt SerialISR(void)
; ---------------------------------------------------------------------
; This is an Interrupt Service Routine (ISR) for
; serial receive interrupts.  Characters received
; are placed in a queue by calling Enqueue(char).

		GLOBAL	_SerialISR
		EXTERN	_QueueInsert	; (provided by LIBPC)

_SerialISR:	;<your code here>	; (1) Enable (higher-priority) IRQs 
		;<your code here>	; (2) Preserve all registers 
		;<your code here>	; (3) Get character from UART

		MOV	[data],AL	; (4) Put character into queue 
		PUSH	DWORD data		; Param #2: address of data
		PUSH	DWORD [_inbound_queue]	; Param #1: address of queue
		CALL	_QueueInsert
		ADD	ESP,8

		;<your code here>	; (5) Enable lower priority interrupts
		;<your code here>	;       (Send Non-Specific EOI to PIC)
		;<your code here>	; (6) Restore all registers
		IRET			; (7) Return to interrupted code

⌨️ 快捷键说明

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