IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Two's complement


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Sun Oct 03, 2010 7:11 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Oct 03, 2010 7:51 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Oct 03, 2010 10:28 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Oct 04, 2010 12:58 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Sorting a 9's complement by comparing... DFSORT/ICETOOL 1
No new posts Need to Sort field that are in 9's co... DFSORT/ICETOOL 2
Search our Forums:

Back to Top