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

📄 sha1prog.psm

📁 和picoblaze完全兼容的mcu ip core
💻 PSM
📖 第 1 页 / 共 5 页
字号:
                           ;
                           ;
                           ;ASCII table
                           ;
                           CONSTANT character_a, 61
                           CONSTANT character_b, 62
                           CONSTANT character_c, 63
                           CONSTANT character_d, 64
                           CONSTANT character_e, 65
                           CONSTANT character_f, 66
                           CONSTANT character_g, 67
                           CONSTANT character_h, 68
                           CONSTANT character_i, 69
                           CONSTANT character_j, 6A
                           CONSTANT character_k, 6B
                           CONSTANT character_l, 6C
                           CONSTANT character_m, 6D
                           CONSTANT character_n, 6E
                           CONSTANT character_o, 6F
                           CONSTANT character_p, 70
                           CONSTANT character_q, 71
                           CONSTANT character_r, 72
                           CONSTANT character_s, 73
                           CONSTANT character_t, 74
                           CONSTANT character_u, 75
                           CONSTANT character_v, 76
                           CONSTANT character_w, 77
                           CONSTANT character_x, 78
                           CONSTANT character_y, 79
                           CONSTANT character_z, 7A
                           CONSTANT character_A, 41
                           CONSTANT character_B, 42
                           CONSTANT character_C, 43
                           CONSTANT character_D, 44
                           CONSTANT character_E, 45
                           CONSTANT character_F, 46
                           CONSTANT character_G, 47
                           CONSTANT character_H, 48
                           CONSTANT character_I, 49
                           CONSTANT character_J, 4A
                           CONSTANT character_K, 4B
                           CONSTANT character_L, 4C
                           CONSTANT character_M, 4D
                           CONSTANT character_N, 4E
                           CONSTANT character_O, 4F
                           CONSTANT character_P, 50
                           CONSTANT character_Q, 51
                           CONSTANT character_R, 52
                           CONSTANT character_S, 53
                           CONSTANT character_T, 54
                           CONSTANT character_U, 55
                           CONSTANT character_V, 56
                           CONSTANT character_W, 57
                           CONSTANT character_X, 58
                           CONSTANT character_Y, 59
                           CONSTANT character_Z, 5A
                           CONSTANT character_0, 30
                           CONSTANT character_1, 31
                           CONSTANT character_2, 32
                           CONSTANT character_3, 33
                           CONSTANT character_4, 34
                           CONSTANT character_5, 35
                           CONSTANT character_6, 36
                           CONSTANT character_7, 37
                           CONSTANT character_8, 38
                           CONSTANT character_9, 39
                           CONSTANT character_colon, 3A
                           CONSTANT character_fullstop, 2E
                           CONSTANT character_semi_colon, 3B
                           CONSTANT character_minus, 2D
                           CONSTANT character_plus, 2B
                           CONSTANT character_comma, 2C
                           CONSTANT character_less_than, 3C        ;'<'
                           CONSTANT character_greater_than, 3E     ;'>'
                           CONSTANT character_open, 28             ;'('
                           CONSTANT character_close, 29            ;')'
                           CONSTANT character_divide, 2F           ;'/'
                           CONSTANT character_equals, 3D
                           CONSTANT character_space, 20
                           CONSTANT character_CR, 0D               ;carriage return
                           CONSTANT character_LF, 0A               ;line feed
                           CONSTANT character_question, 3F         ;'?'
                           CONSTANT character_dollar, 24
                           CONSTANT character_exclaim, 21          ;'!'
                           CONSTANT character_BS, 08               ;Back Space command character
                           CONSTANT character_XON, 11              ;Flow control ON
                           CONSTANT character_XOFF, 13             ;Flow control OFF
                           ;
                           ;
                           ;**************************************************************************************
                           ; Initialise the system and welcome message
                           ;**************************************************************************************
                           ;
               cold_start: CALL DS_wire_init                       ;Ensure DS_wire is not driven (pulled High)
                           CALL delay_1s                           ;Allow everything to settle!
            welcome_start: CALL send_welcome                       ;start up message and version number
                           ;
                           ;
                           ;**************************************************************************************
                           ; Reset Main menu and command selection
                           ;**************************************************************************************
                           ;
                           ; The main program allows you to use four of the DS2432 memory and SHA function
                           ; commands. A simple menu is displayed and you are guided to enter more information
                           ; when required. All the communication and protocol required to get the DS2432 ready
                           ; to receive memory and SHA function commands has been automated although information
                           ; is displayed to indicate the procedures being executed.
                           ;
                           ; Before any memory and function commands are available a master reset and read ROM
                           ; command must be issued.
                           ;
               warm_start: CALL send_CR
                           CALL send_CR
                           CALL DS_init_regular_mode               ;master reset
                           JUMP C, warm_start                      ;repeat reset if no presence pulse detected
                           CALL read_ROM_command                   ;read ROM command and display results
                           ;
                           ; After a valid ROM command the DS2432 specific memory commands and SHA-1
                           ; functions become accessible. This program assumes that the ROM command did
                           ; 'Pass' so you will need to check yourself. If this program automatically
                           ; reset the DS2432 and tried again and there was a fault it would just cause
                           ; the display to roll continuously and not be very informative!
                           ;
                           ; Each of the DS2432 commands selected from the menu will require the master reset
                           ; and read ROM command to be repeated before being able to proceed with the next
                           ; memory or SHA-1 function. This is automated by the program.
                           ;
                           ;
              DS2432_menu: CALL send_DS2432_menu                   ;Menu and command selection
                           CALL send_CR
                           ;
            DS2432_prompt: CALL send_CR                            ;prompt for user input
                           CALL send_CR
                           LOAD UART_data, character_greater_than  ;prompt for input
                           CALL send_to_UART
                           CALL read_upper_case
                           COMPARE s0, character_1                 ;test for commands and execute as required
                           JUMP Z, write_scratchpad_command
                           COMPARE s0, character_2
                           JUMP Z, read_scratchpad_command
                           COMPARE s0, character_3
                           JUMP Z, load_first_secret_command
                           COMPARE s0, character_4
                           JUMP Z, read_auth_page_command
                           CALL send_CR                            ;no valid command input
                           LOAD UART_data, character_question      ;display ???
                           CALL send_to_UART
                           CALL send_to_UART
                           CALL send_to_UART
                           JUMP DS2432_prompt                      ;Try again!
                           ;
                           ;
                           ;
                           ;
                           ;**************************************************************************************
                           ; DS2432 Read ROM Command.
                           ;**************************************************************************************
                           ;
                           ; The read ROM command (33 hex) allows the 8-bit family code, 48-bit unique serial
                           ; number and 8-bit CRC to be read from the DS2432 device.
                           ;
                           ; This routine reads the values and places them in KCPSM3 scratch pad memory
                           ; locations for future reference. These locations should be defined with constants
                           ; as follows and MUST be in consecutive ascending locations.
                           ;
                           ;  family_code
                           ;     Location to store family code which should be 33 hex
                           ;  serial_number0 to serial_number5
                           ;     6 bytes to hold 48-bit serial number (LS-byte first).
                           ;  read_ROM_CRC
                           ;     8-bit CRC value for the above data.
                           ;
                           ;
                           ; The routine also displays the values read and performs a verification of the
                           ; 8-bit CRC displaying a 'Pass' or 'Fail' message as appropriate.
                           ;
         read_ROM_command: LOAD s3, 33                             ;Read ROM Command
                           CALL write_byte_slow                    ;transmit command
                           LOAD s5, family_code                    ;memory pointer
            read_ROM_loop: CALL read_byte_slow                     ;read response into s3
                           STORE s3, (s5)                          ;store value
                           COMPARE s5, read_ROM_CRC                ;8-bytes to read
                           JUMP Z, display_ROM
                           ADD s5, 01
                           JUMP read_ROM_loop
              display_ROM: CALL send_CR
                           CALL send_code                          ;'code=' to display family code
                           FETCH s0, family_code
                           CALL send_hex_byte
                           CALL send_CR
                           CALL send_sn                            ;'s/n=' to display family code
                           LOAD s5, serial_number5                 ;memory pointer starting MS-byte first
         disp_serial_loop: FETCH s0, (s5)
                           CALL send_hex_byte
                           COMPARE s5, serial_number0
                           JUMP Z, end_serial
                           SUB s5, 01
                           JUMP disp_serial_loop
               end_serial: CALL send_CR

⌨️ 快捷键说明

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