Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. //#define TRUE 1
  2. //#define FALSE 0
  3. #include "libs/stdbool.h"
  4. #include "libs/string.h"
  5. #include "libs/stdlib.h"
  6.  
  7. typedef unsigned int UINT; // Defining UINT
  8.  
  9. void shutdown();
  10. void putchar(char c);
  11. void puts(const char *s);
  12. char* gets(int maxChar);
  13. char getchar();
  14.  
  15. //void loop_1();
  16.  
  17. //Defining variables
  18. //char a;
  19. char* hello = "Hello!\r\n";
  20. char* input = "";
  21.  
  22. void main(void) {
  23. puts("X-DOS Ver 1.0\r\n\r\n");
  24. while(1==1) {
  25. puts("> ");
  26. input = gets(200);/*
  27. if (strncmp(input, "print\n\r", 7) == 0) {
  28. puts (input += 3);
  29. puts ("\r\n");
  30. }*/
  31. if (input == "sysinfo") {
  32. puts("OS: X-DOS\r\nOS Ver: 1.0\n\r");
  33.  
  34. }puts(input);
  35. }
  36. }
  37. /*
  38. void loop_1() {
  39. ans = getchar();
  40. putchar(ans);
  41. puts("\r\n");
  42. if (ans == 'y'){
  43. puts("idk lol");
  44. getchar();
  45. shutdown();
  46. } else if (ans == 'n') {
  47. puts("idk lelelelel");
  48. getchar();
  49. shutdown();
  50. } else {
  51. puts("That is not an available option.\r\n");
  52. loop_1();
  53. }
  54. }
  55. */
  56. void shutdown() {
  57. __asm {
  58. mov ax, 0x1000
  59. mov ax, ss
  60. mov sp, 0xf000
  61. mov ax, 0x5307
  62. mov bx, 0x0001
  63. mov cx, 0x0003
  64. int 0x15
  65. }
  66. }
  67.  
  68. char getchar() {
  69. char a;
  70. __asm {
  71. xor ah, ah
  72. int 16h
  73. mov [a], AL
  74. }
  75. return a;
  76. }
  77.  
  78. char* gets(int maxChar) {
  79. char a;
  80. char* b = (char *)malloc(maxChar);
  81. int i;
  82. for(i = 0; i<maxChar; i = i + 1){
  83. a = getchar();
  84. if (a !=13) {putchar(a);} else {puts("\r\n");break;}
  85. b[i] = a;
  86. }
  87. return b;
  88. //if (b[sizeof(b)-1] != '')
  89. }
  90.  
  91. void putchar(char c) {
  92. __asm {
  93. mov ah, 0Eh
  94. mov al, [c]
  95. mov bh, 0
  96. mov bl, 0Fh
  97. int 10h
  98. }
  99. }
  100.  
  101. void puts(const char* s) {
  102. while(*s != 0) {
  103. putchar(*s);
  104. s++;
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement