How to read the manual
You will need to read your previously acquired survival manual over and over again in your future PAs. Since some students think that "reading the manual" means "reading the whole manual" and therefore "it is impossible to finish it in a short time", we will talk about how to read the manual scientifically at the end of PA1.
Learn to use the table of contents
The fastest way to find out what's in a book is to look at the table of contents, especially if it's your first time reading a new book. Looking at the table of contents doesn't mean you know exactly what it says, but it does give you a first impression of what's in it, and when a concept is mentioned, you can get a rough idea of where it will appear in the manual. This is extremely important for reviewing the manual, because we always focus on one issue every time we review the manual, and if we have to go through the manual from the beginning every time, we can't do that. It would be very inefficient to read the manual from cover to cover to determine what the concern is. In fact, no one would ever do that, so the importance of reading the table of contents is obvious. It's not as easy as it sounds on paper, so let's do it!
Trying to locate concerns through the table of contents
Assuming that you now need to understand a concept called selector
, go through the table of contents of the i386 manual to determine where you need to read the manual. Even if your ISA of choice isn't x86, try checking out this concept as well.
Well, isn't that simple? You still don't know what a selector
is, but you know what you need to read. It's just a matter of time before you figure out what is selector
.
Progressive refining of the scope of the search
Sometimes the question you are concerned about may not be found directly in the table of contents, e.g., "What is the meaning of the PG bit in the CR0 register". This kind of detail is usually found in the body of the text, not directly in the table of contents, so you can't go through the table of contents to locate it. So you can't go through the table of contents directly to locate the appropriate content. Depending on whether you are new to CR0 or not, there are different ways to find out about this issue.
- If you already know that CR0 is a control register, you can look directly in the table of contents for the section where the "control register" is located, and then look in the body of those sections.
- If you do not know anything about CR0, you can use the search function in the reader, search for "CR0", you can still quickly find "CR0" related content. But the best way is to use the search engine first, so you know immediately that "CR0 is a control register", and then you can consult the manual as in the first method.
Sometimes, however, you may find that a concept is mentioned in more than one place in the manual. You need to be clear about which aspect of the concept you want to focus on, and usually a particular aspect of a concept will only be covered in detail in one place in the manual. You'll need to sift through the multiple places, but at least you've filtered out a lot of sections that aren't relevant to the concept. Filtering is also strategic, and you don't need to read everything in multiple places to filter. Subheadings, the first sentence of each paragraph, and notes on charts and graphs can help you get a quick sense of what the section is about. Isn't this the same kind of fast reading that was used on the high school English test? Yes, it is. If you think you're lacking in this area, here's your chance to practice.
Searching and sifting through information is a trial and error process, and there is no way to guide you to success on the first search, but there are lessons to be learned. When a search fails, you should try searching again with different keywords. How you vary the keywords depends on your understanding of the heart of the question, in other words, how to get to the heart of the matter. Isn't that what high school language class's emphasizes ability? Yes, it is.
In fact, all you need is some basic social skills to learn how to access information, regardless of the content of the information, like "Civil Law Book", "XX Cell Phone Manual", "YY Company Management Records". "Access to information" is a basic ability that is not related to the field, no matter what industry you are in, you need to have it, if you don't want to be stuck in the middle of a job in the future. If you don't want your future to be jeopardized by your ability to access information, start practicing now!
mandatory question
You will need to answer the following questions in your lab report.
A program is a state machine Draw the state machine of a program that computes
1+2+... +100
program, see [here](1.2.md#A computer is a state machine.).Understanding infrastructure Let's walk through some simple calculations to see what the simple debugger can do. Start with the following assumptions:
- Assume you need to compile NEMU 500 times to complete PA.
- Assume that 90% of those 500 compilations are for debugging.
- Assume that you have not implemented a simple debugger, and can only debug the client program running on NEMU through GDB.
- In each debugging session, since GDB cannot observe the client program directly, it takes you 30 seconds to retrieve and analyze a message from GDB.
- Suppose you need to fetch and analyze 20 messages to troubleshoot a bug.
So how much time will you spend on debugging over the course of the semester?
Since the simple debugger can directly observe the client program, let's say it only takes 10 seconds to get and analyze the same information from the simple debugger. So how much debugging time will the simple debugger save you over the course of the semester?
In fact, these figures may still be a bit optimistic. Even if you use GDB to debug a client program directly, for example, these numbers assume that you can troubleshoot a bug in 10 minutes. If you actually need to obtain and analyze more information during the debugging process, the benefits of the simple debugger infrastructure are even greater.
RTFM Having understood the scientific approach to the manual. Please try to find out where the following questions are located in the ISA manual of your choice, and write down the scope of what you need to read in your lab report.
- x86
- What does the CF bit in the EFLAGS register mean?
- What is the ModR/M byte?
- What is the exact format of the mov instruction?
- mips32
- What are the instruction formats for mips32?
- What is CP0 register?
- What happens if the divisor of a division instruction is 0?
- riscv32
- What are the instruction formats for riscv32?
- What is the behavior of LUI instructions?
- What is the structure of the mstatus register?
- x86
shell command After completing the contents of PA1, what is the total number of lines of code in all the .c and .h and files in the
nemu/
directory? What command did you use to get this result? How many lines of code did you write in PA1 compared to the framework code? (Hint: the currentpa0
branch records exactly what it was before PA1, think about how to get back to the "past"?) You can write this command into aMakefile
, and as you progress, you can easily count the number of lines of code in your project. For example, typingmake count
will automatically run a command that counts lines of code. On a more difficult subject, how many lines of code are in all the.c
and.h
files in thenemu/
directory, excluding blank lines?RTFM Open the
nemu/scripters/build.mk
file, and you'll see some of gcc's build options in theCFLAGS
variable. Please explain what is the purpose of-Wall
and-Werror
in gcc? Why-Wall
and-Werror
are used?
tips
This concludes PA1. Please prepare your lab report (don't forget to answer the mandatory questions in the lab report), Then place the lab report file named studentID.pdf
in the project directory Execute make submit
to submit the project to the specified site.