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

📄 instruction.asm

📁 sonix单片机开发程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	rlc	wk00
	rlc	wk00

	rlcm	wk00
	rlcm	wk00
	rlcm	wk00
	rlcm	wk00

;*******************************************************************************
;
; clr	M
;
	clr	wk00		; Clear memory directly

;*******************************************************************************
;
; bclr
;
	mov	a,#0ffh
	nop
	b0mov	wk00,a

	bclr	wk00.0
	bclr	wk00.7
	b0bclr 	wk00.5

;*******************************************************************************
;
; bset
;	
	bset	wk00.0
	bset	wk00.7
	bset	wk00.5

;*******************************************************************************
;
; cmprs 	a,I
;
	mov	a,#55h
	cmprs	a,#55h		; skip next line if a=55h
	jmp	@f
	
	cmprs	a,#54h
	nop
@@:

;*******************************************************************************
;
; cmprs	a,M
;
	b0mov	wk00,a
	cmprs	a,wk00		; skip next line if a=wk00

	jmp	@f		; skip !
	nop
@@:

;*******************************************************************************
;
; incs	m
;
	mov	a,#01
	b0mov	wk00,a

	incs	wk00
	incs	wk00

	incms	wk00
	incms	wk00
	
	decs	wk00
	decs	wk00

	decms	wk00
	decms	wk00

;*******************************************************************************
;
; bts0				; Bit Test Skip on 0
;
	mov	a,#0xaa
	b0mov	wk00,a		; wk00 = 1010 1010

	bts0	wk00.0		; bit 0 = 0 , --> skip next line
	nop
	
	bts0	wk00.1		; bit 1 = 1 , --> execute next line
	nop

;*******************************************************************************
;
; bts1				; Bit Test Skip on 1
; b0bts1
;
	mov	a,#0xaa
	b0mov	wk00,a		; wk00 = 1010 1010

	bts1	wk00.0		; bit 0 = 0 , --> Execute next line
	nop			; Do here

	bts1	wk00.1		; bit 1 = 1 , --> Skip next line
	nop			; Skip this Line
	nop			; just do this line
						   

;*******************************************************************************
;
; Look-Up Table
;
;*******************************************************************************

	b0mov	x,#movc_tbl$h
	b0mov	y,#movc_tbl$m
	b0mov	z,#movc_tbl$l

	movc			; get 1122 into R,A

	incms	z

	movc			; get 2233 into R,A
		
	inc_xyz			; use the macro which define in albert.h

	movc			; get 3344 into R,A
		
	inc_xyz			; use the macro

	movc			; get 4455 into R,A

	inc_xyz			; use the macro

	movc			; get 5566 into R,A

	jmp	test_jmp

movc_tbl:

	dw	0x1122		; 0x1122 = 1122h
	dw	0x2233
	dw	3344h
	dw	4455h
	dw	5566h
	dw	6677h

	nop
	nop
	nop
	nop
	nop
	nop

;*******************************************************************************
;
; Multi_Address Jump by Contents of Register A
;
;*******************************************************************************
;	Demo 
;	A0,A1,A2,A3,A4,A5,A6,A7,A0,A1...,A7,A0...
;*******************************************************************************
;
test_jmp:

	mov	a,#0		; a = 0

test_jmp10:

	and	a,#0x07

	add	pcl,a		; PCL = PCL + A
		
	jmp	a0		; A = 0
	jmp	a1		; A = 1
	jmp	a2		; A = 2
	jmp	a3
	jmp	a4
	jmp	a5
	jmp	a6
	jmp	a7		; A = 7
;
; ********************
;
; A = 0
a0:
	jmp	test_jmp90

; A = 1
;	
a1:
	jmp	test_jmp90

; A = 2
;	
a2:
	jmp	test_jmp90

; A = 3
;	
a3:
	jmp	test_jmp90

; A = 4	
a4:
	jmp	test_jmp90

; A = 5
; 	
a5:
	jmp	test_jmp90

; A = 6
; 	
a6:
	jmp	test_jmp90

; A = 7
;	
a7:
	mov	a,#0
	jmp	test_jmp90
	
test_jmp90:

	add	a,#1

	jmp	test_jmp10

;*******************************************************************************
; 	Some library Here !
;*******************************************************************************
;	Hex to ASCII Short !
;*******************************************************************************
;	in :	A	range 00~0f
;	out:	A
;*******************************************************************************

hex2asc_s:

	and	a,#0x0f
	b0mov	x,#hex2asc_tbl_s$h
	b0mov	y,#hex2asc_tbl_s$m
	b0mov	z,#hex2asc_tbl_s$l

; z = z +a

;	incs	z
	xyz_a			; xyz = xyz + a (The macro define in albert.h)
					
	movc			; get from table

	ret

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

hex2asc_tbl_s:

	dw	"0"
	dw	"1"
	dw	"2"
	dw	"3"
	dw	"4"
	dw	"5"
	dw	"6"
	dw	"7"
	dw	"8"
	dw	"9"
	dw	"A"
	dw	"B"
	dw	"C"
	dw	"D"
	dw	"E"
	dw	"F"

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

	ret



;-------------------------------------------------------------------------------
; Isr (Interrupt Service Routine)
; Arguments	: 
; Returns	: 
; Reg Change: 
;-------------------------------------------------------------------------------
/*
Processing multi-interrupt request needs to set the priority of these interrupt requests.
The IRQ flags of the 7 interrupt are controlled by the interrupt event occurring. But the
IRQ flag set doesn't mean the system to execute the interrupt vector. The IRQ flags can be
triggered by the events without interrupt enable. Just only any the event occurs and the 
IRQ will be logic "1".
There are two things need to do for multi-interrupt. One is to make a good priority for
these interrupts. Two is using IEN and IRQ flags to decide executing interrupt service 
routine or not.
*/

