组装Intel 8086 64位操作数计算器

问题描述 投票:0回答:1

我需要一个计算器的完整程序,用于计算 2 个操作数(每个操作数 64 位)的和、减法、乘法和除法。

因为8086微处理器中的寄存器是16位我找不到解决这个问题的方法。

assembly calculator x86-16 emu8086
1个回答
0
投票

要求一个完整的程序超出了您在这个论坛上可以要求的范围。我们负责解决您在自己执行任务时可能遇到的具体问题。我们不会为您编写所有代码!

2 个操作数,每个 64 位。
因为8086微处理器中的寄存器是16位的,所以我找不到解决这个问题的方法。

为了让您了解如何处理大于正常寄存器大小的数字,请考虑将两个 64 位值 0123456789ABCDEFh 和 012389ABCDEF4567h 添加的情况:

valueA dw CDEFh, 89ABh, 4567h, 0123h
valueB dw 4567h, CDEFh, 89ABh, 0123h
result dw 0, 0, 0, 0

无循环

mov  di, offset result
mov  si, offset valueA
mov  bx, offset valueB
mov  ax, [si]
add  ax, [bx]
mov  [di], ax
mov  ax, [si+2]
adc  ax, [bx+2]    <<<< Note the use of ADC that allows propagating
mov  [di+2], ax          the carry from earlier addition
mov  ax, [si+4]
adc  ax, [bx+4]    <<<< Note the use of ADC that allows propagating
mov  [di+4], ax          the carry from earlier addition
mov  ax, [si+6]
adc  ax, [bx+6]    <<<< Note the use of ADC that allows propagating
mov  [di+6], ax          the carry from earlier addition

带循环

并利用这些值在内存中彼此相邻存储的事实:

 mov  di, offset result
 mov  si, offset valueA
 clc             ; No carry to consider in first addition
Next:
 lodsw           ; `mov ax, [si]` `add si, 2`
 adc  ax, [si+6] ; Use ADC to propagate carry from earlier addition
 stosw           ; `mov [di], ax` `add di, 2`
 cmp  si, valueB
 jb   Next
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.