mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
httpd: optimize sfr_data_to_html()
This also fixes a compiler warning. page_impl.c: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
This commit is contained in:
+19
-28
@@ -94,39 +94,30 @@ uint16_t port_status(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Converts sfr_data[] into raw hex string.
|
||||||
|
Suppress leading zeros.
|
||||||
|
*/
|
||||||
void sfr_data_to_html(void)
|
void sfr_data_to_html(void)
|
||||||
{
|
{
|
||||||
__bit print_zeros = 0;
|
uint8_t print_zeros = 0;
|
||||||
|
uint8_t val = 0;
|
||||||
|
|
||||||
if (print_zeros || sfr_data[0] & 0xf0) {
|
for (uint8_t nibble = 0; nibble < 8; nibble++) {
|
||||||
char_to_html(hex[sfr_data[0] >> 4]);
|
if (!(nibble & 1))
|
||||||
print_zeros = 1;
|
val = sfr_data[nibble>>1];
|
||||||
|
// force the swap instruction, itohex() ignores the upper nibble.
|
||||||
|
val = (val << 4) | (val >> 4);
|
||||||
|
// when print_zeros is not zero, we know that a non-zero number has printed.
|
||||||
|
// That have to print all the next numbers.
|
||||||
|
print_zeros |= val;
|
||||||
|
// only care about lower nibble, that is what is printed.
|
||||||
|
print_zeros &= 0x0f;
|
||||||
|
if (print_zeros)
|
||||||
|
charhex_to_html(val);
|
||||||
}
|
}
|
||||||
if (print_zeros || sfr_data[0] & 0xf) {
|
if (print_zeros == 0) {
|
||||||
char_to_html(hex[sfr_data[0] & 0xf]);
|
char_to_html('0');
|
||||||
print_zeros = 1;
|
|
||||||
}
|
}
|
||||||
if (print_zeros || sfr_data[1] & 0xf0) {
|
|
||||||
char_to_html(hex[sfr_data[1] >> 4]);
|
|
||||||
print_zeros = 1;
|
|
||||||
}
|
|
||||||
if (print_zeros || sfr_data[1] & 0xf) {
|
|
||||||
char_to_html(hex[sfr_data[1] & 0xf]);
|
|
||||||
print_zeros = 1;
|
|
||||||
}
|
|
||||||
if (print_zeros || sfr_data[2] & 0xf0) {
|
|
||||||
char_to_html(hex[sfr_data[2] >> 4]);
|
|
||||||
print_zeros = 1;
|
|
||||||
}
|
|
||||||
if (print_zeros || sfr_data[2] & 0xf) {
|
|
||||||
char_to_html(hex[sfr_data[2] & 0xf]);
|
|
||||||
print_zeros = 1;
|
|
||||||
}
|
|
||||||
if (print_zeros || sfr_data[3] & 0xf0) {
|
|
||||||
char_to_html(hex[sfr_data[3] >> 4]);
|
|
||||||
print_zeros = 1;
|
|
||||||
}
|
|
||||||
char_to_html(hex[sfr_data[3] & 0xf]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,4 +26,4 @@ Other memory:
|
|||||||
---------------- -------- -------- -------- --------
|
---------------- -------- -------- -------- --------
|
||||||
PAGED EXT. RAM 0 256
|
PAGED EXT. RAM 0 256
|
||||||
EXTERNAL RAM 0x0001 0x1b28 6952 16777216
|
EXTERNAL RAM 0x0001 0x1b28 6952 16777216
|
||||||
ROM/EPROM/FLASH 0x0000 0x1b967 44332 16777216
|
ROM/EPROM/FLASH 0x0000 0x1b84f 44052 16777216
|
||||||
|
|||||||
Reference in New Issue
Block a user