Isr:
;-----------------------------------
;	Save ACC and system registers
;-----------------------------------
	b0xch	A,AccBuf			;B0xch instruction do not change C,Z flag
	push					; Save 80h ~ 87h system							

;-----------------------------------
;   Check which interrupt happen
;-----------------------------------

INTP00CHK:					; Check INT0 interrupt request
	B0BTS1	FP00IEN				; Check P00IEN
	JMP	INTP01CHK			; Jump check to next interrupt
	B0BTS0	FP00IRQ				; Check P00IRQ
	JMP	INTP00				; Jump to INT0 interrupt service routine
INTP01CHK:					; Check INT1 interrupt request
	B0BTS1	FP01IEN				; Check P01IEN
	JMP	INTP02CHK			; Jump check to next interrupt
	B0BTS0	FP01IRQ				; Check P01IRQ
	JMP	INTP01				; Jump to INT1 interrupt service routine
INTP02CHK:					; Check INT2 interrupt request
	B0BTS1	FP02IEN				; Check P02IEN
	JMP	INTT0CHK			; Jump check to next interrupt
	B0BTS0	FP02IRQ				; Check P02IRQ
	JMP	INTP02				; Jump to INT2 interrupt service routine
INTT0CHK:					; Check T0 interrupt request
	B0BTS1	FT0IEN				; Check T0IEN
	JMP	INTTC0CHK			; Jump check to next interrupt
	B0BTS0	FT0IRQ				; Check T0IRQ
	JMP	INTT0				; Jump to T0 interrupt service routine
INTTC0CHK:					; Check TC0 interrupt request
	B0BTS1	FTC0IEN				; Check TC0IEN
	JMP	INTTC1CHK			; Jump check to next interrupt
	B0BTS0	FTC0IRQ				; Check TC0IRQ
	JMP	INTTC0				; Jump to TC0 interrupt service routine
INTTC1CHK:					; Check TC1 interrupt request
	B0BTS1	FTC1IEN				; Check TC1IEN
	JMP	INTSIOCHK			; Jump check to next interrupt
	B0BTS0	FTC1IRQ				; Check TC1IRQ
	JMP	INTTC1				; Jump to TC1 interrupt service routine
INTSIOCHK:					; Check SIO interrupt request
	B0BTS1	FSIOIEN				; Check SIOIEN
	JMP	INT_EXIT			; Jump to exit of IRQ
	B0BTS0	FSIOIRQ				; Check SIOIRQ
	JMP	INTSIO				; Jump to SIO interrupt service routine


;-----------------------------------
; Exit interrupt service routine
;-----------------------------------

INT_EXIT:

	pop					; Restore 80h ~ 87h system registers			
	b0xch	A,AccBuf			; B0xch instruction do not change C,Z flag

	reti					; Exit the interrupt routine



;-------------------------------------------------------------------------------
;	INT0 interrupt service routine
;-------------------------------------------------------------------------------
INTP00:
	b0bclr	FP00IRQ

	;Process P0.0 external interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	INT1 interrupt service routine
;-------------------------------------------------------------------------------
INTP01:
	b0bclr	FP01IRQ

	;Process P0.1 external interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	INT2 interrupt service routine
;-------------------------------------------------------------------------------
INTP02:
	b0bclr	FP02IRQ

	;Process P0.2 external interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	T0 interrupt service routine
;-------------------------------------------------------------------------------
INTT0:
	b0bclr	FT0IRQ

	;Process T0 internal interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	TC0 interrupt service routine
;-------------------------------------------------------------------------------
INTTC0:
	b0bclr	FTC0IRQ

	;Process TC0 timer interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	TC1 interrupt service routine
;-------------------------------------------------------------------------------
INTTC1:
	b0bclr	FTC1IRQ

	;Process TC1 timer interrupt here

	jmp	INT_EXIT
;-------------------------------------------------------------------------------
;	SIO interrupt service routine
;-------------------------------------------------------------------------------
INTSIO:
	b0bclr	FSIOIRQ

	;Process SIO interrupt here

	jmp	INT_EXIT

;-------------------------------------------------------------------------------
;	SysInit
; 	Initialize I/O, Timer, Interrupt, etc.
;-------------------------------------------------------------------------------
SysInit:

	ret

;-------------------------------------------------------------------------------
; ClrRAM
; Use index @YZ to clear RAM  (00h~7Fh)
;-------------------------------------------------------------------------------

ClrRAM:

; RAM Bank 0
	clr	Y    				;Select bank 0 
	b0mov	Z,#0x7f				;Set @YZ address from 7fh

ClrRAM10:
	clr	@YZ				;Clear @YZ content
	decms	Z  				;z = z - 1 , skip next if z=0
	jmp	ClrRAM10
	clr 	@YZ				;Clear address 0x00

; RAM Bank 1
	mov	A,#1
	b0mov	Y,A				;Select bank 1
	b0mov	Z,#0x7f				;Set @YZ address from 17fh

ClrRAM20:
	clr	@YZ				;Clear @YZ content
	decms	Z				;z = z - 1 , skip next if z=0
	jmp 	ClrRAM20
	clr 	@YZ				;Clear address 0x100
	ret
;-------------------------------------------------------------------------------


	ENDP

⌨️ 快捷键说明

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