This chapter is a practical part, wrote a assembler program, and debug to track each instruction process, see Register and memory changes, is a small summary of the previous
4.1 Process of source program to execution
A assembler to write, to compile into the target file, the file suffix is obj, and then link to form an EXE suffix, and then go to execute
4.2 Source Program
Directly put
Pseudo-directives are executed by the compiler, and assembly instructions are executed by the CPU
Assume is a pseudo-directive, associated segment registers and programs that are associated with the segment represented by the segment and end
Segment and ends represent the beginning and end of a segment
End means the entire program ends
In addition, the program will have something called a program to return.
If the P2 to run, must have a P1 in the run, P1 to throw P2 into memory, the CPU control to P2,P2 run out, the CPU control back to P1. This is called the program to return
Last 2 instructions
MOV ax,4c00h
int 21h
is the implementation of the program returned. I don't know exactly why, I'm dead, remember.
4.3 Write source program
1.asm
4.4 Compiling
1.asm->1.obj
4.5 Links
1.obj->1.exe
4.6 Simplifying compilation and linking to the same step
The previous compilations and links are written separately using Microsoft's masm5.0 and linker3.6
But mine's a 64-bit machine, running.
I used DOSBox.
Drop link
http://download.csdn.net/download/wy4649/5536047
There are tutorials inside
Point of operation, you can directly complete the process of compiling and linking, generating 1.exe files
4.7 Running Traces
Use Debug to step through 1.exe execution
Let's put a final program running.
In addition, the last statement executes with P to execute, not T. Specifically not very clear, p probably represents the end of a program, to prevent debug and then tracking the following and program-independent instructions
This chapter must oneself knock Knock knock, knock N long to understand ~~~~~~
And it took a lot of time to toss DOSBox.
That's the first thing. Good night, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
Eof
Assembly language (Wang Shuang) The first procedure of the 4th chapter