当前位置:网站首页>汇编语言段定义
汇编语言段定义
2022-07-06 09:29:00 【My71】
段定义三步走
段定义
关键字:segment(开始) ends(结束)
段名:不得超过八个字符。一般情况下,
- code 表示代码段。
- data 表示数据段
语法
段名 segment 段名 ends
段关联
关键字:assume
类型:CS(代码段)、DS(数据段)、SS(堆栈段)、ES(附加段)
语法:
assume 类型:段名例:定义一个代码段 code,定义一个数据段 data
code segment assume cs:code,ds:data code ends data segment data ends
段传送
传送是将段中的数据传到指定的段寄存器中。例如,讲 data 中的数据传到 DS 数据段中,在关联的时候并没有真正的传递数据。
代码段在定义时不需要段传送,其他段都需要手动传送。
通过 mov 不能将段直接传递给段寄存器,可以间接行传送。
…… mov ax,data mov ds,ax ……这段代码表示,现将 data 数据段存到 ax 中,再将 ax 中的数据存到 ds 中。
数据段
开辟空间的伪指令
- db:开辟一个字节空间。
- dw:开辟一个字空间。(两个字节)
- dup:循环存字符
存储数据
- 存储 10 进制数据时,直接写入。
- 存储字符数据时用单引号扩起来,最终在 debug 模式下现实的是该字符 ASCII 码16进制表现形式。
语法格式
无地址符号


有地址符号


代码演示
使用 db 定义 5 个奇数,将第一个数存到 AH 中,最后一个数存到 AL 中。


最终,AX=0109,恰好是 AH 与 AL 的拼接。
使用 dw 定义 5 个奇数,存入 AX 中。


利用 dup 开辟三个单字节空间
data segment str db 3 dup(5) data ends code segment assume cs:code,ds:data main: mov ax,data mov ds,ax edit: mov ah,4ch int 21h code ends end main
边栏推荐
- 我走過最迷的路,是字節跳動程序員的腦回路
- Sublime text code formatting operation
- Shell_ 06_ Judgment and circulation
- Simply try the new amp model of deepfacelab (deepfake)
- Mp4 format details
- Ffmpeg command line use
- Redis standalone startup
- LeetCode 1641. Count the number of Lexicographic vowel strings
- Record the error reason
- Use JQ to realize the reverse selection of all and no selection at all - Feng Hao's blog
猜你喜欢

字节跳动技术面试官现身说法:我最想pick什么样的候选人

Error occurred during initialization of VM Could not reserve enough space for object heap
![Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]](/img/e6/c53ad67ead1793a2acb93c26e8d377.jpg)
Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]

我在字节跳动「修电影」

When it comes to Google i/o, this is how ByteDance is applied to flutter

~83 form introduction

Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here

~82 style of table

姚班智班齐上阵,竞赛高手聚一堂,这是什么神仙编程大赛?

Yao BanZhi and his team came together, and the competition experts gathered together. What fairy programming competition is this?
随机推荐
LeetCode 1560. The sector with the most passes on the circular track
DS18B20數字溫度計系統設計
Sublime text code formatting operation
LeetCode 1637. The widest vertical area between two points without any point
@RequestMapping、@GetMapping
~85 transition
Spark independent cluster dynamic online and offline worker node
7-12 inventory code base
LeetCode 1545. Find the k-th bit in the nth binary string
CMake速成
字节跳动春招攻略:学长学姐笔经面经,还有出题人「锦囊」
[unsolved] 7-15 shout mountain
字节跳动新程序员成长秘诀:那些闪闪发光的宝藏mentor们
7-8 likes (need to continue to improve)
LeetCode 1566. Repeat the pattern with length m at least k times
Soft music -js find the number of times that character appears in the string - Feng Hao's blog
Yao BanZhi and his team came together, and the competition experts gathered together. What fairy programming competition is this?
Tencent interview algorithm question
One hundred questions of image processing (11-20)
~77 linear gradient








