home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 355_01 / slk1.exe / SHERLOCK / DUMPREGS.C < prev    next >
C/C++ Source or Header  |  1988-04-14  |  1KB  |  68 lines

  1. /*
  2.     Test program to print out registers.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int ax = 0;
  8. int bx = 0;
  9. int cx = 0;
  10. int dx = 0;
  11. int sp = 0;
  12. int bp = 0;
  13. int si = 0;
  14. int di = 0;
  15. int ds = 0;
  16. int cs = 0;
  17. int ss = 0;
  18. int es = 0;
  19. int ip = 0;
  20. int flags = 0;
  21.  
  22. main(argc, argv)
  23. int argc;
  24. char **argv;
  25. {
  26.     sl_regs();
  27.     printf("\n\ndump of registers\n\n");
  28.     phex("ax", ax);
  29.     phex("bx", bx);
  30.     phex("cx", cx);
  31.     phex("dx", dx);
  32.     phex("sp", sp);
  33.     phex("bp", bp);
  34.     phex("si", si);
  35.     phex("di", di);
  36.     printf("\n");
  37.  
  38.     phex("ds", ds);
  39.     phex("es", es);
  40.     phex("ss", ss);
  41.     phex("cs", cs);
  42.     phex("ip", ip);
  43.  
  44. /* Overflow    */    printf("%s ", (flags & (1 << 11)) ? "OV" : "NV");
  45. /* Direction    */    printf("%s ", (flags & (1 << 10)) ? "DN" : "UP");
  46. /* Interrupts    */    printf("%s ", (flags & (1 <<  9)) ? "EI" : "DI");
  47. /* Traps    */    printf("%s ", (flags & (1 <<  8)) ? "TF" : "NT");
  48. /* Sign        */    printf("%s ", (flags & (1 <<  7)) ? "MI" : "PL");
  49. /* Zero        */    printf("%s ", (flags & (1 <<  6)) ? " Z" : "NZ");
  50. /* Aux Carry    */    printf("%s ", (flags & (1 <<  4)) ? "AC" : "NA");
  51. /* Parity    */    printf("%s ", (flags & (1 <<  2)) ? "PE" : "PO");
  52. /* Carry    */    printf("%s", (flags & 1         ) ? " C" : "NC");
  53.  
  54.     printf("\n\n");
  55. }
  56.  
  57. phex(s, n)
  58. char *s;
  59. int n;
  60. {
  61.     printf("%s=", s);
  62.     printf("%x", (n & 0xf000) >> 12);
  63.     printf("%x", (n & 0x0f00) >> 8);
  64.     printf("%x", (n & 0x00f0) >> 4);
  65.     printf("%x", (n & 0x000f));
  66.     printf("  ");
  67. }
  68.