📄 ls_test.psm
字号:
;
;**************************************************************************************
;Initialise the system
;**************************************************************************************
;
;
cold_start: LOAD s0, LED0
OUTPUT s0, LED_port
;
CALL send_welcome ;Write welcome message to UART
;
LOAD s0, 00 ;clear counter
STORE s0, step_counter4
STORE s0, step_counter3
STORE s0, step_counter2
STORE s0, step_counter1
STORE s0, step_counter0
;
OUTPUT s0, line_store_input_L ;Clear input to line store
OUTPUT s0, line_store_input_M
OUTPUT s0, line_store_input_H
STORE s0, test_data_in0
STORE s0, test_data_in1
STORE s0, test_data_in2
;
;
LOAD s2, 0F ;purge line stores with 4000 writes of zero
LOAD s1, A0
purge_loop: OUTPUT s0, line_store_write_en ;dummy write to enable line store
SUB s1, 01
JUMP NC, purge_loop
SUB s2, 01
JUMP NC, purge_loop
;
;
STORE s0, fast_mode ;turn off fast mode by default
;
LOAD s0, 01 ;default first value is 000001 hex
OUTPUT s0, line_store_input_L
STORE s0, test_data_in0
;
STORE s0, auto_inc ;turn auto increment on by default
;
;**************************************************************************************
; Main program
;**************************************************************************************
;
; Provides a prompt to which an input with one of the following formats is expected...
;
; set hhhhhh - Set value to be written into line store.
; 'hhhhhh' is a 6 digit hex value.
;
; cycle n - drive line store with 'n' cycles and display results.
; 'n' is a decimal number up to 9999.
;
; reset - Clears the counter and also purges all line store of all values.
;
; auto on - Turns on the auto increment of the set value so that each
; seccessive write of data will be different and useful for
; determining the delay length.
;
; auto off - Turns off the auto increment function so that all successive writes
; to the line stores will be identical.
;
;
; fast on - Turns on the fast execute mode in which the output to the
; display via the UART is turned off during multi-cycle operations.
; This results in much greater speed.
;
; fast off - Turns off fast execution mode allowing all data to be displayed.
;
; The input allows a degree of editing to be performed and upper and lower case letters
; to be used.
;
warm_start: FETCH s0, auto_inc ;use LED0 to display state of auto increment
FETCH s1, fast_mode ;use LED1 to display state of fast mode
COMPARE s1, 00
JUMP Z, set_LEDs
OR s0, LED1
set_LEDs: OUTPUT s0, LED_port
;
CALL send_prompt ;Prompt 'KCPSM3>'
CALL receive_string ;obtain input string of up to 16 characters
CALL upper_case_string ;convert string to upper case
;
LOAD sE, string_start ;sE is memory pointer
FETCH s0, (sE) ;test for carriage return
COMPARE s0, character_CR
JUMP Z, warm_start
COMPARE s0, character_S ;test for 'S' of 'SET' command
JUMP Z, SET_command
COMPARE s0, character_C ;test for 'C' of 'CYCLE' command
JUMP Z, CYCLE_command
COMPARE s0, character_R ;test for 'R' of 'RESET' command
JUMP Z, RESET_command
COMPARE s0, character_A ;test for 'A' of 'AUTO' command
JUMP Z, AUTO_command
COMPARE s0, character_F ;test for 'F' of 'FAST' command
JUMP Z, FAST_command
bad_command: CALL send_CR ;no valid command entered
CALL send_Error
JUMP warm_start
;
;Processing potential 'RESET' command
;
RESET_command: CALL read_next_char ;test for 'E' of 'RESET' command
COMPARE s0, character_E
JUMP NZ, bad_command
CALL read_next_char ;test for 'S' of 'RESET' command
COMPARE s0, character_S
JUMP NZ, bad_command
CALL read_next_char ;test for 'E' of 'RESET' command
COMPARE s0, character_E
JUMP NZ, bad_command
CALL read_next_char ;test for 'T' of 'RESET' command
COMPARE s0, character_T
JUMP NZ, bad_command
CALL read_next_char ;test for a carriage return
COMPARE s0, character_CR
JUMP NZ, bad_command
JUMP cold_start
;
;Processing potential 'SET' command
;
SET_command: CALL read_next_char ;test for 'E' of 'SET' command
COMPARE s0, character_E
JUMP NZ, bad_command
CALL read_next_char ;test for 'T' of 'SET' command
COMPARE s0, character_T
JUMP NZ, bad_command
CALL read_next_char ;test for a space
COMPARE s0, character_space
JUMP NZ, bad_command
;read value into register set [sC,sB,sA]
CALL read_next_char ;read two character hex value
LOAD s3, s0
CALL read_next_char
LOAD s2, s0
CALL ASCII_byte_to_hex ;convert to value in s0
JUMP C, bad_command
LOAD sC, s0 ;remember value
CALL read_next_char ;read two character hex value
LOAD s3, s0
CALL read_next_char
LOAD s2, s0
CALL ASCII_byte_to_hex ;convert to value in s0
JUMP C, bad_command
LOAD sB, s0 ;remember value
CALL read_next_char ;read two character hex value
LOAD s3, s0
CALL read_next_char
LOAD s2, s0
CALL ASCII_byte_to_hex ;convert to value in s0
JUMP C, bad_command
LOAD sA, s0 ;remember value
CALL read_next_char ;test for carriage return to end command
COMPARE s0, character_CR
JUMP NZ, bad_command
STORE sA, test_data_in0 ;store new line store input value
STORE sB, test_data_in1
STORE sC, test_data_in2
OUTPUT sA, line_store_input_L ;Write data to register driving line store
OUTPUT sB, line_store_input_M
OUTPUT sC, line_store_input_H
CALL send_OK
JUMP warm_start
;
;Processing potential 'AUTO' command
;
AUTO_command: CALL read_next_char
COMPARE s0, character_U ;test for 'U' of 'AUTO' command
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_T ;test for 'T' of 'AUTO' command
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_O ;test for 'O' of 'AUTO' command
JUMP NZ, bad_command
CALL read_next_char ;test for a space
COMPARE s0, character_space
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_O ;test for 'O' of 'ON' or 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_N ;test for 'N' of 'ON'
JUMP Z, test_auto_ON
COMPARE s0, character_F ;test for 'F' of 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_F ;test for 'F' of 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_CR ;test for carriage return
JUMP NZ, bad_command
LOAD s0, 00 ;turn off auto increment
JUMP update_auto
test_auto_ON: CALL read_next_char
COMPARE s0, character_CR ;test for carriage return
JUMP NZ, bad_command
LOAD s0, 01 ;turn on auto increment
update_auto: STORE s0, auto_inc
CALL send_OK
JUMP warm_start
;
;Processing potential 'FAST' command
;
FAST_command: CALL read_next_char
COMPARE s0, character_A ;test for 'A' of 'FAST' command
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_S ;test for 'S' of 'FAST' command
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_T ;test for 'T' of 'FAST' command
JUMP NZ, bad_command
CALL read_next_char ;test for a space
COMPARE s0, character_space
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_O ;test for 'O' of 'ON' or 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_N ;test for 'N' of 'ON'
JUMP Z, test_fast_ON
COMPARE s0, character_F ;test for 'F' of 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_F ;test for 'F' of 'OFF'
JUMP NZ, bad_command
CALL read_next_char
COMPARE s0, character_CR ;test for carriage return
JUMP NZ, bad_command
LOAD s0, 00 ;turn off fast mode
JUMP update_fast
test_fast_ON: CALL read_next_char
COMPARE s0, character_CR ;test for carriage return
JUMP NZ, bad_command
LOAD s0, 01 ;turn on fast mode
update_fast: STORE s0, fast_mode
CALL send_OK
JUMP warm_start
;
;Processing potential 'CYCLE' command
;
CYCLE_command: CALL read_next_char
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -