本文介绍了我们可以用两个32位章(32 + 32 = 64)在同一时间,使其能够承担64位值?汇编语言8086的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

汇编语言8086:

我必须做出另外它需要在控制台两个值,并给我们带来..它只能采取在32位(8位),如果我们给予较高值,那么它会给控制台整数溢出的误差值的程序

如果我想给更多然后在输入1 32bit的值和输入2我将如何做呢?

我想通过使用32位的寄存器添加值1到值2和64位下的对价(相当于16位)..它可以使用 2章(32 + 32 = 64)的空间? ...

我们怎样才能使2寄存器32位,使其64位我知道这是可能的,但我不知道怎么做了......因为我在汇编语言是新

我使用KIP.R.IRVINE链接库汇编语言

我们将如何使用2章32位64位给予价值?或如何我们将启用32位2章取64位值?

这里是code的32位加法:

 包括Irvine32.inc。数据 此外BYTE答:加入两个整数,0 inputValue1st BYTE输入第一个整​​数=0
 inputValue2nd BYTE输入第二个整数=0  outputSumMsg​​ BYTE的两个整数的总和=0   NUM1 DD?
   NUM2 DD?
   综上所述DD?   。code   主要PROC   ; ----显示除了文字-----  MOV EDX,偏移加
  调用WriteString
  调用CRLF
  ; -------------------------------  ;调用程序在这里   电话InputValues
   打电话的addValue
   调用outputValue   调用CRLF   JMP exitLabel
   主要ENDP
      ;这是我作出的程序是在这里
  InputValues​​ PROC
  ; -----------对于第一个值--------
   调用CRLF
   MOV EDX,OFFSET inputValue1st;输入文本1
   调用WriteString   ;这里正在采取第一个值
   调用的readInt;读整
   MOV NUM1,EAX;存储值
     ; -----------对于第二个值----------      MOV EDX,OFFSET inputValue2nd;输入文本2
      调用WriteString
      ;这里正在采取第二个值
      调用的readInt;读整
      MOV NUM2,EAX;存储值      RET
      InputValues​​ ENDP
     ; ---------添加总和----------------     PROC的addValue
     ;计算总和     MOV EAX,NUM2;移动NUM2到EAX
     添加EAX,NUM1;加NUM2 NUM1到
     MOV总和,EAX;瓦尔存储在EAX     RET
     的addValue ENDP     ; --------对于和输出结果----------     outputValue PROC     ;输出结果     MOV EDX,OFFSET outputSumMsg​​;输出文本
     调用WriteString
     MOV EAX,总和
     调用WriteInt;打印EAX中的价值
     RET
     outputValue ENDP
     exitLabel:
     出口
    主要END


解决方案

您可以结合使用 ADC 添加做添加的东西存储在2个32位寄存器,64位整数。

您可以结合使用 SHLD SHL 来左移存储在2 32位64位整数位寄存器。

如果你能做到64位加法和64位转移,您可以轻松地通过10(提示做一个64位整数乘法:10 = 8 + 2,X * 10 = X * 8 + X * 2 )。

您可能会需要它才能从控制台读取64位整数。你需要阅读它们作为 ASCII字符串,然后使用重复乘以10和加法(提示转换为64位整数:1234 =( ((0 + 1)* 10 + 2)* 10 + 3)* 10 + 4 )。

以上应该是足够的信息来读取64位整数,并将其添加。

为了打印您需要通过10有64位除法,这样你就可以在64位整数转换成 ASCII字符串的总和小数重它(提示presentation:4 = 1234 MOD 10(当时123 = 1234/10),3 = 123 MOD 10(当时12 = 123/10),2 = 12模10(当时1 = 12/10),1 = 1模10(0再= 1/10,停止))。

我不使用2 的DIV将会由现在10来解释如何做到64位除法。获得其余的第一个工作日。

Assembly Language 8086:

I have make the program for addition it takes two values in console and gives us result.. it can only take value under 32 bits(8 digits) if we give higher value then it will give error of integer overflow in console

If i want to give more then 32bit value in input1 and input2 how will i do it?

I Want add value1 to value2 by using 32bit register and give value under 64bit(equals to 16 digits).. it is Possible to use the space of 2 reg (32+32 = 64bit)?...

How we can make 2 register of 32 bit to make it 64bit i know it is possible but i don't know how to do it...because i am new in Assembly language

I am using KIP.R.IRVINE Link Libraries in Assembly Language

how we will give 64bit value by using 2 32bit reg? or how we will enable 2 32bit reg to take 64bit value?

here is the code for 32-bit addition:

INCLUDE Irvine32.inc

.data

 Addition BYTE "A: Add two Integer Numbers", 0

 inputValue1st BYTE "Input the 1st integer = ",0
 inputValue2nd BYTE "Input the 2nd integer = ",0

  outputSumMsg BYTE "The sum of the two integers is = ",0

   num1 DD ?
   num2 DD ?
   sum  DD ?

   .code

   main PROC

   ;----Displays addition Text-----

  mov edx, OFFSET Addition
  call WriteString
  call Crlf
  ;-------------------------------

  ; calling procedures here

   call InputValues
   call addValue
   call outputValue

   call Crlf

   jmp exitLabel


   main ENDP


      ; the PROCEDURES which i have made is here


  InputValues PROC
  ;----------- For 1st Value--------


   call Crlf
   mov edx,OFFSET inputValue1st ; input text1
   call WriteString

   ; here it is taking 1st value
   call ReadInt    ; read integer
   mov num1, eax   ; store the value




     ;-----------For 2nd Value----------



      mov edx,OFFSET inputValue2nd ; input text2
      call WriteString


      ; here it is taking 2nd value
      call ReadInt    ; read integer
      mov num2, eax   ; store the value

      ret
      InputValues ENDP




     ;---------Adding Sum----------------

     addValue PROC
     ; compute the sum

     mov eax, num2  ; moves num2 to eax
     add eax, num1  ; adds num2 to num1
     mov sum, eax   ; the val is stored in eax

     ret
     addValue ENDP

     ;--------For Sum Output Result----------

     outputValue PROC

     ; output result

     mov edx, OFFSET outputSumMsg ; Output text
     call WriteString


     mov eax, sum
     call WriteInt ; prints the value in eax


     ret
     outputValue ENDP


     exitLabel:
     exit


    END main
解决方案

You can use ADC in conjunction with ADD to do add something to a 64-bit integer stored in 2 32-bit registers.

You can use SHLD in conjunction with SHL to shift left a 64-bit integer stored in 2 32-bit registers.

If you can do 64-bit addition and 64-bit shifting, you can easily do multiplication of a 64-bit integer by 10 (hint: 10=8+2, x*10=x*8+x*2).

You'll likely need it in order to read 64-bit integers from the console. You'll need to read them as ASCII strings and then convert into 64-bit integers using repeated multiplication by 10 and addition (hint: 1234 = (((0+1)*10+2)*10+3)*10+4).

The above should be enough info to read 64-bit integers and add them.

In order to print the sum you'll need to have 64-bit division by 10, so you can convert a 64-bit integer into an ASCII string decimal representation of it (hint: 4=1234 mod 10 (then 123 = 1234 / 10), 3 = 123 mod 10 (then 12 = 123 / 10), 2 = 12 mod 10 (then 1 = 12 / 10), 1 = 1 mod 10 (then 0 = 1 / 10, stop)).

I'm not going to explain now how to do 64-bit division by 10 using 2 DIVs. Get the rest working first.

这篇关于我们可以用两个32位章(32 + 32 = 64)在同一时间,使其能够承担64位值?汇编语言8086的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 16:11