当前位置:网站首页>Assemble | find the maximum and minimum values
Assemble | find the maximum and minimum values
2022-07-24 08:06:00 【-Babbler-】
function : Bubble sort finds the maximum and minimum values
DATA SEGMENT
TABLE DB 1,2,10,20,5,7,6
NUM EQU ($-TABLE)-1 ; The number of bubble sorting is the number of elements n-1
DATA ENDS
CODE SEGMENT
ASSUME: CS:CODE, DS:DATA
START:MOV AX, DATA
MOV DS, AX
; Get ready
MOV CX, NUM ; The length of the memory ( The number of numbers )
LEA SI, TABLE ; Address of a pointer SI Point to TABLE First address of storage area
MOV BH, [SI] ; Put the first number in BH, Save the current maximum
MOV BL, [SI] ; Put the first number in BL, Save the current minimum
; Find the maximum and minimum
CALL FIND
; Show maximum
MOV AL, BH
CALL PRINT
; Show minimum
MOV AL, BL
CALL PRINT
; Back to the operating system
MOV AH, 4CH
INT 21H
; Find the maximum and minimum --- The results are stored in BH,BL in
FIND PROC NEAR
L: INC SI ; The pointer SI Move to the next number
MOV AL, [SI] ;AL -- Current number
CMP AL, BL ; And BL Compare
JB NEXT1 ;AL Less than BL --- BL Replace with a smaller value
CMP AL, BH ; And BH Compare
JB NEXT2 ;AL Less than BH --- Cycle down
MOV BH, AL ; otherwise BH Replace with a larger value
JMP NEXT2 ; Cycle down
NEXT1:MOV BL, AL ;BL Replace with a smaller value
JMP NEXT2
NEXT2:LOOP L ; Check whether the cycle stops
RET
FIND ENDP
; Displays the maximum and minimum values --- Show that the number exists AL in
PRINT PROC NEAR
PUSH DX
MOV DL,AL
CMP DL,9 ; Determine whether <=9
JLE ADD1 ; yes ---> ASCII Code plus 30H
JNLE ADD2 ; No ---> ASCII Code plus 37H
ADD1: ADD DL,30H
JMP PRI
ADD2: ADD DL,37H
PRI: ; Show
MOV AH,02H
INT 21H
; Carriage return
MOV DX,0DH
INT 21H
; Add line breaks
MOV DL,0AH
INT 21H
POP DX
RET
PRINT ENDP
CODE ENDS
END START边栏推荐
- Case practice - panoramic image mosaic: feature matching method
- *Code understanding *numpy basic (plus code) that must be understood
- Hcip day 8 notes
- A Knight‘s Journey题解
- SVM linear separable linear support vector machine
- MySQL --- 子查询 - 标量子查询
- Collection of linked list topics
- NFT是什么?一篇文章搞懂NFT的概念
- Common DOS commands
- 赛宁TechTalk丨攻防演练:攻击组合拳 “稳准狠”渗透
猜你喜欢

Do you want to have a robot that can make cartoon avatars in three steps?

Qt|字符串生成二维码功能

Generative model and discriminant model

What is NFT? An article to understand the concept of NFT

Thesis reading: geotransformer

MySQL -- subquery scalar subquery

Debug No1 summarizes common solutions to bugs

Hcip day 8 notes

VIDAR team team exclusive interview: as we do, as you know

jmeter中JSON提取器使用
随机推荐
Natural language processing Jieba
【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵
Generative model and discriminant model
P1135 strange elevator problem solution
Tools for data visualization
Common DOS commands
Hegong sky team vision training Day2 - traditional vision, opencv basic operation
Thesis reading: geotransformer
Autojs article proficient in detailed explanation of autojs script tutorial
*Code understanding *numpy basic (plus code) that must be understood
MySQL -- subquery scalar subquery
how to add square on screenshot
[multithreading] five communication modes between multithreads
What is the NFT concept.. Fully understand NFT market, technology and cases
Learning dynamic Siamese network for visual object tracking full text translation
Image feature SIFT (scale invariant feature transform)
Hegong sky team vision training day4 - traditional vision, contour recognition
[golang from introduction to practice] student achievement management system
mysql使用explain分析sql执行计划帮助查找性能瓶颈
Digital twin demonstration project -- Talking about simple pendulum (4) IOT exploration