From: bg Date: Tue, 15 Dec 2009 22:20:46 +0000 (+0000) Subject: BMW-small -100 bytes / fix for help cmd X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=24e4a90f4aea9941ff89472ea7d1349d6db82029;p=avr-crypto-lib.git BMW-small -100 bytes / fix for help cmd --- diff --git a/bmw/bmw_small-asm.S b/bmw/bmw_small-asm.S index 03f8702..0699893 100644 --- a/bmw/bmw_small-asm.S +++ b/bmw/bmw_small-asm.S @@ -2107,43 +2107,9 @@ dst0 = 10 dst1 = 11 .global bmw256 bmw256: - push_range 2, 11 - stack_alloc_large 64+4 - adiw r30, 1 - movw ctx0, r30 - movw dst0, r24 - movw msg0, r22 - movw len0, r18 - movw len2, r20 - movw r24, ctx0 - rcall bmw256_init -20: - mov r18, len2 - or r18, len3 - breq 50f - movw r24, ctx0 - movw r22, msg0 - rcall bmw_small_nextBlock - ldi r20, 2 - sub len1, r20 - sbc len2, r1 - sbc len3, r1 - ldi r20, 64 - add msg0, r20 - adc msg1, r1 - rjmp 20b -50: - movw r24, ctx0 - movw r22, msg0 - movw r20, len0 - rcall bmw_small_lastBlock - movw r24, dst0 - movw r22, ctx0 - rcall bmw256_ctx2hash - stack_free_large 64+4 - pop_range 2, 11 - ret - + push r16 + ldi r16, 1 + rjmp bmw_small_all /******************************************************************************* * void bmw224(void* dest, const void* msg, uint32_t length_b){ @@ -2174,6 +2140,10 @@ dst0 = 10 dst1 = 11 .global bmw224 bmw224: + push r16 + clr r16 + +bmw_small_all: push_range 2, 11 stack_alloc_large 64+4 adiw r30, 1 @@ -2183,7 +2153,11 @@ bmw224: movw len0, r18 movw len2, r20 movw r24, ctx0 - rcall bmw224_init + ldi r30, pm_lo8(init_lut) + ldi r31, pm_hi8(init_lut) + add r30, r16 + adc r31, r1 + icall 20: mov r18, len2 or r18, len3 @@ -2206,7 +2180,19 @@ bmw224: rcall bmw_small_lastBlock movw r24, dst0 movw r22, ctx0 - rcall bmw224_ctx2hash + ldi r30, pm_lo8(c2h_lut) + ldi r31, pm_hi8(c2h_lut) + add r30, r16 + adc r31, r1 + icall stack_free_large 64+4 pop_range 2, 11 + pop r16 ret + +init_lut: + rjmp bmw224_init + rjmp bmw256_init +c2h_lut: + rjmp bmw224_ctx2hash + rjmp bmw256_ctx2hash diff --git a/test_src/cli-core.S b/test_src/cli-core.S index cbe9760..69671f6 100644 --- a/test_src/cli-core.S +++ b/test_src/cli-core.S @@ -38,7 +38,7 @@ * param cmdlist: r24:r25 */ TMP_CNT_0 = 26 -TMP_CNT_1 = 27 +TMP_CNT_1 = 27 .global max_cmd_length max_cmd_length: movw r30, r24 @@ -68,10 +68,10 @@ max_cmd_length: brge 1b movw r24, TMP_CNT_0 rjmp 1b - + /******************************************************************************/ .global echo_ctrl -echo_ctrl: +echo_ctrl: call strstrip tst r24 brne 3f @@ -95,14 +95,14 @@ echo_ctrl: cpi r20, 'n' breq exit_1 cpi r20, 'f' - breq exit_0 + breq exit_0 ret -exit_1: +exit_1: ldi r20, 1 rjmp exit exit_0: ldi r20, 0 -exit: +exit: sts cli_echo, r20 ret print_echo_status: @@ -128,12 +128,12 @@ print_echo_status: clr r25 ldi r24, '\n' rcall cli_putc - ret + ret pecho: .asciz "\r\necho is o" /******************************************************************************/ -/* int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist) +/* int8_t search_and_call(char* cmd, uint16_t maxcmdlength, PGM_VOID_P cmdlist) * param cmd: r24:r25 * param maxcmdlength: r22:r23 * param cmdlist: r20:r21 @@ -146,7 +146,7 @@ CMD_1 = 17 snc_auto_help: movw r24, r22 movw r22, r20 - rcall cli_auto_help + rcall cli_auto_help snc_return_1: ldi r24, 1 rjmp snc_return @@ -154,7 +154,7 @@ snc_return_2: ldi r24, 2 snc_return: clr r25 - ret + ret .global search_and_call search_and_call: @@ -183,7 +183,7 @@ search_and_call: tst r18 brne 1f 2: rjmp snc_auto_help -1: +1: push r28 push r29 push CMD_0 @@ -237,7 +237,7 @@ snc_found: icall ldi r24, 1 rjmp 5f -4: ldi r24, 2 +4: ldi r24, 2 snc_return_0: clr r24 5: pop LEN_1 @@ -261,7 +261,7 @@ nocommand_str: * param cmdlist: r22:r23 */ ITM_0 = 12 -ITM_1 = 13 +ITM_1 = 13 CMD_0 = 14 CMD_1 = 15 LEN_0 = 16 @@ -300,7 +300,7 @@ cli_option_listing: movw r24, ITM_0 rcall cli_putstr_P rjmp 1b -99: +99: ldi r24, lo8(prompt_str) ldi r25, hi8(prompt_str) rcall cli_putstr_P @@ -310,9 +310,9 @@ cli_option_listing: pop_range 12, 17 ret -prompt_str: +prompt_str: .asciz "\r\n>" -itemprefix_str: +itemprefix_str: .asciz "\r\n " /******************************************************************************/ @@ -322,7 +322,7 @@ itemprefix_str: */ TMP_0 = 14 -TMP_1 = 15 +TMP_1 = 15 LEN_0 = 16 LEN_1 = 17 LST_0 = 28 @@ -341,7 +341,7 @@ cli_auto_help: lpm r25, Z+ movw r28, r30 adiw r24, 0 - breq 99f + breq 99f movw TMP_0, r24 rcall cli_putstr_P movw r24, TMP_0 @@ -357,9 +357,9 @@ cli_auto_help: brne 2b 4: ldi r24, lo8(sep_str) ldi r25, hi8(sep_str) + rcall cli_putstr_P ldi r22, lo8(none_str) ldi r23, hi8(none_str) - rcall cli_putstr_P movw r30, r28 lpm r24, Z+ lpm r25, Z+ @@ -369,7 +369,7 @@ cli_auto_help: ldi r22, lo8(yes_str) ldi r23, hi8(yes_str) 5: movw r24, r22 - rcall cli_putstr_P + rcall cli_putstr_P ldi r24, lo8(sep2_str) ldi r25, hi8(sep2_str) rcall cli_putstr_P @@ -388,7 +388,7 @@ cli_auto_help: rcall cli_putc adiw r28, CMDLIST_ENTRY_SIZE-4 rjmp 1b -99: +99: pop_range 28, 29 pop_range 14, 17 ret