From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,131bcd57bbc7fdae X-Google-Attributes: gid1164f8,public From: john@yrsk.demon.co.uk (John Laird) Subject: Re: EDIV instruction Date: 1995/12/06 Message-ID: <1995Dec6.094220.2647@yrsk.demon.co.uk>#1/1 X-Deja-AN: 121039825 x-nntp-posting-host: yrsk.demon.co.uk references: <4a2bre$lq1@www.uno.edu> organization: Yezerski Roper Ltd newsgroups: comp.sys.dec 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"