Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Two's complement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: Two's complement
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Sun Oct 03, 2010 7:51 pm    Post subject: Reply to: Two's complement
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

Site Director


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

PostPosted: Sun Oct 03, 2010 10:28 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Oct 04, 2010 12:58 am    Post subject: Reply to: Two's complement
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting a 9's complement by comparing... venkatatcts DFSORT/ICETOOL 1 Sat Nov 14, 2009 1:33 pm
No new posts Need to Sort field that are in 9's co... fareed DFSORT/ICETOOL 2 Wed Mar 29, 2006 1:19 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us