8086 程序确定两个数组中对应元素的减法


在本程序中,我们将了解如何减去两个不同数组的内容。

问题陈述

编写 8086 汇编语言程序,以减去存储在两个不同数组中对应的元素的内容

讨论

此示例中有两个不同的数组。数组存储在 501 及其以后的位置和 601 及其以后的位置。这两个数组的大小存储在偏移位置 500。我们使用数组大小初始化计数器,然后通过使用循环逐个减去元素

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

输入

地址数据
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 次浏览

开始你的 事业

通过完成课程取得认证

开始
广告