Hub Hex Dump addition for JohnnyMac's jm_serial & jm_fullduplexserial spin library
Cluso99
Posts: 18,069
in Propeller 2
Here is a new object to add on to JohnnyMac's serial library.
Hopefully his jm_serial and jm_fullduplexserial objects will become a standard.
I use the hub hex dump facility often to display data in hub (and cog and lut) using the ROM serial/debugger. So I've created an add-on object that returns a formatted string ready for output to the serial port, or to a screen. It's quite simply a format routine that returns a single 80 character line (pointer) that is terminated in <cr><lf> followed by $0 for the string termination.
Jon,
You're welcome to include it in your routines directly if you think it's worthwhile.
In essence, this is it - nothing fancy.
Hopefully his jm_serial and jm_fullduplexserial objects will become a standard.
I use the hub hex dump facility often to display data in hub (and cog and lut) using the ROM serial/debugger. So I've created an add-on object that returns a formatted string ready for output to the serial port, or to a screen. It's quite simply a format routine that returns a single 80 character line (pointer) that is terminated in <cr><lf> followed by $0 for the string termination.
Jon,
You're welcome to include it in your routines directly if you think it's worthwhile.
In essence, this is it - nothing fancy.
pub hubdump(addr1) : p_str | addr, value, chr, i, j ' Return pointer to string of 4 longs from hub (1 line on 16 byte boundary) bytefill(@pbuf, 0, PBUF_SIZE) ' clear buffer p_str := @pbuf ' point to start of buffer addr := addr1 & $ffff0 ' round down hub address to 16 byte boundary value := addr << ((8 - 5) << 2) ' prepare for hex display of 5 digits (<<3*4) repeat 5 byte[p_str++] := lookupz((value ROL= 4) & $F : "0".."9", "A".."F") ' insert 5 digit hub address byte[p_str++] := ":" byte[p_str++] := " " repeat i from 0 to 3 repeat j from 0 to 3 byte[p_str++] := lookupz((byte[addr] >> 4): "0".."9", "A".."F") ' insert 2 hex digits... byte[p_str++] := lookupz((byte[addr++] & $F): "0".."9", "A".."F") byte[p_str++] := " " byte[p_str++] := " " addr-=16 ' point back to start byte[p_str++] := "'" repeat i from 0 to 15 ' insert 16 bytes as ascii chars chr := byte[addr++] if (chr < $20) | (chr > $7E) ' ascii character $20..$7E, else print "." byte[p_str++] := "." else byte[p_str++] := chr byte[p_str++] := "'" byte[p_str++] := CR byte[p_str++] := LF p_str := @pbuf ' point to start of buffer