📄 uclock.log
字号:
KCPSM3 Assembler log file for program 'uclock.psm'.
Generated by KCPSM3 version 1.30
Ken Chapman (Xilinx Ltd) 2005.
17Dec2007-09:53:20
Addr Code
000 ;KCPSM3 Program - Real Time Clock with UART communication.
000 ;
000 ;Ken Chapman - Xilinx Ltd - October 2003
000 ;
000 ;
000 ;Port definitions
000 ;
000 CONSTANT UART_status_port, 00 ;UART status input
000 CONSTANT tx_half_full, 01 ; Transmitter half full - bit0
000 CONSTANT tx_full, 02 ; FIFO full - bit1
000 CONSTANT rx_half_full, 04 ; Receiver half full - bit2
000 CONSTANT rx_full, 08 ; FIFO full - bit3
000 CONSTANT rx_data_present, 10 ; data present - bit4
000 ;
000 CONSTANT UART_read_port, 01 ;UART Rx data input
000 ;
000 CONSTANT UART_write_port, 01 ;UART Tx data output
000 ;
000 CONSTANT alarm_port, 00 ;Alarm output
000 CONSTANT alarm_control, 01 ; bit0
000 ;
000 ;Special Register usage
000 ;
000 NAMEREG sF, UART_data ;used to pass data to and from the UART
000 ;
000 NAMEREG sE, store_pointer ;used to pass location of data in scratch pad memory
000 ;
000 ;Two registers to form a 16-bit counter used to count
000 ;interrupt pulses generated at 1us intervals.
000 ;
000 NAMEREG sD, int_counter_lsb ;lower 8-bits
000 NAMEREG sC, int_counter_msb ;upper 8-bits
000 ;
000 ;
000 ;Scratch Pad Memory Locations
000 ;
000 ;
000 CONSTANT us_time_stamp_lsb, 00 ;16-bit micro-second time stamp
000 CONSTANT us_time_stamp_msb, 01
000 ;
000 CONSTANT us_time_lsb, 02 ;16-bit micro-second real time value
000 CONSTANT us_time_msb, 03
000 ;
000 CONSTANT ms_time_lsb, 04 ;16-bit milli-second real time value
000 CONSTANT ms_time_msb, 05
000 ;
000 CONSTANT real_time_hours, 06 ;Current clock time
000 CONSTANT real_time_minutes, 07
000 CONSTANT real_time_seconds, 08
000 ;
000 CONSTANT alarm_time_hours, 09 ;Alarm time
000 CONSTANT alarm_time_minutes, 0A
000 CONSTANT alarm_time_seconds, 0B
000 ;
000 CONSTANT alarm_status, 0C ;Alarm status
000 CONSTANT alarm_active, 01 ; bit0 - Alarm is active
000 CONSTANT alarm_armed, 02 ; bit1 - Alarm is armed
000 ;
000 CONSTANT time_preserve0, 10 ;storage for protection of registers
000 CONSTANT time_preserve1, 11 ;used by the real time clock routine.
000 CONSTANT time_preserve2, 12
000 CONSTANT time_preserve3, 13
000 CONSTANT time_preserve4, 14
000 CONSTANT time_preserve5, 15
000 ;
000 ;UART character strings will be stored in scratch pad memory ending in carriage return.
000 ;A string can be up to 16 characters with the start location defined by this constant.
000 ;
000 CONSTANT string_start, 20
000 ;
000 ;
000 ;Initialise the system
000 ;
000 ;
000 00000 cold_start: LOAD s0, 00 ;clear all time values
001 2E000 STORE s0, us_time_stamp_lsb[00]
002 2E001 STORE s0, us_time_stamp_msb[01]
003 2E002 STORE s0, us_time_lsb[02]
004 2E003 STORE s0, us_time_msb[03]
005 2E004 STORE s0, ms_time_lsb[04]
006 2E005 STORE s0, ms_time_msb[05]
007 2E006 STORE s0, real_time_hours[06]
008 2E007 STORE s0, real_time_minutes[07]
009 2E008 STORE s0, real_time_seconds[08]
00A 2E009 STORE s0, alarm_time_hours[09]
00B 2E00A STORE s0, alarm_time_minutes[0A]
00C 2E00B STORE s0, alarm_time_seconds[0B]
00D 2E00C STORE s0, alarm_status[0C] ;clear and disable alarm
00E 300A4 CALL alarm_drive[0A4] ;turn off alarm control output port
00F 00D00 LOAD int_counter_lsb[sD], 00 ;clear 'us' interrupt counter
010 00C00 LOAD int_counter_msb[sC], 00
011 3C001 ENABLE INTERRUPT ;enable the 1us interrupts
012 ;
012 ;
012 ;Start of the main program loop.
012 ;
012 ;A prompt is transmitted to the UART transmitter and then
012 ;a command can be entered and interpreted.
012 ;
012 ;
012 30115 prompt_input: CALL send_prompt[115] ;Prompt 'KCPSM3>'
013 300C3 CALL receive_string[0C3] ;obtain input string and maintain the time
014 ;
014 ;
014 ;Parse the string and perform actions as required
014 ;
014 ;
014 ;
014 00120 LOAD s1, string_start[20]
015 30091 CALL fetch_char_from_memory[091]
016 1400D COMPARE s0, character_CR[0D] ;carriage return does nothing
017 35012 JUMP Z, prompt_input[012]
018 14054 COMPARE s0, character_T[54] ;start of 'TIME' command?
019 3501E JUMP Z, test_for_TIME[01E]
01A 14041 COMPARE s0, character_A[41] ;start of 'ALARM' command?
01B 35037 JUMP Z, test_for_ALARM[037]
01C ;
01C ;trap other command starts here
01C ;
01C 300ED bad_input_command: CALL send_Syntax_Error[0ED] ;no valid command
01D 35012 JUMP Z, prompt_input[012]
01E ;
01E ;
01E 30091 test_for_TIME: CALL fetch_char_from_memory[091]
01F 14049 COMPARE s0, character_I[49] ;test for rest of 'TIME'
020 3541C JUMP NZ, bad_input_command[01C]
021 30091 CALL fetch_char_from_memory[091]
022 1404D COMPARE s0, character_M[4D]
023 3541C JUMP NZ, bad_input_command[01C]
024 30091 CALL fetch_char_from_memory[091]
025 14045 COMPARE s0, character_E[45]
026 3541C JUMP NZ, bad_input_command[01C]
027 ;now have a valid TIME command to process
027 30091 CALL fetch_char_from_memory[091]
028 1400D COMPARE s0, character_CR[0D] ;carriage return means display time
029 3542C JUMP NZ, set_time_command[02C]
02A 300A8 CALL transmit_time[0A8] ;transmit time to UART
02B 34012 JUMP prompt_input[012]
02C 14020 set_time_command: COMPARE s0, character_space[20]
02D 3541C JUMP NZ, bad_input_command[01C]
02E 3006D CALL test_time_string[06D] ;interpret 'hh:mm:ss' string
02F 35812 JUMP C, prompt_input[012] ;test for invalid input
030 2E606 STORE s6, real_time_hours[06] ;set new time into clock
031 2E507 STORE s5, real_time_minutes[07]
032 2E408 STORE s4, real_time_seconds[08]
033 2E004 STORE s0, ms_time_lsb[04] ;clear 'ms' counter (s0=00)
034 2E005 STORE s0, ms_time_msb[05]
035 300A8 CALL transmit_time[0A8] ;transmit new time to UART
036 34012 JUMP prompt_input[012]
037 ;
037 ;
037 30091 test_for_ALARM: CALL fetch_char_from_memory[091]
038 1404C COMPARE s0, character_L[4C] ;test for rest of 'ALARM'
039 3541C JUMP NZ, bad_input_command[01C]
03A 30091 CALL fetch_char_from_memory[091]
03B 14041 COMPARE s0, character_A[41]
03C 3541C JUMP NZ, bad_input_command[01C]
03D 30091 CALL fetch_char_from_memory[091]
03E 14052 COMPARE s0, character_R[52]
03F 3541C JUMP NZ, bad_input_command[01C]
040 30091 CALL fetch_char_from_memory[091]
041 1404D COMPARE s0, character_M[4D]
042 3541C JUMP NZ, bad_input_command[01C]
043 ;now have a valid ALARM command to process
043 30091 CALL fetch_char_from_memory[091]
044 1400D COMPARE s0, character_CR[0D] ;carriage return means display alarm time
045 35448 JUMP NZ, set_alarm_command[048]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -