mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
httpd: Also don't byte_to_html() and itoa_html() to save 1.5kbytes.
Also fixed compiler "warning page_impl.c:47: warning 126: unreachable code". But I think it was a false-positive.
This commit is contained in:
+32
-4
@@ -27,10 +27,26 @@ extern __xdata uint8_t isRTL8373;
|
||||
extern __xdata uint8_t sfp_pins_last;
|
||||
extern __xdata uint8_t vlan_names[VLAN_NAMES_SIZE];
|
||||
|
||||
inline void byte_to_html(uint8_t a)
|
||||
|
||||
/* Convert only the lower nibble to ascii HEX char.
|
||||
For convenience the upper nibble is masked out.
|
||||
*/
|
||||
inline char itohex(uint8_t val) {
|
||||
// Ignore upper nibble for convenience.
|
||||
val &= 0x0f;
|
||||
val -= 10;
|
||||
|
||||
// 10 or above
|
||||
if ((int8_t)val >= 0)
|
||||
val += ('a' - '0' - 10);
|
||||
|
||||
return val + ('0' + 10);
|
||||
}
|
||||
|
||||
// Convert uint8_t to ascii HEX char push on html-buffer.
|
||||
void charhex_to_html(char c)
|
||||
{
|
||||
outbuf[slen++] = hex[(a >> 4) & 0xf];
|
||||
outbuf[slen++] = hex[a & 0xf];
|
||||
outbuf[slen++] = itohex(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +56,19 @@ void char_to_html(char c)
|
||||
}
|
||||
|
||||
|
||||
inline void itoa_html(uint8_t v)
|
||||
// Convert uint8_t to ascii HEX char.
|
||||
void byte_to_html(uint8_t val)
|
||||
{
|
||||
uint8_t cnt = 2;
|
||||
do {
|
||||
val = (val >> 4) | (val << 4);
|
||||
charhex_to_html(val);
|
||||
cnt -= 1;
|
||||
} while(cnt);
|
||||
}
|
||||
|
||||
|
||||
void itoa_html(uint8_t v)
|
||||
{
|
||||
uint8_t t = (v / 100) % 10;
|
||||
if (t)
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ Other memory:
|
||||
---------------- -------- -------- -------- --------
|
||||
PAGED EXT. RAM 0 256
|
||||
EXTERNAL RAM 0x0001 0x1b28 6952 16777216
|
||||
ROM/EPROM/FLASH 0x0000 0x1bf4f 45844 16777216
|
||||
ROM/EPROM/FLASH 0x0000 0x1b967 44332 16777216
|
||||
|
||||
Reference in New Issue
Block a user