当前位置:网站首页>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
边栏推荐
猜你喜欢

427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)

汇编语言-王爽 第11章 标志寄存器-笔记

高斯分布Gaussian distribution、线性回归、逻辑回归logistics regression

openstack实例重启状态就会变成错误处理方法,容器搭建的openstack重启计算节点compute服务方法,开机提示Give root password for maintenance处理方法

426-二叉树(513.找树左下角的值、112. 路径总和、106.从中序与后序遍历序列构造二叉树、654. 最大二叉树)

Formation and release of function stack frame

机 器 学 习

Gaussian distribution, linear regression, logistic regression

JVM整体结构解析

Distribution gaussienne, régression linéaire, régression logistique
随机推荐
Openresty usage document
IAR Systems全面支持芯驰科技9系列芯片
IDEA一键生成Log日志
下载cuda和cudnn
Assembly language - Wang Shuang Chapter 3 notes and experiments
TiDB的使用限制
TiDB 中的视图功能
426-二叉树(513.找树左下角的值、112. 路径总和、106.从中序与后序遍历序列构造二叉树、654. 最大二叉树)
tracepoint
tar: /usr/local:归档中找不到tar: 由于前次错误,将以上次的错误状态退出
思维的技术:如何破解工作生活中的两难冲突?
The form verifies the variables bound to the V-model, and the solution to invalid verification
Jump details of item -h5 list, and realize the function of not refreshing when backing up, and refreshing when modifying data (record scroll bar)
[QT dot] QT download link
JVM overall structure analysis
693. alternate bit binary number
Thinking technology: how to solve the dilemma in work and life?
我对于测试团队建设的意见
Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
表单校验 v-model 绑定的变量,校验失效的解决方案