📄 control.rmh
字号:
3021f // @04c #342: CALL(send_CR)3038f // @04d #343: CALL(send_serial) ;'serial=' to display family code00506 // @04e #344: LOAD(s5,serial_number5) ;memory pointer starting MS-byte first// @04f #345: [disp_serial_loop]07050 // @04f #345: FETCH(s0,s5)301ee // @050 #346: CALL(send_hex_byte)14501 // @051 #347: COMPARE(s5,serial_number0)35055 // @052 #348: JUMP(Z,end_serial)1c501 // @053 #349: SUB(s5,1)3404f // @054 #350: JUMP(disp_serial_loop)// @055 #351: [end_serial]3021f // @055 #351: CALL(send_CR)3039c // @056 #352: CALL(send_CRC) ;'CRC=' to display CRC value06007 // @057 #353: FETCH(s0,read_ROM_CRC)301ee // @058 #354: CALL(send_hex_byte)3021f // @059 #355: CALL(send_CR)30112 // @05a #356: CALL(compute_CRC8) ;compute CRC value in s006107 // @05b #357: FETCH(s1,read_ROM_CRC) ;compare with received value15010 // @05c #358: COMPARE(s0,s1)35460 // @05d #359: JUMP(NZ,crc8_fail)30345 // @05e #360: CALL(send_Pass)34020 // @05f #361: JUMP(DS2432_menu) ;now in memory and SHA-1 functions level// @060 #362: [crc8_fail]3034d // @060 #362: CALL(send_Fail)34013 // @061 #363: JUMP(ROM_menu) ;can not proceed to next level// #364: ;// #365: ;// #366: ;// #367: ;**************************************************************************************// #368: ; DS2432 Skip ROM Command.// #369: ;**************************************************************************************// #370: ;// #371: ; The skip ROM command (CC hex) is a short cut to the memory commands and SHA-1// #372: ; functions which means that the 64 bit ROM contents do not have to be read.// #373: ;// #374: ;// @062 #375: [skip_ROM_command]003cc // @062 #375: LOAD(s3,CC) ;Skip ROM Command30161 // @063 #376: CALL(write_byte_slow) ;transmit command302c9 // @064 #377: CALL(send_OK)34020 // @065 #378: JUMP(DS2432_menu)// #379: ;// #380: ;// #381: ;// #382: ;**************************************************************************************// #383: ; DS2432 Read Memory Command.// #384: ;**************************************************************************************// #385: ;// #386: ; The read memory command (F0 hex) allows the entire memory contents to be read// #387: ; except for the secret. This routine displays the address followed by 8 bytes// #388: ; of data on each line until the address 0097 is reached.// #389: ;// #390: ; The initial 'F0' command must be followed by the 16-bit start address transmitted// #391: ; LS-byte first. Then reads must continue until address 0097 has been read for the// #392: ; command to complete naturally (otherwise a master reset is required).// #393: ;// #394: ;// #395: ;// @066 #396: [read_memory_command]003f0 // @066 #396: LOAD(s3,F0) ;read memory Command30161 // @067 #397: CALL(write_byte_slow) ;transmit command00500 // @068 #398: LOAD(s5,0) ;initial address in [s5,s4]=000000400 // @069 #399: LOAD(s4,0)01340 // @06a #400: LOAD(s3,s4) ;transmit address30161 // @06b #401: CALL(write_byte_slow)01350 // @06c #402: LOAD(s3,s5)30161 // @06d #403: CALL(write_byte_slow)// @06e #404: [rmc_line_loop]3021f // @06e #404: CALL(send_CR)01050 // @06f #405: LOAD(s0,s5) ;display 16-bit address301ee // @070 #406: CALL(send_hex_byte)01040 // @071 #407: LOAD(s0,s4)301ee // @072 #408: CALL(send_hex_byte)30222 // @073 #409: CALL(send_space)30222 // @074 #410: CALL(send_space)// @075 #411: [rmc_data_loop]30222 // @075 #411: CALL(send_space)30182 // @076 #412: CALL(read_byte_slow) ;read data into s301030 // @077 #413: LOAD(s0,s3) ;display byte301ee // @078 #414: CALL(send_hex_byte)18401 // @079 #415: ADD(s4,1) ;increment address1a500 // @07a #416: ADDCY(s5,0)12407 // @07b #417: TEST(s4,7) ;test for 8-byte boundary35475 // @07c #418: JUMP(NZ,rmc_data_loop)14498 // @07d #419: COMPARE(s4,152) ;test for last address3546e // @07e #420: JUMP(NZ,rmc_line_loop)302c9 // @07f #421: CALL(send_OK)34003 // @080 #422: JUMP(reset_menu) ;needs master reset next// #423: ;// #424: ;// #425: ;**************************************************************************************// #426: ; DS2432 Write Scratchpad Memory Command.// #427: ;**************************************************************************************// #428: ;// #429: ; The write scratchpad memory command (0F hex) allows 8-bytes of data to be written// #430: ; together with a target address for final storage in the main memory map.// #431: ;// #432: ; The DS2432 provides an initial confirmation of the write by returning a 16-bit CRC// #433: ; value which KCPSM3 tests. The CRC is computed based on the command, address and// #434: ; data transmitted (11 bytes). To achieve this, all bytes transmitted to the DS2432// #435: ; are recorded in KCPSM3 scratch pad memory in ascending locations starting at// #436: ; the location defined by constant 'command_start'.// #437: ;// #438: ; This routine prompts the user to enter the 16-bit target address is to be loaded// #439: ; into the target address registers TA2 and TA1 in the DS2432 device. Note that only// #440: ; address values below 0090 hex are valid. If the address is too high, then the// #441: ; DS2432 aborts the command and this routine will too.// #442: ;// #443: ; Also note that the address will be forced internally to the DS2432 to match an// #444: ; 8-byte boundary address in which the least significant 3-bits are reset to '000'// #445: ; regardless of the address provided. The CRC still reflects the transmitted address.// #446: ;// #447: ; After providing a valid address, the routine then prompts the user to enter// #448: ; 8 bytes of data which are written to the DS2432.// #449: ;// #450: ;// #451: ;// @081 #452: [write_scratchpad_command]00e08 // @081 #452: LOAD(sE,command_start) ;pointer to memory0030f // @082 #453: LOAD(s3,15) ;write scratchpad memory Command2f3e0 // @083 #454: STORE(s3,sE) ;record command sequence18e01 // @084 #455: ADD(sE,1) ;increment pointer30161 // @085 #456: CALL(write_byte_slow) ;transmit command// @086 #457: [wsc_addr_loop]30364 // @086 #457: CALL(send_address) ;obtain 16-bit address 0000 to FFFF in [s5,s4]30219 // @087 #458: CALL(obtain_8bits)35886 // @088 #459: JUMP(C,wsc_addr_loop) ;bad input address01500 // @089 #460: LOAD(s5,s0)30219 // @08a #461: CALL(obtain_8bits)35886 // @08b #462: JUMP(C,wsc_addr_loop) ;bad input address01400 // @08c #463: LOAD(s4,s0)01340 // @08d #464: LOAD(s3,s4) ;transmit target address TA1 (LS-Byte)2f3e0 // @08e #465: STORE(s3,sE) ;record command sequence18e01 // @08f #466: ADD(sE,1) ;increment pointer30161 // @090 #467: CALL(write_byte_slow)01350 // @091 #468: LOAD(s3,s5) ;transmit target address TA2 (MS-Byte)2f3e0 // @092 #469: STORE(s3,sE) ;record command sequence18e01 // @093 #470: ADD(sE,1) ;increment pointer30161 // @094 #471: CALL(write_byte_slow)14500 // @095 #472: COMPARE(s5,0) ;check address less than 0090 hex354c2 // @096 #473: JUMP(NZ,end_write_scratchpad) ;DS2432 aborts command and so14490 // @097 #474: COMPARE(s4,144) ;no need to read data bytes.35cc2 // @098 #475: JUMP(NC,end_write_scratchpad)00400 // @099 #476: LOAD(s4,0) ;initialise byte counter// @09a #477: [wsc_data_loop]30374 // @09a #477: CALL(send_data) ;obtain a byte of data01f40 // @09b #478: LOAD(UART_data,s4) ;display which byte requested18f30 // @09c #479: ADD(UART_data,character_0) ;convert to ASCII301b8 // @09d #480: CALL(send_to_UART)30371 // @09e #481: CALL(send_equals)30219 // @09f #482: CALL(obtain_8bits)3589a // @0a0 #483: JUMP(C,wsc_data_loop) ;bad input data01300 // @0a1 #484: LOAD(s3,s0) ;transmit byte2f3e0 // @0a2 #485: STORE(s3,sE) ;record command sequence18e01 // @0a3 #486: ADD(sE,1) ;increment pointer30161 // @0a4 #487: CALL(write_byte_slow)18401 // @0a5 #488: ADD(s4,1) ;count bytes14408 // @0a6 #489: COMPARE(s4,8)3549a // @0a7 #490: JUMP(NZ,wsc_data_loop)30182 // @0a8 #491: CALL(read_byte_slow) ;read back the 16-bit CRC into [s5,s4]01430 // @0a9 #492: LOAD(s4,s3)30182 // @0aa #493: CALL(read_byte_slow)01530 // @0ab #494: LOAD(s5,s3)2f4e0 // @0ac #495: STORE(s4,sE) ;record command sequence18e01 // @0ad #496: ADD(sE,1) ;increment pointer2f5e0 // @0ae #497: STORE(s5,sE) ;record command sequence3021f // @0af #498: CALL(send_CR)3039c // @0b0 #499: CALL(send_CRC) ;'CRC=' to display CRC value01050 // @0b1 #500: LOAD(s0,s5)301ee // @0b2 #501: CALL(send_hex_byte)01040 // @0b3 #502: LOAD(s0,s4)301ee // @0b4 #503: CALL(send_hex_byte)3021f // @0b5 #504: CALL(send_CR)0020b // @0b6 #505: LOAD(s2,11) ;11 (0B hex) bytes transmitted in this command3012c // @0b7 #506: CALL(compute_CRC16) ;compute CRC value in [s1,s0]075e0 // @0b8 #507: FETCH(s5,sE) ;compare with received value1ce01 // @0b9 #508: SUB(sE,1)074e0 // @0ba #509: FETCH(s4,sE) ;compare with received value15510 // @0bb #510: COMPARE(s5,s1)354c1 // @0bc #511: JUMP(NZ,wsc_crc16_fail)15400 // @0bd #512: COMPARE(s4,s0)354c1 // @0be #513: JUMP(NZ,wsc_crc16_fail)30345 // @0bf #514: CALL(send_Pass)34003 // @0c0 #515: JUMP(reset_menu) ;needs master reset next// @0c1 #516: [wsc_crc16_fail]3034d // @0c1 #516: CALL(send_Fail)// @0c2 #517: [end_write_scratchpad]34003 // @0c2 #517: JUMP(reset_menu) ;needs master reset next// #518: ;// #519: ;// #520: ;// #521: ;**************************************************************************************// #522: ; Write Byte Command.// #523: ;**************************************************************************************// #524: ;// #525: ; This routine simply allows you to specify any byte and write it to the DS2432 device.// #526: ; Apart from checking that the value is in the range 00 to FF hex, there is no checking// #527: ; of the meaning of the value to the DS2432 device and all attempts to track the// #528: ; state machine will be lost.// #529: ;// #530: ;// @0c3 #531: [write_byte_command]3021f // @0c3 #531: CALL(send_CR)3031f // @0c4 #532: CALL(send_Byte) ;obtain a byte of data30371 // @0c5 #533: CALL(send_equals)30219 // @0c6 #534: CALL(obtain_8bits)358c3 // @0c7 #535: JUMP(C,write_byte_command) ;bad input data01300 // @0c8 #536: LOAD(s3,s0) ;transmit byte30161 // @0c9 #537: CALL(write_byte_slow) ;transmit byte302c9 // @0ca #538: CALL(send_OK)34020 // @0cb #539: JUMP(DS2432_menu) ;remain in memory and function menu// #540: ;// #541: ;// #542: ;// #543: ;**************************************************************************************// #544: ; Read Byte Command.// #545: ;**************************************************************************************// #546: ;// #547: ; This routine will attempt to read a single byte from the DS2432 device.// #548: ; The results will be displayed on the terminal. There is no checking of the meaning// #549: ; of the value received from the DS2432 device and all attempts to track the// #550: ; state machine will be lost.// #551: ;// #552: ;// @0cc #553: [read_byte_command]3021f // @0cc #553: CALL(send_CR)3031f // @0cd #554: CALL(send_Byte) ;obtain a byte of data30371 // @0ce #555: CALL(send_equals)30182 // @0cf #556: CALL(read_byte_slow) ;receive byte01030 // @0d0 #557: LOAD(s0,s3) ;display value301ee // @0d1 #558: CALL(send_hex_byte)302c9 // @0d2 #559: CALL(send_OK)34020 // @0d3 #560: JUMP(DS2432_menu) ;remain in memory and function menu// #561: ;// #562: ;// #563: ;// #564: ;// #565: ;**************************************************************************************// #566: ; DS2432 Read Scratchpad Memory Command.// #567: ;**************************************************************************************// #568: ;// #569: ; The read scratchpad memory command (AA hex) allows the 8-bytes of data previously// #570: ; to be written into the scratchpad memory to be read back for verification together with// #571: ; the target address, a transfer status register and a 16-bit CRC value.// #572: ;// #573: ; The 16-bit CRC is formed of the command byte, address TA1 and TA2, E/S byte and 8 data// #574: ; bytes as transmitted (12 bytes). These may not be the same as the values provided// #575: ; during a previous write to scratchpad memory. All these bytes are recorded in KCPSM3// #576: ; scratch pad memory in ascending locations starting at the location defined by// #577: ; constant 'command_start'.// #578: ;// #579: ;// @0d4 #580: [read_scratchpad_command]00e08 // @0d4 #580: LOAD(sE,command_start) ;pointer to memory003aa // @0d5 #581: LOAD(s3,AA) ;read scratchpad memory Command2f3e0 // @0d6 #582: STORE(s3,sE) ;record command sequence18e01 // @0d7 #583: ADD(sE,1) ;increment pointer30161 // @0d8 #584: CALL(write_byte_slow) ;transmit command30364 // @0d9 #585: CALL(send_address) ;display 'Address='30182 // @0da #586: CALL(read_byte_slow) ;read address into [s5,s4]01430 // @0db #587: LOAD(s4,s3)30182 // @0dc #588: CALL(read_byte_slow)01530 // @0dd #589: LOAD(s5,s3)2f4e0 // @0de #590: STORE(s4,sE) ;record sequence18e01 // @0df #591: ADD(sE,1) ;increment pointer2f5e0 // @0e0 #592: STORE(s5,sE) ;record sequence18e01 // @0e1 #593: ADD(sE,1) ;increment pointer01050 // @0e2 #594: LOAD(s0,s5) ;display address301ee // @0e3 #595: CALL(send_hex_byte)01040 // @0e4 #596: LOAD(s0,s4)301ee // @0e5 #597: CALL(send_hex_byte)3037e // @0e6 #598: CALL(send_ES) ;display 'E/S='30182 // @0e7 #599: CALL(read_byte_slow) ;read E/S register2f3e0 // @0e8 #600: STORE(s3,sE) ;record sequence18e01 // @0e9 #601: ADD(sE,1) ;increment pointer01030 // @0ea #602: LOAD(s0,s3) ;display value301ee // @0eb #603: CALL(send_hex_byte)30374 // @0ec #604: CALL(send_data) ;display 'Data='30371 // @0ed #605: CALL(send_equals)00408 // @0ee #606: LOAD(s4,8) ;8 bytes to read// @0ef #607: [rsc_loop]30222 // @0ef #607: CALL(send_space)30182 // @0f0 #608: CALL(read_byte_slow) ;read data byte2f3e0 // @0f1 #609: STORE(s3,sE) ;record sequence18e01 // @0f2 #610: ADD(sE,1) ;increment pointer01030 // @0f3 #611: LOAD(s0,s3) ;display value301ee // @0f4 #612: CALL(send_hex_byte)1c401 // @0f5 #613: SUB(s4,1) ;count bytes354ef // @0f6 #614: JUMP(NZ,rsc_loop)30182 // @0f7 #615: CALL(read_byte_slow) ;read 16-bit CRC into [s5,s4]01430 // @0f8 #616: LOAD(s4,s3)30182 // @0f9 #617: CALL(read_byte_slow)01530 // @0fa #618: LOAD(s5,s3)2f4e0 // @0fb #619: STORE(s4,sE) ;record command sequence18e01 // @0fc #620: ADD(sE,1) ;increment pointer2f5e0 // @0fd #621: STORE(s5,sE) ;record command sequence3021f // @0fe #622: CALL(send_CR)3039c // @0ff #623: CALL(send_CRC) ;'CRC=' to display CRC value01050 // @100 #624: LOAD(s0,s5)301ee // @101 #625: CALL(send_hex_byte)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -