View previous topic :: View next topic
|
Author |
Message |
karthi_ind
Active User
Joined: 24 Feb 2004 Posts: 131 Location: Chennai
|
|
|
|
Hi,
Could you help me out on this.
Display the two's complement value from 1 to n numbers thru assembler program. Pls guide me on this. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
since this not something we usually do/have done we would need to do it just for Your sake
review the TWO complement notation for short numbers ( 4 bits , 0 to 15 ) doing it by pencil and paper
after that expand the logic to longer number |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Is this a binary number?
You might try multiplying n by -1 (negative one) and see if the result is what you want. . . |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
For register usage, with a positive number in Rx (R14 in this example), review the LCR (Load Complement Register) instruction.
EG:
Code: |
LA R14,15 LOAD WITH X'0000000F'
LCR R15,R14 LOAD WITH TWO'S COMPLEMENT (R14 PRESERVED)
|
Bill |
|
Back to top |
|
|
|