8086 程式確定兩個陣列中對應元素的減法


在本程式中,我們將瞭解如何減去兩個不同陣列的內容。

問題陳述

編寫 8086 組合語言程式,以減去儲存在兩個不同陣列中對應的元素的內容

討論

此示例中有兩個不同的陣列。陣列儲存在 501 及其以後的位置和 601 及其以後的位置。這兩個陣列的大小儲存在偏移位置 500。我們使用陣列大小初始化計數器,然後透過使用迴圈逐個減去元素

輸入

地址資料
50004
50109
50203
50308
50406
60104
60201
60302
60403

流程圖

程式

    MOV SI, 500     ;Point Source index to 500
    MOV CL, [SI]    ;Load the array size into CL
    MOV CH, 00 ;Clear Upper half of CX
    INC SI   ;Increase SI register to point next location
    MOV DI, 601     ;Destination register points to 601
L1: MOV AL, [SI]    ;Load A with the data stored at SI
    SUB AL, [DI]    ;Subtract DI element from AL
    MOV [SI], AL    ;Store AL to SI address
    INC SI   ;SI Point to next location
    INC DI   ;DI Point to next location
    LOOP L1     ;Jump to L1 until the counter becomes 0
    HLT ;Terminate the program

輸出

地址資料
50004
50105
50202
50306
50403

更新於:2019 年 7 月 30 日

253 次瀏覽

開始你的 事業

透過完成課程取得認證

開始
廣告