Assembly language has strict format requirements for source programs. Only when the format is correct can the assembler accurately translate the source program and form equivalent machine instructions. The assembly language program format is the grammatical rules that the assembly language must follow.
Assembly language has two writing forms: simplified segment definition format and complete segment definition format.......
1. The assembly source program in the simplified segment definition format is as follows:
;filename.asm
.model small ;Define the storage mode of the program (generally small is used)
.stack ;Define the stack segment.data
;Define the data segment
....... ;Define the data.code
;Define the code
segment.startup ;Program starting point, and establish DS, SS content
........... ;Program code.exit
0 ;Program end point, return to DOS
........... ;Subroutine code
end ;Assembly ends
Because MASM5.0/5.1 does not support .startup and .exit 0, you need to modify .startup and .exit 0 to the following form, and modify end
.startup————〉 start: mov ax,@data
mov ds,ax
.exit 0————〉 mov ax,4c00h ; return to DOS
int 21h
end ————〉 end start ; assembly ends, the program starting point is label start
2. The assembly source program in the complete segment definition format is as follows:
;filename.asm
stack segment ; define stack segment stack
............ ; allocate the size of the stack segment
stack ends ; the end of the stack segment
data segment ; define the data segment data
............ ; define data
data ends ; the end of the data segment
code segment 'code' ; define the code segment
asuume cs:code,ds:data,ss:stack ; determine the logical segment pointed to by CS/DS/SS
start: mov ax,data ; set the segment address DS of the data segment
mov ds,ax
.............. ; program code
mov ax,4c00h ; return to DOS
int 21h
code ends ; the code segment ends
............ ; subroutine code
end start ; assembly ends, the program starting point is start
Previous article:The first analog I2C program learned by MSP430
Next article:MSP430 MCU analog IIC programming (1)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- LORA SX1308
- Newbie question: When using the PCB antenna library, one of the antenna pins is not connected. I want to know how to solve it.
- Why is this power circuit connected like this?
- 【National Technology N32G430】03 Development foundation, the platform is emerging
- Four major Bluetooth antenna design methods
- Please recommend a microcontroller with 5V IO port output
- PowerBox
- I2C bus controls RDA5807M to achieve high-fidelity reception of FM signals
- I would like to ask you how to use timequest to analyze the delay time of the delay chain in FPGA.
- [Qinheng Trial] Experience of CH549 capacitive touch function