当前位置:网站首页>Store a group of positive and negative numbers respectively, and count the number of 0 -- assembly language implementation
Store a group of positive and negative numbers respectively, and count the number of 0 -- assembly language implementation
2022-07-26 08:51:00 【Miracle Fan】
Store a group of positive and negative numbers separately , And statistics 0 The number of
1. Realize the idea
By giving positive numbers 、 Negative numbers allocate space for the length of a length digit group , Then send the first address of the two variables to the register , And then loop through , Combine numbers with 0 Judge , Branch in three ways , After execution, the statement .
2. Code implementation
DATA SEGMENT
ARY DB -7,9,-9,1,18,1,-4,6,-13,-1,0,-3,0,-9,0
CNT EQU $-ARY
PLUS DB CNT DUP(?)
MINUS DB CNT DUP(?)
CNT0 DB 0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV BX,OFFSET ARY;ary The first address
MOV SI,OFFSET PLUS;PLUS The first address
MOV DI,OFFSET MINUS;MINUS The first address
MOV CL,0; Used to count , in total CNT individual
L1:
CMP CL,CNT; Whether the number of comparisons has reached the end
JE EXIT; Jump to the end plate
MOV DH,[BX]
CMP DH,0; The judgment is positive 、 Negative or 0
JE ZERO; It's zero
JNS POSITIVE; It means a positive number
JS NEGATIVE; A negative number
ZERO:
INC CNT0
INC BX
INC CL
JMP L1
POSITIVE:
MOV [SI],DH
INC BX
INC SI
INC CL
JMP L1
NEGATIVE:
MOV [DI],DH
INC BX
INC DI
INC CL
JMP L1
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START
边栏推荐
- Alphabetic string
- Web3 Games: current situation and future
- Foundry教程:使用多种方式编写可升级的智能合约(上)
- [database] gbase 8A MPP cluster v95 installation and uninstall
- Hegong sky team vision training Day6 - traditional vision, image processing
- Mysql database connection / query index and other common syntax
- Memory management based on C language - Simulation of dynamic partition allocation
- Typescript encryption tool passwordencoder
- Uni app simple mall production
- ES6模块化导入导出)(实现页面嵌套)
猜你喜欢
Excel find duplicate lines
03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
uni-app 简易商城制作
Deploy prometheus+grafana monitoring platform
Cadence (x) wiring skills and precautions
[encryption weekly] has the encryption market recovered? The cold winter still hasn't thawed out. Take stock of the major events that occurred in the encryption market last week
Poor English, Oracle OCP or MySQL OCP exam can also get a high score of 80 points
Using the primitive root of module m to judge and solve
Leetcode and query question summary
Solve the problem of C # calling form controls across threads
随机推荐
03异常处理,状态保持,请求钩子---04大型项目结构与蓝图
Mysql database connection / query index and other common syntax
C Entry series (31) -- operator overloading
12306 ticket system crawling - 1. Saving and reading of city code data
基于C语言设计的换乘指南打印系统
What are the contents of Oracle OCP and MySQL OCP certification exams?
Dynamic SQL and exceptions of pl/sql
23.6 23.7 web environment web environment variable reading
2000年的教训。web3是否=第三次工业革命?
Mycat2 sub database and sub table
Pan micro e-cology8 foreground SQL injection POC
[untitled]
Analysis on the query method and efficiency of Oracle about date type
Neo eco technology monthly | help developers play smart contracts
Transfer guide printing system based on C language design
Study notes of automatic control principle -- dynamic model of feedback control system
Ansible important components (playbook)
Mysql/mariadb (Galera multi master mode) cluster construction
Excel find duplicate lines
Poor English, Oracle OCP or MySQL OCP exam can also get a high score of 80 points