当前位置:网站首页>Chapter IV - first procedure
Chapter IV - first procedure
2022-06-12 08:52:00 【Pickup Ping】
Chapter four - The first program
4.1 The process of a source program from writing to execution
Write assembly source program
Using the text editor , Use assembly language to write assembly source program .
Compile and connect
- Compile programs in assembly language (MASM.EXE) Compile the source program in the source program file , Generate target file ;
- Reuse connection program (LINK.EXE) Connect to the target file , Generate executable files that can be run directly in the operating system .
Executable file
- Program ( Machine code translated from assembly instructions ) And data ( Defined data )
- Related description information ( such as : How much memory does it take , How big the program is )
Execute the program in the executable file
- Execute the program in the executable file in the operating system .
- The operating system follows the description in the executable file , Load the machine code and data in the executable file into memory , And initialize , Then from CPU Execution procedure .
4.2 Source program
Assembly instruction
from CPU distinguish , Corresponding machine code
Pseudo instruction
Understood by the compiler ,CPU Cannot read . Tell the compiler how to execute our code .
XXX segment( paragraph )
XXX endssegment and ends Is a pair of pseudo instructions , The function is to define a segment , The former represents the beginning , The following represents the end .
end Is the end of an assembler .
assume: If 、 hypothesis .
label
- A label represents an address
- codesg: Put it in segment In front of , As the name of a segment , The name of this segment is finally
DOS Program running in
- DOS Is a single task operating system .
- At the end of a program , take CPU The controller is returned , This is called : Return of program
- To add the returned program segment at the end of the program .
- The function of these two instructions is program return .
mov ax,4c00H
int 21H
## interrupt
End of paragraph 、 Program end 、 Program return

Grammatical and logical errors
- Grammar mistakes , Errors found by the compiler at compile time ;
- Logic error is something that a program cannot show at compile time 、 What happens at runtime .
About compiling and linking
- compile : Assembly language is translated into machine language
- Connect : Connect the target files together , Generate an executable file .
4.8 The principle that programs in executable files are loaded into memory and run
- stay DOS in , Programs in executable files P1 To run , There must be a running program P2, take P1 Load into memory from an executable , take CPU Give it control of ,P1 To run ; When P1 Operation completed , Should be CPU Control of the is returned to CPU So that it can continue to run the program P2
- We are DOS Run directly in 1.exe when , It's running command take 1.exe The program in is loaded into memory .
- command Set up CPU Of CS:IP The first instruction to the program ( It's the entry point of the program ), So that the program can run .
- At the end of the program , Back to command in ,CPU Continue operation command.

The shell of the operating system
- DOS There's a program in command.com, This program is in DOS Called command interpreter in , That is to say DOS Systematic shell
4.9 Tracking of program execution process

summary :EXE The loading process of the program in the file
- After the program is loaded ,ds The segment address of the memory area where the program is stored in , The offset address of this memory area is 0, The address of the memory area where the program is located is :ds:0;
- The front of this memory area 256 In bytes are PSP,dos Used to communicate with programs .
- from 256 The space behind the byte is for the program .
- so, We from ds You can get PSP Section address of SA,PSP The offset address of is 0, Then the physical address is :SA×16+0.
- because PSP Occupy 256(100H) byte , So the physical address of the program is :
SA×16+0+256=(SA+16)×16
The segment address and offset address can be expressed as :SA+10:0
command :
- use U Command view other instructions ;
- use T Command but not execute every instruction in the program , And observe the execution result of each instruction
- here we are int21, We need to use it. P Command execution
- Come back to debug,q go back to command
边栏推荐
- [new planning]
- UMI packaging and subcontracting, and compressing to gzip
- Shell基本语法--算数运算
- Background fixing effect
- [advanced pointer III] implement C language quick sorting function qsort & callback function
- What is the MES system? What is the operation process of MES system?
- Background position position NOUN
- (p21-p24) unified data initialization method: List initialization, initializing objects of non aggregate type with initialization list, initializer_ Use of Lisy template class
- Shell基本语法--数组
- API handling Android security distance
猜你喜欢

Use NVM to dynamically adjust the nodejs version to solve the problem that the project cannot be run and packaged because the node version is too high or too low

Engineers learn music theory (I) try to understand music

FDA审查人员称Moderna COVID疫苗对5岁以下儿童安全有效

Background position - exact units

处理异常数据

JVM learning notes: three local method interfaces and execution engines
![[advanced pointer III] implement C language quick sorting function qsort & callback function](/img/f0/3729db83ba3eb15c7df0958858ece9.png)
[advanced pointer III] implement C language quick sorting function qsort & callback function

svg中viewbox图解分析
![[dynamic memory management] malloc & calloc and realloc and written test questions and flexible array](/img/d2/a6276d8415c46124920395df5651d1.png)
[dynamic memory management] malloc & calloc and realloc and written test questions and flexible array

调整svg宽高
随机推荐
Background position - mixed units
FDA审查人员称Moderna COVID疫苗对5岁以下儿童安全有效
API handling Android security distance
Convert spaces to < br / > newline labels
What is the MES system? What is the operation process of MES system?
Popular understanding of time domain sampling and frequency domain continuation
[compilation principle] understand BNF
2022 safety officer-c certificate special operation certificate examination question bank and simulation examination
Gets the number of occurrences of a character in a string
Detailed explanation of private, public and interface attributes in cmake
判断对象是否为空
【sklearn学习】LightGBM
2022.6.11-----leetcode. nine hundred and twenty-six
Knee joint
(P14) use of the override keyword
【进阶指针一】字符数组&数组指针&指针数组
Make a simple page with the websql database of HTML5:
【字符集八】char8_t、char16_t、char32_t、wchar、char
Engineers learn music theory (III) interval mode and chord
通俗理解时域采样与频域延拓