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.
输入
地址 | 数据 |
---|---|
… | … |
500 | 04 |
501 | 09 |
502 | 03 |
503 | 08 |
504 | 06 |
… | … |
601 | 04 |
602 | 01 |
603 | 02 |
604 | 03 |
… | … |
流程图
程序
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
输出
地址 | 数据 |
---|---|
… | … |
500 | 04 |
501 | 05 |
502 | 02 |
503 | 06 |
504 | 03 |
… | … |
广告