当前位置:网站首页>[assembly language practice] (II). Write a program to calculate the value of expression w=v- (x+y+z-51) (including code and process screenshots)
[assembly language practice] (II). Write a program to calculate the value of expression w=v- (x+y+z-51) (including code and process screenshots)
2022-07-24 09:04:00 【Strange &】
Catalog :
Preface
How do you do , I am a “ blame & ”, I'm a college student .
Home link : blame & My personal blog home page
️ The main direction of the blog is : Course learning knowledge 、 Homework problem solving 、 Final exam preparation . With the deepening of specialty, it will become more and more extensive … Look forward to .
️ One “ I don't want what I didn't do well to be your regret ” Bloggers .
Nice to meet you , Come on together !
If you are not familiar with assembly instructions, you can see my article :【 Assembly language practice 】( One )、 The code knocked out in the first experiment and the explanation of common instructions ( Assembly language 4 edition , Wang Shuang , Super detailed notes )
One 、 subject
- Experimental content : Write a program to calculate the expression w=v-(x+y+z-51) Value .
- The experimental requirements :
1、 Variable x,y,z,v, The value of is a number in memory ;
2、 Will use debug In debugging , Modify variables x,y,z,v Value ;
3、 The result of the calculation is saved in the variable w in , The initial value is 0.
Two 、 Code
notes : Assembly language programming is not case sensitive
DATAS SEGMENT
x DW 5 ; Set variables and assign initial values
y DW 5
z DW 5
v DW 5
W DW 0
DATAS ENDS
STACKS SEGMENT
; Enter the stack segment code here
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV CX,0 ;CX=0
MOV AX,X ;AX=X
ADD AX,Y ;AX=X+Y
ADD AX,Z ;AX=X+Y+Z
SUB AX,51 ;AX=X+Y+Z-51
MOV BX,V ;BX=V
SUB BX,AX ;BX=V-(X+Y+Z-51)
MOV CX,BX ;CX=V-(X+Y+Z-51)
MOV W,CX ;W=V-(X+Y+Z-51)
MOV AH,4CH
INT 21H
CODES ENDS
END START
3、 ... and 、 Operation flow chart
1、 Don't change xyzv Operation of initial value



Analysis of operation results :
- w=v-(x+y+z-51) take x=y=z=v=5 Brought in ,w=41
- Because will w Value deposit CX,CX In the end, it's equal to 0029, Hexadecimal 0029 Convert to decimal 2*16+9=41
- So the calculation is correct
2、 modify xyzv Operation of initial value
notes : It's execution ( The following codes work : That is, initialize variables )
MOV AX,DATAS
MOV DS,AX
Then execute ( The following codes work : Change the value of the variable )
-e 143f:0 0 0 0 0


Analysis of experimental results :
- take x=y=z=v=0, w=v-(x+y+z-51) Brought in ,w=51
- Running results w=CX=0033, Hexadecimal 0033 Convert to decimal to :3*16+3=51
- So the calculation is correct
Four 、 The understanding of variables
Take the operation without changing the initial value as an example :
There is still one graph after the four graphs given above :
Data register DS=143F
Variables set in the code :X,Y,Z,V,W Stored in... In turn 143F:00 In memory at the beginning
Storage compliance “ Gaogao village, Gaogao village , Low save low ”
DW: word ,DB: byte ; A word is two bytes ,143D:0000 For a byte
for example :
143F:0000 Deposited 05,143F:0001 Deposited 00, When combined, what is saved is 0005 That is, the first variable X The initial value of the 5
143F:0002 Deposited 05,143F:0003 Deposited 00, When combined, what is saved is 0005 That is, the first variable Y The initial value of the 5
By analogy
So we can use the following code , Separate to change X,Y,Z,V Value
-e 143f:0 0 0 0 0
️️️ Don't forget the romantic duck when you are busy Typing Code !

边栏推荐
- [Shangshui Shuo series] final rad New Literacies
- 链表——24. 两两交换链表中的节点
- [emotion] what is "excellent"
- 科目1-3
- Super complete summary: how to operate files in go language
- Promise基础总结
- OpenCV中文文档4.0.0学习笔记(更新中……)
- Ansible 常用模块介绍
- From single architecture to distributed architecture, there are many pits and bugs!
- How to configure env.js in multiple environments in uni app
猜你喜欢

Porting boa server on imx6ull

VGA character display based on FPGA

0 threshold takes you to know two-point search

Why is TCP a triple handshake

& 和 &&、| 和 || 的区别

Taking advantage of the momentum, oceanbase promotes the lean growth of digital payment

Some mistakes that Xiaobai often makes (update from time to time, and promise not to make them again next time)

Detailed sequence traversal of leetcode102 binary tree

FreeRTOS - use of software timer

Android系统安全 — 5.3-APK V2签名介绍
随机推荐
[Shangshui Shuo series together] June summary +no anxiety +july plan + how to test + how to improve
How to judge and analyze NFT market briefly through NFT go?
排序入门—插入排序和希尔排序
Houdini 官方HDA SideFX Labs 安装
Relationship between fork and pipeline
Typora prompt [this beta version of typora is expired, please download and install a new version]
剑指 Offer II 024. 反转链表
Leetcode102-二叉树的层序遍历详解
Promise basic summary
【汇编语言实战】一元二次方程ax2+bx+c=0求解(含源码与过程截屏,可修改参数)
链表——24. 两两交换链表中的节点
Source code analysis of BlockingQueue (arraybq and linkedbq)
Protocol buffers 的问题和滥用
Paclitaxel loaded tpgs reduced albumin nanoparticles /ga-hsa gambogic acid human serum protein nanoparticles
gnuplot软件学习笔记
JS built-in method
Realize page return to parent directory based on cookies
PIP3 installation complete with source
TT ecosystem - cross border in-depth selection
Practice 4-6 number guessing game (15 points)