uclock.log
来自「UART transmitter and receiver mocros」· LOG 代码 · 共 870 行 · 第 1/5 页
LOG
870 行
046 300AC CALL transmit_alarm_time[0AC] ;transmit time to UART
047 34012 JUMP prompt_input[012]
048 14020 set_alarm_command: COMPARE s0, character_space[20] ;test for ON or OFF command
049 3541C JUMP NZ, bad_input_command[01C]
04A 30091 CALL fetch_char_from_memory[091]
04B 1404F COMPARE s0, character_O[4F]
04C 35055 JUMP Z, set_alarm_on_off[055]
04D 1C101 SUB s1, 01 ;move memory pointer back to first character of 'hh:mm:ss' string
04E 3006D CALL test_time_string[06D] ;interpret 'hh:mm:ss' string
04F 35812 JUMP C, prompt_input[012] ;test for invalid input
050 2E609 STORE s6, alarm_time_hours[09] ;set new time into clock
051 2E50A STORE s5, alarm_time_minutes[0A]
052 2E40B STORE s4, alarm_time_seconds[0B]
053 300AC CALL transmit_alarm_time[0AC] ;transmit new alarm time and status
054 34012 JUMP prompt_input[012]
055 30091 set_alarm_on_off: CALL fetch_char_from_memory[091]
056 1404E COMPARE s0, character_N[4E] ;test for 'ON'
057 35460 JUMP NZ, test_OFF[060]
058 30091 CALL fetch_char_from_memory[091]
059 1400D COMPARE s0, character_CR[0D]
05A 3541C JUMP NZ, bad_input_command[01C]
05B 0600C FETCH s0, alarm_status[0C] ;turn alarm on
05C 0C002 OR s0, alarm_armed[02]
05D 2E00C STORE s0, alarm_status[0C]
05E 300AC CALL transmit_alarm_time[0AC] ;transmit alarm time and status
05F 34012 JUMP prompt_input[012]
060 14046 test_OFF: COMPARE s0, character_F[46] ;test for for 'OFF'
061 3541C JUMP NZ, bad_input_command[01C]
062 30091 CALL fetch_char_from_memory[091]
063 14046 COMPARE s0, character_F[46]
064 3541C JUMP NZ, bad_input_command[01C]
065 30091 CALL fetch_char_from_memory[091]
066 1400D COMPARE s0, character_CR[0D]
067 3541C JUMP NZ, bad_input_command[01C]
068 00000 LOAD s0, 00 ;turn alarm off and stop an active alarm
069 2E00C STORE s0, alarm_status[0C]
06A 300A4 CALL alarm_drive[0A4] ;turn off alarm
06B 300AC CALL transmit_alarm_time[0AC] ;transmit alarm time and status
06C 34012 JUMP prompt_input[012]
06D ;
06D ;
06D ;
06D ;
06D ;Read an 'hh:mm:ss' time string and provide new values.
06D ;
06D ;The string must be provided in successive scratch pad memory locations
06D ;with the s1 register containing the location of the first character.
06D ;
06D ;A correct time specification will result in the return of new values
06D ;as follows:-
06D ;
06D ; s6 = hours
06D ; s5 = minutes
06D ; s4 = seconds
06D ;
06D ;If the syntax is incorrect or values are not in the correct ranges an
06D ;'Invalid Time' message will be transmitted and the CARRY flag will be set
06D ;
06D ;Registers used s0, s1, s6, s5 and s4
06D ;
06D 301EC test_time_string: CALL 2char_to_value[1EC] ;obtain hours value
06E 3588B JUMP C, invalid_time[08B] ;test for non-decimal characters
06F 01620 LOAD s6, s2 ;remember hours
070 18101 ADD s1, 01 ;increment memory pointer past hours
071 30091 CALL fetch_char_from_memory[091]
072 1403A COMPARE s0, character_colon[3A] ;test for colon
073 3548B JUMP NZ, invalid_time[08B]
074 301EC CALL 2char_to_value[1EC] ;obtain minutes value
075 3588B JUMP C, invalid_time[08B] ;test for non-decimal characters
076 01520 LOAD s5, s2 ;remember minutes
077 18101 ADD s1, 01 ;increment memory pointer past minutes
078 30091 CALL fetch_char_from_memory[091]
079 1403A COMPARE s0, character_colon[3A] ;test for colon
07A 3548B JUMP NZ, invalid_time[08B]
07B 301EC CALL 2char_to_value[1EC] ;obtain seconds value
07C 3588B JUMP C, invalid_time[08B] ;test for non-decimal characters
07D 01420 LOAD s4, s2 ;remember minutes
07E 18101 ADD s1, 01 ;increment memory pointer past seconds
07F 30091 CALL fetch_char_from_memory[091]
080 1400D COMPARE s0, character_CR[0D] ;finish with carriage return
081 3548B JUMP NZ, invalid_time[08B]
082 ;Have values for hh:mm:ss but need to test if each is valid range.
082 14618 COMPARE s6, hours_in_a_day[18]
083 35C8B JUMP NC, invalid_time[08B]
084 1453C COMPARE s5, minutes_in_an_hour[3C]
085 35C8B JUMP NC, invalid_time[08B]
086 1443C COMPARE s4, seconds_in_a_minute[3C]
087 35C8B JUMP NC, invalid_time[08B]
088 00000 LOAD s0, 00
089 2000E SR0 s0 ;reset CARRY flag (with s0=0)
08A 2A000 RETURN ;time string was OK
08B 30125 invalid_time: CALL send_Invalid[125]
08C 300E7 CALL send_space[0E7]
08D 30134 CALL send_Time[134]
08E 00001 LOAD s0, 01
08F 2000E SR0 s0 ;set CARRY flag
090 2A000 RETURN ;time string was bad
091 ;
091 ;
091 ;Fetch character from memory, convert to upper case
091 ;and increment memory pointer.
091 ;
091 ;The memory pointer is provided in register s1.
091 ;The character obtained is returned in register s0.
091 ;
091 ;Registers used s0 and s1.
091 ;
091 07010 fetch_char_from_memory: FETCH s0, (s1) ;read character
092 301E2 CALL upper_case[1E2] ;convert to upper case
093 18101 ADD s1, 01 ;increment memory pointer
094 2A000 RETURN
095 ;
095 ;
095 ;
095 ;Read one character from the UART
095 ;
095 ;Character read will be returned in a register called 'UART_data' and will be
095 ;echoed to the UART transmitter.
095 ;
095 ;The routine first tests the receiver FIFO buffer to see if data is present.
095 ;If the FIFO is empty, the routine waits until there is a character to read.
095 ;As this could take any amount of time the wait loop includes a call to the
095 ;subroutine which updates the real time clock.
095 ;
095 ;Registers used s0 and UART_data
095 ;
095 04000 read_from_UART: INPUT s0, UART_status_port[00] ;test Rx_FIFO buffer
096 12010 TEST s0, rx_data_present[10]
097 3549A JUMP NZ, read_character[09A]
098 30185 CALL update_time[185] ;Perform useful operation whilst waiting
099 34095 JUMP read_from_UART[095]
09A 04F01 read_character: INPUT UART_data[sF], UART_read_port[01] ;read from FIFO
09B 3009D CALL send_to_UART[09D] ;echo received character
09C 2A000 RETURN
09D ;
09D ;
09D ;
09D ;Transmit one character to the UART
09D ;
09D ;Character supplied in register called 'UART_data'.
09D ;
09D ;The routine first tests the transmit FIFO buffer to see if it is full.
09D ;If the FIFO is full, the routine waits until there is space which could
09D ;be as long as it takes to transmit one complete character.
09D ;
09D ; Baud Rate Time per Character (10 bits)
09D ; 9600 1,024us
09D ; 19200 521us
09D ; 38400 260us
09D ; 57600 174us
09D ; 115200 87us
09D ;
09D ;Since this is a relatively long duration, the wait loop includes a
09D ;call to the subroutine which updates the real time clock.
09D ;
09D ;Registers used s0
09D ;
09D 04000 send_to_UART: INPUT s0, UART_status_port[00] ;test Tx_FIFO buffer
09E 12002 TEST s0, tx_full[02]
09F 350A2 JUMP Z, UART_write[0A2]
0A0 30185 CALL update_time[185] ;Perform useful operation whilst waiting
0A1 3409D JUMP send_to_UART[09D]
0A2 2CF01 UART_write: OUTPUT UART_data[sF], UART_write_port[01]
0A3 2A000 RETURN
0A4 ;
0A4 ;
0A4 ;
0A4 ;
0A4 ;Alarm output
0A4 ;
0A4 ;Uses the alarm status scratch pad memory to set or reset the alarm
0A4 ;control bit on the alarm output port.
0A4 ;
0A4 ;Registers used s0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?