Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 在汇编中减去三个整数(MASM)_Assembly_Integer_Masm_Irvine32 - Fatal编程技术网

Assembly 在汇编中减去三个整数(MASM)

Assembly 在汇编中减去三个整数(MASM),assembly,integer,masm,irvine32,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 1

使用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,
在不知道“addSub”程序的情况下,您可能只需要知道有符号整数(2的补码)背后的理论,以及0-x的操作码。(负)

八位示例,5-10-20

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

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

好吗?

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

工作是:

TITLE Add and Subtract      (AddSub.asm)

; Program Assignment 1 - Subtracting Three Integers   
; Using the AddSub program From Section 3.2 as a Reference,  
; Write a program that subtracts three Integer using only 16-bit     registers,  
; Insert a call DumpRegs statement to display the register values.

INCLUDE Irvine32.inc

 .code
 main PROC

 mov eax, 90000h    ;EAX = 10000h  
 sub eax, 40000h    ;EAX = 50000h   
 sub eax, 20000h    ;EAX = 30000h   
 call DumpRegs                ; display registers    

   exit    

   main ENDP   

   END main

您好,欢迎来到苏。由于你是新来的,一些友好的建议-在你的问题中包括你尝试了什么,以及你到底被困在哪里。这会帮助你得到更好的答案。没有人会为您编写代码。另外,鉴于这是汇编语言,它是用于什么平台的?哪种汇编语言?数字的大小是多少?有很多事情需要澄清。最重要的是你尝试了什么?@LưuVĩnhPhúc:看看OP的简介,尤其是“看到”部分。你真的相信你会得到答案吗?只有16位寄存器。