s.c 615 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. int g(char c)
  2. {
  3. //int *p = (int *)0xC0262E; // fake address of UART TX
  4. //*p = (int)c; // fake write char over UART
  5. int i = 3;
  6. i += c;
  7. return 1;
  8. }
  9. int f(char* str)
  10. {
  11. int i = 0;
  12. char chr = *str; // first character of str
  13. while (chr != 0) // continue until null value
  14. {
  15. i += g(chr);
  16. str++; // go to next character address
  17. chr = *str; // get character from address
  18. }
  19. return i;
  20. }
  21. int main()
  22. {
  23. int i = f("StringOf15Chars");
  24. return i; //15
  25. }
  26. void interrupt()
  27. {
  28. }