c#給定二維數組按升序排序_在數組中按升序對數字進行排序| 8086微處理器

c#給定二維數組按升序排序

Problem: Write a program in 8086 microprocessor to sort numbers in ascending order in an array of n numbers, where size n is stored at memory address 2000 : 500 and the numbers are stored from memory address 2000 : 501.

問題:在8086微處理器中編寫一個程序,以按n個數字的升序對數字進行排序,其中大小n存儲在內存地址2000:500中,而數字存儲在內存地址2000:501中。

Algorithm:

算法:

  1. Load data from offset 500 to register CL (for count).

    將數據從偏移500加載到寄存器CL(用于計數)。

  2. Travel from starting memory location to last and compare two numbers if first number is greater than second number then swap them.

    從起始存儲位置移動到最后一個位置,如果第一個數字大于第二個數字,則比較兩個數字,然后交換它們。

  3. First pass fix the position for last number.

    首遍確定最后一個號碼的位置。

  4. Decrease the count by 1.

    將計數減少1。

  5. Again travel from starting memory location to (last-1, by help of count) and compare two numbers if first number is greater than second number then swap them.

    再次從起始存儲位置移動到(last-1,借助計數),如果第一個數字大于第二個數字,則比較兩個數字,然后交換它們。

  6. Second pass fix the position for last two numbers.

    第二遍確定最后兩個數字的位置。

  7. Repeated.

    重復。

Program:

程序:

ADDRESSMNEMONICSCOMMENTS
400MOV SI, 500SI ← 500
403MOV CL, [SI]CL ← [SI]
405DEC CLCL ← CL-1
407MOV SI, 500SI ← 500
40AMOV CH, [SI]CH ← [SI]
40CDEC CHCH ← CH-1
40EINC SISI ← SI+1
40FMOV AL, [SI]AL ← [SI]
411INC SISI ← SI+1
412CMP AL, [SI]AL-[SI]
414JC 41CJUMP TO 41C IF CY=1
416XCHG AL, [SI]SWAP AL AND [SI]
418DEC SISI ← SI-1
419XCHG AL, [SI]SWAP AL AND [SI]
41BINC SISI ← SI+1
41CDEC CHCH ← CH-1
41EJNZ 40FJUMP TO 40F IF ZF=0
420DEC CLCL ← CL-1
422JNZ 407JUMP TO 407 IF ZF=0
424HLTEND
地址 記憶 注釋
400 MOV SI,500 SI←500
403 MOV CL,[SI] CL←[SI]
405 DEC CL CL←CL-1
407 MOV SI,500 SI←500
40A MOV CH,[SI] CH←[SI]
40度 DEC CH CH←CH-1
40E INC SI SI←SI + 1
40樓 MOV AL,[SI] AL←[SI]
411 INC SI SI←SI + 1
412 CMP AL,[SI] AL- [SI]
414 JC 41C 如果CY = 1,則跳至41C
416 XCHG AL,[SI] 交換AL和[SI]
418 DEC SI SI←SI-1
419 XCHG AL,[SI] 交換AL和[SI]
41B INC SI SI←SI + 1
41C DEC CH CH←CH-1
41E JNZ 40F 如果ZF = 0,則跳至40F
420 DEC CL CL←CL-1
422 JNZ 407 如果ZF = 0,則跳至407
424 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. DEC CL: decrease value of register CL BY 1.

    DEC CL:將寄存器CL的值減1。

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

    MOV SI,500:將SI的值設置為500。

  5. MOV CH, [SI]: load data from offset SI to register CH.

    MOV CH,[SI]:將數據從偏移量SI加載到寄存器CH。

  6. DEC CH: decrease value of register CH BY 1.

    DEC CH:將寄存器CH的值減1。

  7. INC SI: increase value of SI BY 1.

    INC SI:SI的值增加1。

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

    MOV AL,[SI]:從偏移量SI加載到寄存器AL的值。

  9. INC SI: increase value of SI BY 1.

    INC SI:SI的值增加1。

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

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

  11. JC 41C: jump to address 41C if carry generated.

    JC 41C:如果產生進位,則跳轉到地址41C。

  12. XCHG AL, [SI]: exchange the contents of register AL and SI.

    XCHG AL,[SI]:交換寄存器AL和SI的內容。

  13. DEC SI: decrease value of SI by 1.

    DEC SI:將SI的值減1。

  14. XCHG AL, [SI]: exchange the contents of register AL and SI.

    XCHG AL,[SI]:交換寄存器AL和SI的內容。

  15. INC SI: increase value of SI by 1.

    INC SI:將SI的值增加1。

  16. DEC CH: decrease value of register CH by 1.

    DEC CH:將寄存器CH的值減1。

  17. JNZ 40F: jump to address 40F if zero flat reset.

    JNZ 40F:如果歸零平面復位,則跳轉到地址40F。

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

    DEC CL:將寄存器CL的值減1。

  19. JNZ 407: jump to address 407 if zero flat reset.

    JNZ 407:如果歸零平面復位,則跳轉到地址407。

  20. HLT: stop.

    HLT:停止。

