查找不在0到n的数字_在8位N数字中查找最大| 8086微处理器

news/2024/7/20 1:42:38 标签: java, python, mysql, 大数据, 小程序

查找不在0到n的数字

Problem: Write a program in 8086 microprocessor to find out the largest among 8-bit n numbers, where size n is stored at memory address 2000 : 500 and the numbers are stored from memory address 2000 : 501 and store the result (largest number) into memory address 2000 : 600.

问题: 在8086微处理器中编写一个程序,以找出8位n个数字中最大的一个 ,其中大小n存储在内存地址2000:500中,数字从存储地址2000:501存储并存储结果(最大数字)进入内存地址2000:600。

Algorithm:

算法:

  1. Load data from offset 500 to register CL and set register CH to 00 (for count).

    将数据从偏移500加载到寄存器CL并将寄存器CH设置为00(用于计数)。

  2. Load first number (value) from next offset (i.e. 501) to register AL and decrease count by 1.

    从下一个偏移量(即501)中加载第一个数字(值)到寄存器AL,并将计数减1。

  3. Now compare value of register AL from data(value) at next offset, if that data is greater than value of register AL then update value of register AL to that data else no change, and increase offset value for next comparison and decrease count by 1 and continue this till count (value of register CX) becomes 0.

    现在将寄存器AL的值与下一个偏移量的数据(值)进行比较,如果该数据大于寄存器AL的值,则将寄存器AL的值更新为该数据,否则保持不变,并为下一次比较将偏移量值增加,并将计数减少1并继续进行直到计数(寄存器CX的值)变为0。

  4. Store the result (value of register AL) to memory address 2000 : 600.

    将结果(寄存器AL的值)存储到内存地址2000:600。

Program:

程序:

ADDRESSMNEMONICSCOMMENTS
400MOV SI, 500SI ← 500
403MOV CL, [SI]CL ← [SI]
405MOV CH, 00CH ← 00
407INC SISI ← SI+1
408MOV AL, [SI]AL ← [SI]
40ADEC CLCL ← CL-1
40CINC SISI ← SI+1
40DCMP AL, [SI]AL-[SI]
40FJNC 413JUMP TO 413 IF CY=0
411MOV AL, [SI]AL ← [SI]
413INC SISI ← SI+1
414LOOP 40DCX ← CX-1 & JUMP TO 40D IF CX NOT 0
416MOV [600], ALAL → [600]
41AHLTEND
地址 记忆 注释
400 MOV SI,500 SI←500
403 MOV CL,[SI] CL←[SI]
405 MOV CH,00 CH←00
407 INC SI SI←SI + 1
408 MOV AL,[SI] AL←[SI]
40A DEC CL CL←CL-1
40度 INC SI SI←SI + 1
40D CMP AL,[SI] AL- [SI]
40楼 JNC 413 如果CY = 0,则跳至413
411 MOV AL,[SI] AL←[SI]
413 INC SI SI←SI + 1
414 环40D 如果CX不为0,则CX←CX-1和跳至40D
416 MOV [600],AL AL→[600]
41A HLT 结束

Explanation:

说明:

  1. MOV SI, 500: set the value of SI to 500

    MOV SI,500:将SI的值设置为500

  2. MOV CL, [SI]: load data from offset SI to register CL

    MOV CL,[SI]:将数据从偏移SI加载到寄存器CL

  3. MOV CH, 00: set value of register CH to 00

    MOV CH,00:将寄存器CH的值设置为00

  4. INC SI: increase value of SI by 1

    INC SI:将SI的值增加1

  5. MOV AL, [SI]: load value from offset SI to register AL

    MOV AL,[SI]:从偏移量SI到寄存器AL的加载值

  6. DEC CL: decrease value of register CL by 1

    DEC CL:将寄存器CL的值减1

  7. INC SI: increase value of SI by 1

    INC SI:将SI的值增加1

  8. CMP AL, [SI]: compares value of register AL and [SI] (AL-[SI])

    CMP AL,[SI]:比较寄存器AL和[SI](AL- [SI])的值

  9. JNC 413: jump to address 413 if carry not generated

    JNC 413:如果未生成进位则跳转到地址413

  10. MOV AL, [SI]: transfer data at offset SI to register AL

    MOV AL,[SI]:将偏移量SI的数据传输到寄存器AL

  11. INC SI: increase value of SI by 1

    INC SI:将SI的值增加1

  12. LOOP 40C: decrease value of register CX by 1 and jump to address 40D if value of register CX is not zero

    LOOP 40C:如果寄存器CX的值不为零,则将寄存器CX的值减1并跳转到地址40D

  13. MOV [600], AL: store the value of register AL to offset 600

    MOV [600],AL:将寄存器AL的值存储到偏移600

  14. HLT: stop

    HLT:停止

翻译自: https://www.includehelp.com/embedded-system/find-the-largest-among-8-bit-N-numbers.aspx

查找不在0到n的数字


http://www.niftyadmin.cn/n/1256044.html

相关文章

八大排序算法的 Python 实现

冒泡排序原理冒泡排序(Bubble Sort)是一种简单的排序算法。它重复地走访过要排序的数列,依次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由…

bootstrap-selectpicker 插件事件

$(#id).on(show.bs.select, function (e) {//绑定下拉显示列表触发事件 });$(#id).on(hidden.bs.select, function (e) {//绑定下拉选择隐藏触发事件});转载于:https://www.cnblogs.com/ZeroSunny/p/8599958.html

jq简单实现选项卡--tab

Html代码如下 <!DOCTYPE html> <html> <head> <meta charset"utf-8"> <meta name"viewport" content"widthdevice-width, initial-scale1.0"> <meta name"description" content""> <…

第一个python作业题目以及代码

1、 编写程序&#xff0c;用户输入一个三位以上的整数&#xff0c;输出其百位以上的数字。例如用户输入1234&#xff0c;则程序输出12。&#xff08;提示&#xff1a;使用整除运算。&#xff09; xinput("请输入一个三位以上的数字&#xff1a;") xint(x) xx//100 if…

路由器漏洞复现分析第三弹:DVRF INTRO题目分析

这个项目的目的是来帮助人们学习X86_64之外其他架构环境&#xff0c;同时还帮助人们探索路由器固件里面的奥秘。 本文通过练习DVRF 中INTRO 部分的题目来学习下MIPS 结构下的各种内存攻击。 DVRF&#xff1a;路由器漏洞练习靶机 用binwalk解压DVRFbin后&#xff0c;题目位于如下…

微原循环移位指令_8086微处理器中的移位和旋转指令

微原循环移位指令As we know that any machine (system) works on machine language, which consists of binary numbers. In the 8086 microprocessor, we have 16-bit registers to handle our data. Sometimes, the need to perform some necessary shift and rotate operat…