-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathb.c
More file actions
92 lines (84 loc) · 1.23 KB
/
Copy pathb.c
File metadata and controls
92 lines (84 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
__asm__(".code16gcc\n");
typedef unsigned char u8;
typedef unsigned int u32;
int i;
char* itoa(int n, char* str);
void print(const char *s)
{
while(*s)
{
__asm__ __volatile__ ("int $0x10" : : "a"(0x0E00 | *s), "b"(7));
s++;
}
}
int p()
{
int c=i+1;
char arr[6]="a";
char *s = arr;
//const char *str="test";
//volatile u8 *video_addr = (u8*)0xB8000;
//asm("movw $0xb000 %gs");
//*video_addr = 'a';
s = itoa(c, s);
print(s);
return c;
}
#if 1
char* itoa(int n, char* str)
{
char digit[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char* p=str;
char* head=str;
int radix = 10;
// if(!p || radix < 2 || radix > 36)
// return p;
if (n==0)
{
*p++='0';
*p=0;
return str;
}
#if 1
if (radix == 10 && n < 0)
{
*p++='-';
n= -n;
}
#endif
while(n)
{
*p++=digit[n%radix];
n/=radix;
}
*p=0;
#if 1
for (--p; head < p ; ++head, --p)
{
char temp=*head;
*head=*p;
*p=temp;
}
#endif
return str;
}
#endif
#if 0
extern u32 __bss_start__;
extern u32 __bss_end__;
void init_bss()
{
u8 *bss=(u8*)__bss_start__;
*bss = 0x1;
*(bss+1) = 0x1;
*(bss+2) = 0x1;
*(bss+3) = 0x1;
#if 0
while (i!=(u8*)__bss_end__)
{
*i = 0x1;
++i;
}
#endif
}
#endif