翻譯自: https://www.includehelp.com/embedded-system/sort-numbers-in-ascending-order-in-an-array.aspx

c#給定二維數組按升序排序

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542671.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542671.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542671.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

使用python套用excel模板_Python自動化辦公Excel-從表中批量復制粘貼數據到新表

1、模塊安裝 1)cmd模式下: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xlrd pip install -i https://pypi.tuna.tsinghua.edu.cn/simple openpyxl 2)如果有安裝Pycharm,則在程序中操作如下: 菜單欄&…

在HubSpot是如何應對Fat JAR困境的

在七月底,Spring Boot和Dropwizard分別發布了1.4和1.0版本,它們都是基于Fat JAR的。隨著人們更多地采用這些框架和微服務架構,Fat JAR成為了通用的部署機制。\\Fat JAR技術會將Java應用的所有依賴打包到一個bundle之中,便于執行&a…

給定數字的b+樹創建_在C ++中找到給定數字中的兩個的下一個和上一個冪

給定數字的b樹創建Problem statement: 問題陳述: Find Next and previous power of two of a given number 查找給定數字中兩個的下一個和上一個冪 Next power of two 下一個二的冪 Example(1):input: 22output: 32 ( as 32 is 2^5)Example(2):input: 54output…

java 字節數組作用_這段java代碼中字節數組b起到了什么作用?

