三位bcd加法计数器
Problem statement:
问题陈述:
Write a program in 8086 microprocessor to find out the addition of two 8-bit BCD numbers, where numbers are stored from starting memory address 2000 : 500 and store the result into memory address 2000 : 600 and carry at 2000 : 601.
在8086微处理器中编写一个程序,找出两个8位BCD数字的加法运算,其中数字从起始存储地址2000:500存储,并将结果存储到存储地址2000:600,并在2000:601进位。
Algorithm:
算法:
Load data from offset 500 to register AL (first number)
将数据从偏移500加载到寄存器AL(第一个数字)
Load data from offset 501 to register BL (second number)
将数据从偏移量501加载到寄存器BL(第二个数字)
Add these two numbers (contents of register AL and register BL)
将这两个数字相加(寄存器AL和寄存器BL的内容)
Apply DAA instruction (decimal adjust)
应用DAA指令(十进制调整)
Store the result (content of register AL) to offset 600
将结果(寄存器AL的内容)存储到偏移600
Set register AL to 00
将寄存器AL设置为00
Add contents of register AL to itself with carry
用进位将寄存器AL的内容添加到自身
Store the result (content of register AL) to offset 601
将结果(寄存器AL的内容)存储到偏移量601
Stop
停止
Program:
程序:
ADDRESS | MNEMONICS | COMMENTS |
---|---|---|
400 | MOV AL, [500] | AL ← [500] |
404 | MOV BL, [501] | BL ← [501] |
408 | ADD AL, BL | AL ← AL+BL |
40A | DAA | DECIMAL ADJUST AL |
40B | MOV [600], AL | AL → [600] |
40F | MOV AL, 00 | AL ← 00 |
411 | ADC AL, AL | AL ← AL+AL+cy(prev) |
413 | MOV [601], AL | AL → [601] |
417 | HLT | END |
地址 | 记忆 | 注释 |
---|---|---|
400 | MOV AL,[500] | AL←[500] |
404 | MOV BL,[501] | BL←[501] |
408 | 新增AL,BL | AL←AL + BL |
40A | DAA | 法定调整 |
40B | MOV [600],AL | AL→[600] |
40楼 | MOV AL,00 | AL←00 |
411 | ADC AL,AL | AL←AL + AL + cy(上一个) |
413 | MOV [601],AL | AL→[601] |
417 | HLT | 结束 |
Explanation:
说明:
MOV AL, [500]: load data from offset 500 to register AL
MOV AL,[500]:将数据从偏移500加载到寄存器AL
MOV BL, [501]: load data from offset 501 to register BL
MOV BL,[501]:将数据从偏移量501加载到寄存器BL
ADD AL, BL: ADD contents of registers AL AND BL
ADD AL,BL:添加寄存器AL和BL的内容
DAA: decimal adjust AL
DAA:十进制调整AL
MOV [600], AL: store data from register AL to offset 600
MOV [600],AL:将数据从寄存器AL存储到偏移量600
MOV AL, 00: set value of register AL to 00
MOV AL,00:将寄存器AL的值设置为00
ADC AL, AL: add contents of register AL to AL with carry
ADC AL,AL:带进位将寄存器AL的内容添加到AL
MOV [601], AL: store data from register AL to offset 601
MOV [601],AL:将数据从寄存器AL存储到偏移量601
HLT: stop
HLT:停止
三位bcd加法计数器