本文介绍了以8086汇编语言交换2个寄存器(16位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在不使用其他变量,寄存器,堆栈或任何其他存储位置的情况下交换2个寄存器的值吗?谢谢!

Does someone know how to swap the values of 2 registers without using another variable, register, stack, or any other storage location? thanks!

就像交换AX,BX.

推荐答案

您可以使用一些数学运算来完成.我可以给你个主意.希望对您有帮助!

You can do it using some mathematical operation. I can give you an idea. Hope it helps!

我遵循了以下C代码:

int i=10; j=20
i=i+j;
j=i-j;
i=i-j;


mov ax,10
mov bx,20
add ax,bx
//mov command to copy data from accumulator to ax, I forgot the statement, now ax=30
sub bx,ax //accumulator vil b 10
//mov command to copy data from accumulator to bx, I forgot the statement now
sub ax,bx //accumulator vil b 20
//mov command to copy data from accumulator to ax, I forgot the statement now

这篇关于以8086汇编语言交换2个寄存器(16位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 14:41