The unified diff between revisions [65df00aa..] and [4cc7246c..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'uart.c'
# # old_revision [65df00aa2705ce33fd74f4dd706d2879fe99b2b0] # new_revision [4cc7246c1b6c809c9dc15997798f6deed15b3631] # # patch "uart.c" # from [7c57b3658cbce3a90ff7773d9e4a0b1d626c68af] # to [37a2e0459886f7f9c4e4a5361e21d50902dbe3f7] # ============================================================ --- uart.c 7c57b3658cbce3a90ff7773d9e4a0b1d626c68af +++ uart.c 37a2e0459886f7f9c4e4a5361e21d50902dbe3f7 @@ -155,6 +155,31 @@ void putint(unsigned int n) { putstr(s+i); } +void putint_s(int n) { + char s[12]; + int i; + int neg; + + /* OK, technically, this might not work properly for the most + * negative possible number. Oh well. + */ + neg = (n < 0); + if (neg) + n = -n; + + i = 11; + s[i] = '\0'; + + do { + s[--i] = n % 10 + '0'; + } while ((n /= 10) > 0); + + if (neg) + s[--i] = '-'; + + putstr(s+i); +} + void puthex(unsigned int n) { char s[9]; int i;