1 ; Print and Debug functions
3 ; Copyright (C) 2010-2013 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/>.
20 ; $Id: utils.asm 93 2014-01-03 16:32:32Z rapid $
27 ;Print a unsigned lonng value to the uart
28 ; r15:r14:temp2:temp = value
39 clr yl ;yl = stack level
41 ultoa1: ldi z_flags, 32 ;yh = r15:temp % 10
42 clr yh ;r15:temp /= 10
54 cpi yh, 10 ;yh is a numeral digit '0'-'9'
58 cp temp,_0 ;Repeat until r15: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
124 ;-----------------------------------------------------------------------
125 ;Prints the zero-terminated string following the call statement.
135 ldd zl,y+7 ;SP+7 == "return adr." == String adr.
138 lsl zl ;word to byte conv.
152 adiw zl,1 ;rounding up
153 lsr zh ;byte to word conv.
165 ; ------------------------ String functions -------------------------
169 ; String compare (z, y), one z-string in flash.
197 ;-----------------------------------------------------------------------
198 ; String compare (x, y, temp2). Max temp2 bytes are compared.
214 ;-----------------------------------------------------------------------
215 ; Memory compare: DRAM - AVR-RAM
216 ; DRAM-Addr. in x, AVRRAM-Addr. in y
217 ; Compare temp3 bytes.
219 ; Return Z-Flag == 1 if match
220 ; temp, _tmp0 destroyed
233 ; --------------- Debugging stuff ---------------
240 ldi temp, low(RAMEND+1)
241 ldi temp2,high(RAMEND+1)
242 ldi temp3,SRAMFILL_VAL
246 brne stack_search_found
256 printstring "Stack used (bytes): "
270 ;-----------------------------------------------------------------------
271 ; Prints 16 bytes RAM, pointed to by Z in hex.
273 dbg_hexdump_line: ;Address in z
277 movw temp,z ;Print address
280 ldi temp2,16 ;16 byte per line
316 ; Prints temp2 bytes RAM, pointed to by Z in hex.
318 dbg_hexdump: ;Address in z
322 movw temp,z ;Print address
356 ;-----------------------------------------------------------------------
357 ; Print a line with the 8080/Z80 registers
456 ldiw z,zflags_to_ch*2
461 cpi temp,' ' ; Test if no flag
464 ldi temp,' ' ; Flag not set
475 ; vim:set ts=8 noet nowrap