减去装配中的三个整数(MASM)

时间:2011-02-15 18:29:35

标签: assembly integer masm irvine32

使用 AddSub 程序,编写一个仅使用16位寄存器减去三个整数的程序。插入调用DumpRegs 语句以显示寄存器值。

AddSub示例程序:

TITLE Add and Subtract, Version 2 (AddSub2.asm)
; This program adds and subtracts 32-bit unsigned
; integers and stores the sum in a variable.
INCLUDE Irvine32.inc
.data
val1 DWORD 10000h
val2 DWORD 40000h
val3 DWORD 20000h
finalVal DWORD ?
.code
main PROC
mov eax,val1 ; start with 10000h
add eax,val2 ; add 40000h
sub eax,val3 ; subtract 20000h
mov finalVal,eax ; store the result (30000h)
call DumpRegs ; display the registers
exit
main ENDP
END main
How does it work? First,

2 个答案:

答案 0 :(得分:0)

在不知道“addSub”程序的情况下,您可能只需要了解有符号整数(二进制补码)和0-x操作码背后的理论。 (NEG)

八位示例,5-10-20

ldi a,5
ldi b,10
ldi c,20

neg b
neg c
addc a,b
addc a,c

OK?

答案 1 :(得分:-1)

问题是:使用3.2节中的ADDSUB程序作为参考,编写一个程序,只减去三个整数的16位寄存器。插入cal DumpRegs语句以显示寄存器值

工作是:

$conn = new PDO("mysql:host=yourhost;dbname=yourdbname;charset=utf8");