1 ; Print and Debug functions
3 ; Copyright (C) 2010 Leo C.
5 ; This file is part of avrcpm.
7 ; avrcpm is free software: you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
12 ; avrcpm is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
27 ;Print a unsigned lonng value to the uart
28 ; temp4:temp3:temp2:temp = value
39 clr yl ;yl = stack level
41 ultoa1: ldi z_flags, 32 ;yh = temp4:temp % 10
42 clr yh ;temp4:temp /= 10
54 cpi yh, 10 ;yh is a numeral digit '0'-'9'
58 cp temp,_0 ;Repeat until temp4:temp gets zero
65 ultoa5: cpi yl,3 ; at least 3 digits (ms)
71 ultoa6: pop temp ;Flush stacked digits
86 ;Prints temp2:temp in hex to the uart
94 ;Prints temp in hex to the uart
101 ;Prints the lower nibble
115 ; Prints a single space
121 ; Prints 16 bytes pointed to by Z in hex.
123 dbg_hexdump_line: ;Address in z
127 movw temp,z ;Print address
129 ldi temp2,16 ;16 byte per line
165 ;Prints the zero-terminated string following the call statement.
175 ldd zl,y+7 ;SP+7 == "return adr." == String adr.
178 lsl zl ;word to byte conv.
192 adiw zl,1 ;rounding up
193 lsr zh ;byte to word conv.
205 ; --------------- Debugging stuff ---------------
206 ; Print a line with the 8080/Z80 registers
293 ldiw z,zflags_to_ch*2
298 cpi temp,' ' ; Test if no flag
301 ldi temp,' ' ; Flag not set
312 ; vim:set ts=8 noet nowrap