X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fcli-hexdump.S;h=d071a0031126720a1d83597c2edf2c1de2413e05;hb=b8aa8d06134ce687993cb3148d66ebd86dbf1d6f;hp=0a34984ffd344bd97909e327463af47edad0b159;hpb=52ec168ece9d61bd9cb652235dfe8faee6232a11;p=avr-crypto-lib.git diff --git a/test_src/cli-hexdump.S b/test_src/cli-hexdump.S index 0a34984..d071a00 100644 --- a/test_src/cli-hexdump.S +++ b/test_src/cli-hexdump.S @@ -1,7 +1,7 @@ /* cli-hexdump.S */ /* This file is part of the AVR-Huffman. - Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ #include "avr-asm-macros.S" /******************************************************************************/ -/* cli_hexdump_byte +/* cli_hexdump_byte * param data: r24 */ .global cli_hexdump_byte @@ -43,10 +43,10 @@ cli_hexdump_byte: clr r25 lpm r24, Z rcall cli_putc - ret + ret /******************************************************************************/ -/* cli_hexdump +/* cli_hexdump * param data: r24:r25 * param length: r22:r23 */ @@ -63,19 +63,19 @@ cli_hexdump: breq hexdump_exit 2: ld r24, Y+ - rcall cli_hexdump_byte + rcall cli_hexdump_byte subi r16, 1 - sbc r17, r1 + sbci r17, 0 brne 2b -hexdump_exit: +hexdump_exit: pop r17 pop r16 pop r29 pop r28 ret - + /******************************************************************************/ -/* cli_hexdump_rev +/* cli_hexdump_rev * param data: r24:r25 * param length: r22:r23 */ @@ -94,11 +94,11 @@ cli_hexdump_rev: 1: breq hexdump_exit ld r24, -Y - rcall cli_hexdump_byte + rcall cli_hexdump_byte subi r16, 1 sbci r17, 0 rjmp 1b - + /******************************************************************************/ /* cli_hexdump2 * param data: r24:r25 @@ -114,20 +114,20 @@ cli_hexdump2: movw r16, r22 movw r26, r16 adiw r26, 0 -1: +1: breq hexdump_exit ld r24, Y+ rcall cli_hexdump_byte clr r25 ldi r24,' ' rcall cli_putc - + subi r16, 1 sbci r17, 0 rjmp 1b /******************************************************************************/ -/* void cli_hexdump_block(const void* data, uint16_t length, uint8_t indent, uint8_t width) +/* void cli_hexdump_block(const void *data, uint16_t length, uint8_t indent, uint8_t width) * param data: r24:r25 * param length: r22:r23 * param indent: r20 @@ -142,11 +142,9 @@ LENG_1 = 17 .global cli_hexdump_block cli_hexdump_block: - tst r22 - brne 1f - tst r23 - brne 1f - ret + movw r26, r22 + adiw r26, 0 + breq simple_ret 1: push WIDTH push INDENT @@ -158,18 +156,18 @@ cli_hexdump_block: mov WIDTH, r18 mov INDENT, r20 movw DATA_0, r24 - movw LENG_0, r22 + movw LENG_0, r22 2: - clr r25 +; clr r25 ldi r24, '\r' rcall cli_putc - clr r25 +; clr r25 ldi r24, '\n' rcall cli_putc mov r4, INDENT tst r4 breq 4f -3: clr r25 +3:; clr r25 ldi r24, ' ' rcall cli_putc dec r4 @@ -181,18 +179,17 @@ cli_hexdump_block: tst LENG_1 brne 7f cp WIDTH, LENG_0 - breq 6f - brmi 7f + brlo 7f mov r22, LENG_0 -6: inc r4 -7: +6: inc r4 +7: rcall cli_hexdump2 add DATA_0, WIDTH adc DATA_1, r1 sub LENG_0, WIDTH - sbc LENG_0, r1 + sbc LENG_1, r1 tst r4 - breq 2b + breq 2b pop r4 pop LENG_1 pop LENG_0 @@ -200,6 +197,7 @@ cli_hexdump_block: pop DATA_0 pop INDENT pop WIDTH +simple_ret: ret - - + +