当前位置:网站首页>Assembly language - Wang Shuang Chapter 9 Principles of transfer instructions - Notes
Assembly language - Wang Shuang Chapter 9 Principles of transfer instructions - Notes
2022-06-27 06:09:00 【Holding hands to listen to falling flowers】

assume cs:codesg
codesg segment
start: mov ax, 2000H
mov ds, ax
mov bx, 0
s: mov cl, [bx]
mov ch, 0
inc cx
inc bx
loop s
ok: dec bx
mov dx, bx
mov ax, 4c00h
int 21h
codesg ends

From the code point of view , It should be analyzed in this way , First of all, the entry of the program is start Where to point , That is to say mov ax,0 here , Instead of the first two statements to exit the program .
Then two nop, Each account 1 Bytes .
then mov di,offset s This sentence is to di Register transfer s The offset address of ;
then mov si,offset s2, This is the Wang register si Pass on s2 The offset address of
then mov ax,cs:[si], therefore ax Save the execution s2 Pointer address of .
mov cs:[di] ,ax And then put s2 The execution address of is given to cs:[di] This memory location .
Here's the main point s2:jmp short s1, From the perspective of effect , The next step is to execute s1 The code for segment . And machine instructions EBF6, Will be copied to cs:[di] Memory here . and EBF6 The effect is actually to jump back 10 Bytes ( s1 here mov ax,0 Occupy 3 Bytes ,int 21h Occupy 2 Bytes , mov ax,0 Occupy 3 Bytes , This is the 8 Bytes . and s2 Of jmp short s1 It's up to you 2 Bytes . This sentence is finished , Go back 10 Bytes , just s1 The location of )
So when EBF6 Copy to cs:[di] after , amount to cs:[di] Actually saved s The execution address of , So it's to put EBF6 This machine instruction is copied to s Of nop nop here . and EBF6 The actual meaning of "jump back" is to jump back 10 Bytes , Not literally jmp short s1 It means , That is, it will not jump down to execute s1, But jump back 10 Bytes
Calculate it like this EBF6 In itself 2 Bytes ,mov ax, 4c00h 3 Bytes , int 21h 2 Bytes , mov ax, 0 3 Bytes , All together 10 Bytes . So the execution is over s Section of the code , The pointer is there mov ax,4c00h here . So the program exits normally .
————————————————
Copyright notice : This paper is about CSDN Blogger 「 Yang, a conscious digital citizen 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/m0_47161778/article/details/125285200


assume cs:codesg ds:datasg
datasg segment
db 'Welcome to masm!'
db 2H, 24H, 71H ; String attribute value
datasg ends
stack segment
dw 8 dup (0)
stack ends
codesg segment
start: mov ax, stack
mov ss, ax
mov sp, 10h
mov ax, datasg
mov ds, ax
mov bx, 0
mov ax, 0B800H
mov es, ax ;80×25 The color character mode shows the buffer section address input es
mov di, 10H ; This offset is used for both string and color
mov cx 3
s0: push cx
mov ah, ds:[di]
push di
mov di, 0
mov si, 0
mov cx, 16
s: mov al, ds:[di]
mov es:[bx+si], al
mov es:[bx+si+1], ah
add si, 2
inc di
loop s
pop di
inc di
pop cx
add bxm 0a0h ; Line break , Each row 80 character ,160 Bytes
loop s0
all: jmp short all ; Cycle all the time , In order to see the effect
mov ax, 4c00h
int 21h
codesg ends
end start
边栏推荐
猜你喜欢

Proxy-Reflect使用详解

Active learning

Crawler learning 5--- anti crawling identification picture verification code (ddddocr and pyteseract measured effect)

C Primer Plus 第11章_字符串和字符串函数_代码和练习题

js实现双向数据绑定

30 SCM common problems and solutions!

Assembly language - Wang Shuang Chapter 13 int instruction - Notes

cpu-z中如何查看内存的频率和内存插槽的个数?

Multithreading basic Part3

【QT小作】使用结构体数据生成读写配置文件代码
随机推荐
下载cuda和cudnn
30 SCM common problems and solutions!
TiDB的事务概览
写一个 goroutine 实例, 同时练习一下 chan
IAR Systems全面支持芯驰科技9系列芯片
Database - index
Distribution gaussienne, régression linéaire, régression logistique
IDEA中关于Postfix Completion代码模板的一些设置
高斯分布Gaussian distribution、线性回归、逻辑回归logistics regression
TiDB 中的视图功能
426 binary tree (513. find the value in the lower left corner of the tree, 112. sum of paths, 106. construct a binary tree from the middle order and post order traversal sequence, 654. maximum binary
openstack实例重启状态就会变成错误处理方法,容器搭建的openstack重启计算节点compute服务方法,开机提示Give root password for maintenance处理方法
NoViableAltException([email protected][2389:1: columnNameTypeOrConstraint : ( ( tableConstraint ) | ( columnNameT
tar: /usr/local:归档中找不到tar: 由于前次错误,将以上次的错误状态退出
高斯分布Gaussian distribution、線性回歸、邏輯回歸logistics regression
WebRTC系列-網絡傳輸之7-ICE補充之提名(nomination)與ICE_Model
[collection] Introduction to basic knowledge of point cloud and functions of point cloud catalyst software
多线程基础部分Part2
Keep 2 decimal places after multiplying SQLSEVER fields
表单校验 v-model 绑定的变量,校验失效的解决方案