X01. OS. 14: Where is the time? x01. OS. 14: Time
Where has the time been?
"Why is the flowers so red" in the old PA caused six cheers in three minutes, but lost to Zhang bichen. Imagine, if Chen Bing is more popular, even if he sings exactly the same way as Zhang bichen, he may still be defeated. Why can he win? There was such a joke: no one was playing the piano, but an old woman was crying. It turns out that her husband is in Cotton! This is a joke, but it breaks the mystery. In addition to singing, there are also emotional factors. If the old Pa's "why is the flowers so red" is 1 point, then Zhang bichen's father and daughter sentiment is 1 point, "Where has the time been?" Is 1 point. 2: 1. Zhang bichen's victory is a matter of course.
Shell implementation
Running your own program echo in your OS is easier to implement than you think. This benefits from the support of the file system. For more information, seeX01. OS. 7. Source code, which can be downloaded from x01.Lab. DownloadX01. OS .13.tar.gz. After decompression, enter the terminal. After make, the bochs interface is displayed as follows:
It seems that the echo program is running well. First, let's look at the echo program. The Code is as follows:
1 #include "kstd.h" 2 3 int main(int argc, char* argv[]) { 4 int i; 5 for (i = 1; i < argc; i++) { 6 printf("%s%s", i == 1 ? "" : " ", argv[i]); 7 } 8 printf("\n"); 9 return 0;10 }
This is very simple, but the main function is not what we usually see. It needs to run in our own OS and help from start. s. The Code is as follows:
1 extern main 2 extern exit 3 4 bits 32 5 6 [section .text] 7 global _start 8 9 _start:10 push eax11 push ecx12 call main13 push eax14 call exit15 hlt
This _ start is the key, which is consistent with that in kernnel. s. So, how can we run it in our own OS? In the mm. c => MM_Exec () function, there is a sentence:
g_ProcTable[src].Regs.eip = elf_hdr->e_entry;
Echo entry point, which completes the handover. Simply put, it is to fork a Init sub-process, and then replace it with our own program in shell, such as echo.
Learn the operating system. If you have a memory layout in your mind, you will get twice the result with half the effort. A hex program was written to calculate the conversion from the 10th to the 16th. But to run it in your own OS, there is a lot of work to do.
A perfect OS is not a human power, not a temporary power. In addition to everyone's joint efforts, is there any other way?
Where is time? lyrics
[Ti: Where is the time?]
[Ar: Wang yuliang]
[Al: Old bull's war]
[By: anonymous]
[Offset: 500]
[. 92] Singing: Wang xiaoliang
[. 45] composing: Chen Xi
[. 89]: Dong Dongdong
[. 76] Old tree sprout in front of the door
[. 68] the dead wood in the courtyard blossomed again
[. 67] How much is half-lived?
[. 76] covered with white hair
[00:23. 55]
[. 14] [. 00] The little ankle in memory
[. 56] [. 13] doodle mouth
[. 66] [. 66] give love to him all his life
[. 51] [. 79]
[. 56] [. 14]
[. 26] [. 67] Where have you been?
[. 16] [. 30] I am old when I feel young.
[. 84] [. 15] A child raises a daughter for a lifetime
[. 49] [. 54] All the children were crying and laughing.
[. 47] [. 51]
[. 75] [. 94] Where have you been?
[. 49] [. 76] Your eyes have been spent.
[. 25] [. 79] rice, oil, and salt for half a lifetime
[. 75] [. 37] in a twinkling of an eye, only wrinkles on the face are left.
Where is the time? What is the lyrics?
Where has the time been?
Singing: Wang yuliang
Old tree sprout in front of the door
The dead trees blossom again in the courtyard
A lot of things
Covered with white hair
Incept in memory
Doodle mouth
Give love to him all his life
Just for that Mom and Dad
Where has the time been?
It's old before you feel young.
Children and Children
All the children were crying and laughing.
Where has the time been?
You just spent some time looking at your eyes.
Rice, oil, and salt
In a twinkling of an eye, there will be only wrinkles on your face.
Incept in memory
Doodle mouth
Give love to him all his life
Just for that Mom and Dad
Where has the time been?
It's old before you feel young.
Children and Children
All the children were crying and laughing.
Where has the time been?
You just spent some time looking at your eyes.
Rice, oil, and salt
In a twinkling of an eye, there will be only wrinkles on your face.