Writing format of assembly language source program

Publisher:liliukanLatest update time:2018-05-20 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

Reference address:Writing format of assembly language source program

Previous article:The first analog I2C program learned by MSP430
Next article:MSP430 MCU analog IIC programming (1)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号