]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/utils.asm
* New config option: SRAM_FILL
[avrcpm.git] / avr / utils.asm
index a995179d4315aa53c03d98f05030a70105e1c3a8..d8f881440ee57bc32ec13e68f04036f05e55eb7c 100644 (file)
@@ -161,7 +161,7 @@ dbg_hdp:
        pop     temp2
        ret
        
-
+;-----------------------------------------------------------------------
 ;Prints the zero-terminated string following the call statement. 
 
 printstr:
@@ -209,20 +209,32 @@ printstr_end:
 ; String compare (z, y), one z-string in flash.
 
 strcmp_p:
-       lpm     _tmp0,z+
-       tst     _tmp0
-       breq    strcmp_pex
-
-       ld      temp, y+
+       ld      temp,y+
        lpm     _tmp0, z+
        sub     temp,_tmp0
        brne    strcmp_pex
        tst     _tmp0
        brne    strcmp_p
+       sub     temp,temp
 strcmp_pex:
        ret
+
 #endif
 
+#if 0
+
+strcmp_p:
+       ld      temp,y+
+       lpm     _tmp0,z+
+       sub     temp,_tmp0
+       cpse    _tmp0,_0
+       breq    strcmp_p
+       ret
+
+
+#endif
+
+;-----------------------------------------------------------------------
 ; String compare (x, y, temp2). Max temp2 bytes are compared.
 
 strncmp_p:
@@ -239,8 +251,62 @@ strncmp_peq:
 strncmp_pex:
        ret
 
+;-----------------------------------------------------------------------
+; Memory compare: DRAM - AVR-RAM
+;      DRAM-Addr. in x, AVRRAM-Addr. in y 
+;      Compare temp3 bytes.
+;
+;      Return Z-Flag == 1 if match
+;      temp, _tmp0  destroyed
+;
+
+memcmp_d:
+       rcall   dram_read_pp
+       ld      _tmp0,y+
+       cp      temp,_tmp0
+       brne    memcmpd_nomatch
+       dec     temp3
+       brne    memcmp_d
+memcmpd_nomatch:
+       ret
 
 ; --------------- Debugging stuff ---------------
+
+
+.if SRAM_FILL
+
+stackusage_print:
+       ldiw    z,ramtop
+       ldi     temp,  low(RAMEND+1)
+       ldi     temp2,high(RAMEND+1)
+       ldi     temp3,SRAMFILL_VAL
+stack_search_l:
+       ld      _tmp0,z+
+       cp      temp3,_tmp0
+       brne    stack_search_found
+       cp      zl,temp
+       cpc     zh,temp2
+       brne    stack_search_l
+
+stack_search_found:
+       sbiw    z,1
+       sub     temp, zl
+       sbc     temp2,zh
+       printnewline
+       printstring "Stack used (bytes): "
+       push    r15
+       push    r14
+       clr     r14
+       clr     r15
+       rcall   print_ultoa
+       pop     r14
+       pop     r15
+       ret
+.endif
+
+
+
+;-----------------------------------------------------------------------
 ; Print a line with the 8080/Z80 registers
 
 printregs: