My favorites
▼
|
Sign in
grubutils
grubutils
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
date.c
r107
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
#include "grub4dos.h"
struct realmode_regs {
unsigned long edi; // as input and output
unsigned long esi; // as input and output
unsigned long ebp; // as input and output
unsigned long esp; // stack pointer, as input
unsigned long ebx; // as input and output
unsigned long edx; // as input and output
unsigned long ecx; // as input and output
unsigned long eax;// as input and output
unsigned long gs; // as input and output
unsigned long fs; // as input and output
unsigned long es; // as input and output
unsigned long ds; // as input and output
unsigned long ss; // stack segment, as input
unsigned long eip; // instruction pointer, as input,
unsigned long cs; // code segment, as input
unsigned long eflags; // as input and output
};
static unsigned long BCD2DEC(const char *bcd,int len);
int GRUB = 0x42555247;/* this is needed, see the following comment. */
/* gcc treat the following as data only if a global initialization like the
* above line occurs.
*/
asm(".long 0x534F4434");
asm(ASM_BUILD_DATE);
/* a valid executable file for grub4dos must end with these 8 bytes */
asm(".long 0x03051805");
asm(".long 0xBCBAA7BA");
/* thank goodness gcc will place the above 8 bytes at the end of the b.out
* file. Do not insert any other asm lines here.
*/
static int main (char *arg,int flags)
{
struct realmode_regs int_regs = {0,0,0,-1,0,0,0,0x400,-1,-1,-1,-1,-1,0xFFFF1ACD,-1,-1};
if (!*arg)
{
realmode_run((long)&int_regs);
return printf("%04X-%02X-%02X\n",int_regs.ecx,(char)(int_regs.edx>>8),(char)int_regs.edx);
}
char tmp[8];
int_regs.ecx = BCD2DEC(arg,4);
int_regs.edx = (BCD2DEC(arg+5,2)<<8)+BCD2DEC(arg+8,2);
int_regs.eax = 0x500;
return realmode_run((long)&int_regs);;
}
static unsigned long BCD2DEC(const char *bcd,int len)
{
unsigned long dec = 0;
while (len--)
{
dec <<= 4;
dec += (*bcd++ - '0');
}
return dec;
}
Show details
Hide details
Change log
r88
by chenall.cn on Oct 8, 2011
Diff
sources update
Go to:
/trunk/src/chkpci.c
/trunk/src/date.c
/trunk/src/diskid.c
/trunk/src/include/grub4dos.h
/trunk/src/inifile.c
/trunk/src/vfont.c
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1875 bytes, 60 lines
View raw file
Powered by
Google Project Hosting