]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/utils.asm
* I2C Support added
[avrcpm.git] / avr / utils.asm
index 4d8122a763904b996116998ae1e71e5f58130a64..155c0274130b7c331a1a48adb37b0fa63c339fe8 100644 (file)
@@ -165,17 +165,17 @@ dbg_hdp:
 ;Prints the zero-terminated string following the call statement. 
 
 printstr:
-       push    zh
-       push    zl
-       push    yh
-       push    yl
-       push    temp
+       push    zh              ;SP+5
+       push    zl              ;   4
+       push    yh              ;   3
+       push    yl              ;   2
+       push    temp            ;   1
        in      yh,sph
        in      yl,spl
-       ldd     zl,y+7
-       ldd     zh,y+6
+       ldd     zl,y+7          ;SP+7  == "return adr." == String adr.
+       ldd     zh,y+6          ;SP+6
 
-       lsl zl
+       lsl zl                  ;word to byte conv.
        rol zh
 printstr_loop:
        lpm temp,z+
@@ -189,8 +189,8 @@ printstr_loop:
        rjmp printstr_loop
 
 printstr_end:
-       adiw zl,1               ;rounding
-       lsr zh
+       adiw zl,1               ;rounding up
+       lsr zh                  ;byte to word conv.
        ror zl
 
        std     y+7,zl
@@ -203,20 +203,94 @@ printstr_end:
        ret
        
 ; --------------- Debugging stuff ---------------
-; Print a line with the Z80 main registers
+; Print a line with the 8080/Z80 registers
+
+printregs:
+       mov     temp,z_flags
+       rcall   printflags
+       printstring "  A ="
+       mov     temp,z_a
+       rcall   printhex        
+       printstring " BC ="
+       ldd     temp2,y+oz_b
+       ldd     temp,y+oz_c
+       rcall   printhexw
+       printstring " DE ="
+       ldd     temp2,y+oz_d
+       ldd     temp,y+oz_e
+       rcall   printhexw
+       printstring " HL ="
+       ldd     temp2,y+oz_h
+       ldd     temp,y+oz_l
+       rcall   printhexw
+       printstring " SP="
+       movw    temp, z_spl
+       rcall   printhexw
+       printstring " PC="
+       movw    temp, z_pcl
+       rcall   printhexw
+       printstring "       "
+       movw    xl,z_pcl
+       lcall   dram_read_pp
+       rcall   printhex
+       printstring " "
+       lcall   dram_read_pp
+       rcall   printhex
+       printstring " "
+       lcall   dram_read
+       rcall   printhex
+       printstring " "
+
+#if EM_Z80
+       ldd     temp,y+oz_f2
+       rcall   printflags
+       printstring "  a'="
+       ldd     temp,y+oz_a2
+       rcall   printhex        
+       printstring " bc'="
+       ldd     temp2,y+oz_b2
+       ldd     temp,y+oz_c2
+       rcall   printhexw
+       printstring " de'="
+       ldd     temp2,y+oz_d2
+       ldd     temp,y+oz_e2
+       rcall   printhexw
+       printstring " hl'="
+       ldd     temp2,y+oz_h2
+       ldd     temp,y+oz_l2
+       rcall   printhexw
+       printstring " IX="
+       ldd     temp2,y+oz_xh
+       ldd     temp,y+oz_xl
+       rcall   printhexw
+       printstring " IY="
+       ldd     temp2,y+oz_yh
+       ldd     temp,y+oz_yl
+       rcall   printhexw
+       printstring " I="
+       ldd     temp,y+oz_i
+       rcall   printhex        
 
-;.if INS_DEBUG
+       printstring "       "
+#endif
+       ret
 
+
+#if EM_Z80
+zflags_to_ch:
+       .db     "SZ H VNC",0,0
+#else  
 zflags_to_ch:
        .db     "SZ H PNC",0,0
+#endif
        
-printregs:
+printflags:
+       push    temp2
+       mov     temp2,temp
        printnewline
-
        push    zl
        push    zh
        ldiw    z,zflags_to_ch*2
-       mov     temp2,z_flags
 pr_zfl_next:
        lpm     temp,z+
        tst     temp
@@ -232,43 +306,8 @@ pr_zfl_noflag:
 pr_zfl_end:
        pop     zh
        pop     zl      
-
-       printstring "  A ="
-       mov     temp,z_a
-       rcall   printhex        
-       printstring " BC ="
-       lds     temp2,z_b
-       lds     temp, z_c
-       rcall   printhexw
-       printstring " DE ="
-       lds     temp2,z_d
-       lds     temp, z_e
-       rcall   printhexw
-       printstring " HL ="
-       lds     temp2,z_h
-       lds     temp, z_l
-       rcall   printhexw
-       printstring " SP ="
-       movw    temp, z_spl
-       rcall   printhexw
-       printstring " PC ="
-       movw    temp, z_pcl
-       rcall   printhexw
-       printstring "       "
-       movw    xl,z_pcl
-       mem_read
-       rcall   printhex
-       printstring " "
-       adiw    x,1
-       mem_read
-       rcall   printhex
-       printstring " "
-       adiw    x,1
-       mem_read
-       rcall   printhex
-       printstring " "
+       pop     temp2
        ret
-;.endif
 
 ; vim:set ts=8 noet nowrap