Simple Operating System
sec.c
Go to the documentation of this file.
1 
7 #include <types.h>
8 
9 int stoi(const char* str) {
10  char pows[] = {1, 10, 100};
11  size_t num = 0;
12  size_t size = 0;
13  for(; str[size] != 0; size++) {}
14  size--;
15 
16  for(size_t i = 0; str[i] != 0; i++)
17  num += pows[size - i] * (str[i] - '0');
18  return num;
19 }
20 
21 __start int main() {
22  char* param1 = NULL;
23  char* param2 = NULL;
24  for(int i = 0; * (char*)(0x80 + i) != 0; i++) {
25  if(*(char*)(0x80 + i) == ' ') {
26  *(char*)(0x80 + i) = 0;
27  param1 = 0x80;
28  if(*(char*)(0x81 + i) != 0)
29  param2 = 0x81 + i;
30  break;
31  }
32  }
33  if(param2 == NULL)//if provided less than 2 parameters
34  return -1;
35 
36  int track = stoi(param1);
37  int sector = stoi(param2);
38 
39  char disk[512];
40  asm("int 0x13\n"::"a"(0x0201), "b"(disk), "c"(track<<8 | sector), "d"(0));
41  for(int i = 0; i < 512; i++)
42  asm("int 0x20"::"a"(disk[i]));//putc
43 
44  asm("int 0x20"::"a"('\n'));//newline
45 
46  return 0;
47 }
__start void main()
Definition: kernel.c:131
int stoi(const char *str)
Convert string to int.
Definition: string.h:80
useful macros, definitions, enums etc.
#define NULL
pointer to NULL
Definition: types.h:22
#define __start
Must be before main function of program to put this function as first in binary file.
Definition: types.h:35