importjava.io.*;importjavax.swing.*;publicclassIOMonitor{publicstaticvoidmain(String[]temp){//TODO自動生成的方法存根byteb[]newbyte[2];try{FileInputStreamfisnewFileInput...import java.io.*;import javax.swing.*;public class IOMonitor {public static void main…

如何查看本地的崩潰log_過年回家,還怕搶不到票?程序員教你如何搶票

2019年接近尾聲,距離春節回家的日子越來越近,26日起,2020年除夕火車票正式開售,搶票大戰也進入白熱化階段。是否為某搶票 App 加速而煩惱,是否為車票“秒光而煩惱”。別慌,作為連“對象”都是 new 出來的程…

獲取列表中包含的元素數 在C#中

Given a list, and we have to count its total number of elements using List.Count property. 給定一個列表,我們必須使用List.Count屬性計算其元素總數 。 C#清單 (C# List) A list is used to represent the list of the objects, it is represent…

I00037 虧數(Deficient number)

數論中,若一個正整數除了本身之外所有因子之和比此數自身小,則稱此數為虧數。虧數(Deficient number)也稱為缺數,參見百度百科_虧數,或參見維基百科的Deficient number。虧數在OEIS中的數列號為A005100。 問…

hashmap轉紅黑樹的閾值為8_面試必考的 HashMap,這篇總結到位了

點擊藍色“JavaKeeper”關注我喲加個“星標”,一起成長,做牛逼閃閃的技術人1 概述HashMap是基于哈希表實現的,每一個元素是一個key-value對,其內部通過單鏈表解決沖突問題,容量不足(超過了閥值)時,同樣會自動增長.HashMap是非線程安全的,只適用于單線程環…

linux用戶組管理命令_Linux用戶和組命令能力問題和解答

linux用戶組管理命令This section contains Aptitude Questions and Answers on Linux User and Group Commands. 本節包含有關Linux用戶和組命令的 Aptitude問答。 1) Which of the following commands is used to create a new user in the Linux operating system? create…

Failed to start firewalld.service: Unit firewalld.service is masked.

2019獨角獸企業重金招聘Python工程師標準>>> FireWall in Centos 7 masked How to resolve the error message belowFailed to issue method call: Unit firewalld.service is masked. The main reason a service is masked is to prevent accidental starting or e…

mysql第二個索引_MySQL高級第二章——索引優化分析

一、SQL性能下降原因1.等待時間長?執行時間長?可能原因:查詢語句寫的不行索引失效(單值索引、復合索引)CREATE INDEX index_user_name ON user(name);(底層做了一個排序)CREATE INDEX index_user_nameEmail ON user(name,email);查詢關聯join…

遞歸反轉鏈表改變原鏈表嗎_在不使用遞歸的情況下找到鏈表的長度

遞歸反轉鏈表改變原鏈表嗎Solution: 解: Algorithm to find length 查找長度的算法 Input: 輸入: A singly linked list whose address of the first node is stored in a pointer, say head. 一個單鏈表 ,其第一個節點的地址存儲在指針(例…

西瓜仿站高手v1.08官方正式版

2019獨角獸企業重金招聘Python工程師標準>>> 西瓜仿站高手是一款綠色好用的由追風網絡出品的網站模板批量下載軟件,西瓜仿站高手是一款仿站工具,仿站神器。軟件功能強大,能夠幫你輕松幫你下載任意網站、任意模板,并且速…

用hundred造句子_八個有趣的開學破冰游戲,線上線下都能用

知道大家最近都很忙,所以省略開篇,直接上正題——開學“破冰游戲”走起!一、你比劃我來猜把詞語展示在PPT上,猜詞的同學背對PPT,其他同學可以看到詞語并且用身體動作把詞語表現出來,直到猜詞的同學可以把詞…

java 執行順序_Java代碼執行順序

程序中代碼執行的順序非常重要,稍有不慎便會是程序運行出錯,那么我將結合實例來分析代碼中的執行。名詞解釋首先了解幾個名詞:非靜態代碼塊直接由 { } 包起來的代碼,稱為非靜態代碼塊靜態代碼塊直接由 static { } 包起來的代碼&am…

mysql 包含的那些文件

*.frm是描述了表的結構 *.MYD保存了表的數據記錄 *.MYI則是表的索引 ibd是MySQL數據文件、索引文件,無法直接讀取。 轉載于:https://www.cnblogs.com/07byte/p/5823667.html

math 計算float_Java Math類靜態float min(float f1,float f2)與示例

math 計算float數學類靜態浮點數min(float f1,float f2) (Math Class static float min(float f1 , float f2) ) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to return the minimum one of both the given a…

vector 不初始化時什么狀態_Vue原理解析(三):初始化時created之前做了什么?...

讓我們繼續this._init()的初始化之旅,接下來又會執行這樣的三個初始化方法:initInjections(vm) initState(vm) initProvide(vm)5. initInjections(vm): 主要作用是初始化inject,可以訪問到對應的依賴。inject和provide這里需要簡單的提一下&a…

switch 字符串 java_JDK7新特性switch支持字符串

在JDK7中,switch語句的判斷條件增加了對字符串類型的支持。由于字符串的操作在編程中使用頻繁,這個新特性的出現為Java編程帶來了便利。接下來通過一個案例演示一下在switch語句中使用字符串進行匹配。public class Example {public static void main(String[] args) {String w…

cisco packet tracer路由器配置_【干貨】思科交換機路由器怎么配置密碼?

今天帶大家看看如何在思科的交換機路由器當中配置安全特性,也就是密碼的配置方式。在學習配置之前,我們先回顧一下密碼相關知識。密碼學是研究信息系統安全保密的科學。人類有記載的通信密碼始于公元前400年,古希臘人是置換密碼學的發明者。密…