pio_showhex.s

来自「ALTERA的NIOS处理器!文件直接可以打开直接选择器件重新编译!」· S 代码 · 共 57 行

S
57
字号

		.include "nios_macros.s"
		.text

;----------------------------------------
;         Name: nr_pio_showhex
;  Description: Display lowest 2 hex digits on seven segment display.
;        Input: %o0 = value
;       Output: none
; Side Effects: %g0 & %g1 altered
;    CWP Depth: 0
;
; This is a "PIO" routine, but is only
; meaningful on a pio connected to a
; dual seven segment display, using 8 bits
; for each digit.
;
; More? the display must be called
; na_seven_seg_pio.
;

	.global nr_pio_showhex

	.align 2
_hex_digits_data:
	; 0-9
	.byte	0x01,0x4f,0x12,0x06,0x4c,0x24,0x20,0x0f,0x00,0x04
	; a-f
	.byte	0x08,0x60,0x72,0x42,0x30,0x38
nr_pio_showhex:
	MOVIA	%g3,_hex_digits_data
	;
	; Left Hand Digit, goes to PIO bits 8-14
	;
	MOV	%g0,%o0
	LSRI	%g0,4
	ANDIP	%g0,0x000f	; extract out high digit
	ADD	%g0,%g3
	LD	%g1,[%g0]	; get the right hand digit
	EXT8d	%g1,%g0		; extract which byte
	LSLI	%g1,8		; (could swap on nios16?)
		
	;
	; Right Hand Digit, goes to PIO bits 0-7
	;
	MOV	%g0,%o0
	ANDIP	%g0,0x000f	; extract low digit
	ADD	%g0,%g3
	LD	%g2,[%g0]
	EXT8d	%g2,%g0		; extract which byte
	OR	%g1,%g2

	MOVIA	%g0,na_seven_seg_pio
	JMP	%o7
	ST	[%g0],%g1

⌨️ 快捷键说明

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