called memory access, so that data does not go through the register directly to main memory. is an illustration of this process.third, according to the code in main memory instruction execution programAfter the code and the data required by the program are loaded into main memory, the CPU begins to execute the instructions in the code, starting at the start of the function. Since our code simply outputs a string such as "Hello World", the system simply loads the string into the register and the
example, for 4 (%esp,%eax,4) This operand, it represents the memory address is 4+%esp+4*%eax the value of the memory area.The operands are the majority of the instructions, so the above-mentioned methods, in the following articles we will often see, they will be a good friend of the ape friends.Article SummaryThis chapter only introduces some of the basics of the compilation, which is relatively not particularly difficult, but is the key to opening the door behind the mystery. So if any of the
In-depth understanding of types and computer systems
In C #, there are two types: Value Type and reference type.
1. Value Type and reference type
An in-depth understanding of these two types is very important. The interviewer will test the interviewer's understanding of these two types of knowledge to determine whether the foundation is solid and whether there is any in-depth thinking.
1.1 What is the value
The purpose of the experiment is to fill in the functions of the BITS.C in accordance with the required requirements (such as only limited and specified operators and data types, not the use of control statements, etc.) to implement functions.At the same time, the DLC file is used to detect whether the functions inside the BITS.C are written as required, and there are no illegal data types. How to use:./DLC bits.cOnce the detection is successful, use Btest to test the functionality of each funct
, operand 2 is destination addressThe type of operand immediately//is a constant value register//data (get/Save) to register memory//IS memory,data (get/Save) to registerOperand formatData Transfer InstructionsThe MOV instruction source operand can be an immediate number, register, memory destination operand can be register, memory addressLimitTwo operands cannot all point to the memory locationStackThe address of the stack is to increase the attention!!!! Here, the bottom picture is on top.Exec
pop instruction executes, the current frame is restored to the caller's frame, as shown below.At this point the current frame has been restored to the caller's frame, the last RET instruction changes the value of the program counter (PC), and then jumps out of the child function, continuing to execute the caller's code. Here, our data replication example is over, although this example is not difficult, but the small perfectly formed, if the understanding of the process, I believe that even more
shared by all processes. The properties of the file are mostly saved.For the above program, there are two open file tables, each file table holds the location of open files, they are independent of each other, so in the last read, read a.Of course we don't use these system-level functions most of the time when we write programs, and we've already developed a set of standard IO functions for us to use, such as Printf,fopen,fread.The communication and interaction between our program and other pro
Doubts:***." The ASCII code of the decimal digit x is exactly 0x3x "(P31)". According to the above, the ASCII code of decimal 1 is 0131, it is obviously wrong to find an ASCII code to see" 1 "ASCII code is" 49 ",Again carefully refer to the context of the book, found that the ASCII code of the decimal 1 is a , the original sentence so that "decimal digit _x ASCII code is just 0x3_x" is not a better understanding point, Avoid the "X" Understanding Error, you may say, now or not Ah, now 1 of ASCI
When I first saw the first version of this book, it seemed like it was in, and I was shocked when I remembered it. I was able to reach this level as a teaching material for my undergraduate sophomore year, and I also got in touch with a lot of content for the first time, I was very ashamed. Later, I spent some time studying it carefully. Unfortunately, there were no specific experiments on many important points. At that time, I felt that this book was very close to practice, but unfortunately, s
I recently read a book by Zuo Feige :《CodeSecrets-exploring computer systems from the perspective of C/C ++. I think it is well written. Below is a short article in the book.Program, Modified by me.
# Include
The running result of the program is shown.
The compile steps are as follows:1. My current working directory is/home/sxh2/clinux, the directory has 3 files inet_aton.c csapp.h csapp.c.2. Compile the csapp.c file, the command is Gcc-c csapp.c, generate the target file CSAPP.O.3. Compile the inet_aton.c file, the command is Gcc-c INET_ATON.C, generate the target file INET_ATON.O.4. Link the target file csapp.o, INET_ATON.O (due to the csapp.c file in the part of the thread, GCC compile must take-lpthread, otherwise error), command for Gcc-o
following:①, due to the addition of parameter n, the address of the argument on the stack moved②, the multiplication instruction is used to calculate the N*i (line 4th), instead of the Leal instruction to calculate 3i.So referencing a variable-length array requires only a little change to the fixed-length array, and the dynamic version must use the multiplication instruction to extend n times the I, rather than a series of shifts and additions. In some processors, the multiplication instruction
Synchronize Threads with semaphores:Synchronization error:In general you have no way to predict whether the operating system will execute your thread in the correct order.12.5.1 Progress Chart(1) Progress graph: The execution of n concurrent threads is modeled as a trace line in an n-dimensional Cartesian space.(2) Each axis k corresponds to the progress of thread K.(3) Each point IK represents a state where the K thread has completed instruction IK, which represents the initial state at the ori
program can be clearly seen! And the difference between the operation, we have to see the results directly.The result is obvious, the left side is!x and!! The result of X is only 0 and 1, and the right side is the result of ~x and ~~x. It is obvious that the difference between the logical non-bitwise and the non-operation. The former is only 0 and 1, while the latter is the inverse of each bit binary value.Apart from the differences in results, there is one difference between them, that is, if
The compile steps are as follows:1. My current working directory is/home/sxh2/clinux, the directory has 3 files inet_aton.c csapp.h csapp.c.2. Compile the csapp.c file, the command is Gcc-c csapp.c, generate the target file CSAPP.O.3. Compile the inet_aton.c file, the command is Gcc-c INET_ATON.C, generate the target file INET_ATON.O.4. Link the target file csapp.o, INET_ATON.O (due to the csapp.c file in the part of the thread, GCC compile must take-lpthread, otherwise error), command for Gcc-o
1. Preface
The processor is a complex system. It is not a one-stop process. It is a product that has been continuously upgraded, updated, and designed, and is still being updated.
The processor can only run a series of commands, each of which is just a simple operation, such as adding numbers. Commands must also be encoded. These codes are composed of binary digits of 0 and 1 of a certain rule. These codes are collectively referred to as the instruction set of the processor.
To be continued
Processor Architecture
ISA
One processor supportsCommandAndByte encoding of commandsCalled itsInstruction Set architecture ISA.
Although the performance and complexity of the processors manufactured by each vendor are constantly improved, different models are compatible at the ISA level. Therefore, ISA providesConcept Abstraction Layer.
This concept abstraction layer is the ISA model: the instruction set encoding allowed by the CPU, and commands are executed in sequence, that is, an instruction
to "ESc", the corresponding input file suffix is "ISO", so memory is much easier.Gdb:Note Use GCC to compile with the "-G" parameter.
GdB Programm (Start gdb)
B Set Breakpoints (4 breakpoints are set: Line breakpoint, function breakpoint, conditional breakpoint, temporary breakpoint)
Run starts running the program
BT Print function Call stack
P View variable values
C continue running from the current breakpoint to the next breakpoint
N Single Step operation
library, which can be used as a linker input
Advantages:
The associated function can be compiled into a separate target module and then encapsulated into a separate static library file
The linker copies only the target modules referenced by the referenced program, which reduces the size of the executable file in disk and memory
7. Loading the executable file
The loader copies the code and data from the disk to the storage in the executable target file, a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.