汇编中三个整数相减 (MASM)
使用AddSub程序,编写一个仅使用16位寄存器减去三个整数的程序。插入call 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,
Using the AddSub program, write a program that subtracts three integers using only 16-bit registers. Insert a call DumpRegs statement to display the register values.
AddSub Example Program:
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,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不知道“addSub”程序,您可能只需要知道有符号整数(二进制补码)和 0-x 的操作码背后的理论。 (NEG)
八位示例,5-10-20
可以吗?
Without knowing the "addSub"-program, you probably only have to know the theory behind signed integers, (two's complement), and the opcode for 0-x. (NEG)
Eight bit example, 5-10-20
ok?
问题是:以3.2节中的ADDSUB程序为参考,编写一个只对16位寄存器进行三个整数相减的程序。插入一个 cal DumpRegs 语句来显示寄存器值
工作是:
Question is:Using the ADDSUB program from the section 3.2 as a reference, write a program that subtracts three integers only 16-bit registers. Insert a cal DumpRegs statement to display the register values
Work is: