程序集 [ASM]:不使用算术运算符进行加法

Assembly [ASM]: Adding without using arithmetic operators

如何在没有 addadcsubsbbincdec 的情况下将两个寄存器相加?

老实说,我只是把 this answer 翻译成汇编,求和的数字在 axbx 中,而寄存器 cxdx用于获取中间结果,最终结果在dx:

  mov ax, 12801  ;◄■■ FIRST NUMBER.
  mov bx, 2017   ;◄■■ SECOND NUMBER.

l1:

  mov cx, ax
  and cx, bx

  mov dx, ax
  xor dx, bx

  mov ax, cx
  shl ax, 1

  mov bx, dx

  cmp ax, 0   ;◄■■ IF AX != 0 REPEAT.
  jne l1

;RESULT IN DX = 14818