Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

2's Complement, is it implemented in Compiler or Hardware

Status
Not open for further replies.

tia_design

Advanced Member level 4
Joined
Feb 22, 2005
Messages
113
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,298
Activity points
2,210
32's 2's complement is 00100000
25's 2's complement is 00011001
-25's 2's complement is 11100111

2's complement subtraction, like 32 - (-25), it will be finally converted into addition in computer as 2's complement like 00100000 + 00011001. Is this converstion made by compiler or in hardware?
I'm going to design a microcontroller, in my assembly language, for 32 - (-25), should I directly write 00100000 + 00011001? or should I write 00100000 - 11100111, and design some hardware in microcontroller to convert it into addtion? Thanks!
 

santoshl

Junior Member level 2
Joined
Aug 14, 2007
Messages
24
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,283
Activity points
1,427
hi,
As per my knowledge subtration and additon are both done in hardware itslef.Hence, 2's compilment should also be done in hardware.
Its quite easy to impelent tht. If u find it difficult to do tht plz let me know, i will help u out.

SantoshL
 

onlymusic16

Full Member level 2
Joined
Sep 19, 2007
Messages
129
Helped
8
Reputation
16
Reaction score
5
Trophy points
1,298
Activity points
1,959
Re: 2's Complement, is it implemented in Compiler or Hardwar

Hi,

2's complement will be implemented in hardware, hence write your assembly code accordingly.
 

A.Anand Srinivasan

Advanced Member level 5
Joined
Oct 15, 2005
Messages
1,804
Helped
257
Reputation
514
Reaction score
39
Trophy points
1,328
Location
India
Activity points
10,680
Re: 2's Complement, is it implemented in Compiler or Hardwar

2's complement would be implemented in hardware itself because it is needed for subtraction....
 

vlsi_freak

Full Member level 2
Joined
Sep 3, 2007
Messages
129
Helped
14
Reputation
28
Reaction score
8
Trophy points
1,298
Activity points
2,054
Re: 2's Complement, is it implemented in Compiler or Hardwar

Hi.

When designing controllers we will be having Arithmetic and Logic circts. We will be implementing ADDER. Now ahardware designer will always try to reduce hardware. He will not go for seperate hw's for adders, subractors. He will try to do add/sub using the same logic, and sub using 2's compl method is simply doing that.

Hope it helps.

Thanks
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top