📄 shownum.asm
字号:
;
; Do a poor job of emulating the Number Sequencing
; CPU operation
INCLUDE "p18f242.inc"
; use these configuration bits for all files
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
__CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
; Register Usage
CBLOCK 0x0 ; registers start at location 0 in data memory
loc,dout ; reserve space for two byte variables
ENDC
; C Program equivalent
;
; unsigned char loc, out ;
;
; loc = 0;
; do {
; if (loc == 0) {
; dout = 3; // non-local sequence
; dout = 2;
; dout = 4;
; } else {
; dout = 8; // local sequence
; dout = 5;
; dout = 6;
; dout = 1;
; }
; } while (1); // infinite loop
org 0
goto main
org 0x0200
main
;
;loc = 0;
;
clrf loc ;loc <- 0, do not assume '0' value of register
; value after reset
; bsf loc,0 ; uncomment this line to set loc to 0x01 initially
; do
; if (loc == 0)
;
top
btfsc loc,0 ; skip next instruction if bit 0 is '0'
goto loc_seq
;start non-local sequence
; out = 3;
movlw 3 ; w <- 3
movwf dout ; dout <- w
; out = 2;
movlw 2 ; w <- 2
movwf dout ; dout <- w
; out = 4;
movlw 4 ; w <- 4
movwf dout ; dout <- w
;; start local sequence
loc_seq
; out = 8;
movlw 8 ; w <- 8
movwf dout ; dout <- w
; out = 5;
movlw 5 ; w <- 5
movwf dout ; dout <- w
; out = 6;
movlw 6 ; w <- 6
movwf dout ; dout <- w
; out = 1;
movlw 1 ; w <- 1
movwf dout ; dout <- w
goto top ; loop forever
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -