* Re: EDIV instruction
1995-12-05 5:00 EDIV instruction medcm
@ 1995-12-06 5:00 ` John Laird
1995-12-06 5:00 ` Ron Natalie
1995-12-07 5:00 ` Brian Hibbert
2 siblings, 0 replies; 4+ messages in thread
From: John Laird @ 1995-12-06 5:00 UTC (permalink / raw)
In article <4a2bre$lq1@www.uno.edu>, medcm@uno.edu writes:
> I am currently writing a program in MACRO-32 to run on a VAX system. When
> I use the instruction EDIV R5,R0,R0,R1 , according to the technical specs,
> the computer should take the value R1:R0, a quadword composed of the values
> in R1 and R0, with R1 more significant, and divide it by the doubleword
> value in R5, then store the doubleword answer in R0 and the doubleword
> remainder in R1. However, when I execute that instruction, with R0=0,
> R1=1, and R5=2, instead of returning R1=0 and R0=^x80000000, as it
> seemingly should, it returns R1=0 and R0=0. Is there any explanation for
> this, and are the technical specs that I read correct?
>
Yes, and yes. Your problem is simply that the answer you expected to get
caused an integer overflow - it is too big to fit in a signed longword.
Try setting R5 to 4, you should get ^X40000000.
If you had examined PSL with the debugger, it would have told you that
the V bit was set. The documentation for EDIV states that this occurs
if either {integer overflow} or {divr EQL 0}. Since your divisor was not
zero, overflow had occurred.
--
----
John Laird, Yezerski Roper ( john@yrsk.demon.co.uk ) "Sigs? Gave them up"
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: EDIV instruction
1995-12-05 5:00 EDIV instruction medcm
1995-12-06 5:00 ` John Laird
@ 1995-12-06 5:00 ` Ron Natalie
1995-12-07 5:00 ` Brian Hibbert
2 siblings, 0 replies; 4+ messages in thread
From: Ron Natalie @ 1995-12-06 5:00 UTC (permalink / raw)
medcm@uno.edu wrote:
: I am currently writing a program in MACRO-32 to run on a VAX system. When
: I use the instruction EDIV R5,R0,R0,R1 , according to the technical specs,
: the computer should take the value R1:R0, a quadword composed of the values
: in R1 and R0, with R1 more significant, and divide it by the doubleword
: value in R5, then store the doubleword answer in R0 and the doubleword
: remainder in R1. However, when I execute that instruction, with R0=0,
: R1=1, and R5=2, instead of returning R1=0 and R0=^x80000000, as it
: seemingly should, it returns R1=0 and R0=0. Is there any explanation for
: this, and are the technical specs that I read correct?
I would suspect that you've hit an overflow condition. 1,0000,0000 / 2 is
not representable in a signed dword. 0x80000000 in a signed dword is a
negative number.
-Ron
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: EDIV instruction
1995-12-05 5:00 EDIV instruction medcm
1995-12-06 5:00 ` John Laird
1995-12-06 5:00 ` Ron Natalie
@ 1995-12-07 5:00 ` Brian Hibbert
2 siblings, 0 replies; 4+ messages in thread
From: Brian Hibbert @ 1995-12-07 5:00 UTC (permalink / raw)
To: medcm
medcm@uno.edu wrote:
>I am currently writing a program in MACRO-32 to run on a VAX system. When
>I use the instruction EDIV R5,R0,R0,R1 , according to the technical specs,
>the computer should take the value R1:R0, a quadword composed of the values
>in R1 and R0, with R1 more significant, and divide it by the doubleword
>value in R5, then store the doubleword answer in R0 and the doubleword
>remainder in R1. However, when I execute that instruction, with R0=0,
>R1=1, and R5=2, instead of returning R1=0 and R0=^x80000000, as it
>seemingly should, it returns R1=0 and R0=0. Is there any explanation for
>this, and are the technical specs that I read correct?
>
>
> Michael DeSalvo
> medcm@jazz.ucc.uno.edu
>
>
I got curious about your question and decided to try it with the
debugger. The VAX is behaving as advertised. The values that you are
using are causing an integer overflow (examine the PSL).
Remember that the result of the division is a longword (not an unsigned
long). The value that you were expecting to be stored into R0 has it's
high bit set indicating that the number is negative. Anytime the result
of an operation should be a positive number and the result would be
negative if stored in the destination, an overflow occurs.
Try your program again using a larger divisor an you will get your
expected results.
--
***********************************************
Brian Hibbert b_hibbert@csc32.enet.dec.com
Digital Equipment Corporation
All opinions expressed are my own and should
not be assumed to be the opinion of my employer
^ permalink raw reply [flat|nested] 4+ messages in thread