Advertisement
MichaelPetch

watcom-1

Jul 28th, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. /*
  2. * Compile and assemble with:
  3. * wcc -0 -d0 -s -wx -zl -zu main.c
  4. * wlink FILE main.o FORMAT RAW BIN NAME main.com OPTION NODEFAULTLIBS
  5. */
  6.  
  7. #include <stdint.h>
  8.  
  9. void main(void);
  10. extern void start_main(void);
  11. extern void end_main(void);
  12. #pragma aux _cstart aborts;
  13. /* _cstart does any required initialization and calls main */
  14. void _cstart (void)
  15. {
  16. #pragma aux start_main = \
  17. "cld"
  18.  
  19. #pragma aux end_main = \
  20. "cli" \
  21. "hlt"
  22.  
  23. start_main();
  24. main();
  25. end_main();
  26. }
  27.  
  28. void bios_video_int (uint16_t ax, uint16_t bx);
  29. #pragma aux bios_video_int = \
  30. "int 0x10" \
  31. parm [ax] [bx] \
  32. modify exact [];
  33.  
  34. #define WHITE_ON_BLACK 0x07
  35.  
  36. void write(uint8_t far *s, uint16_t len)
  37. {
  38. int i;
  39.  
  40. for (i=0; i<len; i++)
  41. bios_video_int ((0x0e<<8) | s[i], WHITE_ON_BLACK);
  42. }
  43.  
  44. /* Write a NUL(0) terminated string to the console on page 0 */
  45. void write_str(uint8_t far *s)
  46. {
  47. while (*s)
  48. bios_video_int ((0x0e<<8) | *s++, WHITE_ON_BLACK);
  49. }
  50.  
  51. uint8_t ch = 0;
  52.  
  53. void main(void)
  54. {
  55. uint8_t hexchars[] = {'0','1','2','3','4','5','6','7','8','9','A','B',
  56. 'C','D','E','F'};
  57. char brownfox[] = "The quick brown fox jumps over the lazy dog";
  58.  
  59. uint8_t i = 0;
  60. ch = hexchars[i];
  61. write (&ch, 1);
  62. write (&hexchars, sizeof(hexchars));
  63. write_str (brownfox);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement