up to date 
HomeProjectsTagsMembersGroupsHelp

Twos Complement

OverviewWikiNewsVersionsLatest

Project Description

Twos Complement demonstrates twos complement arithmetic as implemented in logic registers. Registers operations, including basic arithmetic and logical functions, are implemented with boolean operations without use of numbers.

A BitRegister represents on single-bit register with a value (set or not set) and a carry bit. A TwosComplementRegister uses a collection of single-bit registers to form a register of arbitrary width.

A register is not a number, but its current contents can be converted to an integer, and an integer can be stored in a register. A register can accumulate the results of basic arithmetic, shift, and bitwise operations with the contents of another register, maintaining an overflow flag set by the last operation performed. Overflow status is displayed (with trailing $+) in the register printString.

See unit tests for examples.

17 asRegister ==> a TwosComplementRegister with value 17 (00000000000000000000000000010001)

TwosComplementRegister width: 30 value: SmallInteger maxVal ==> a TwosComplementRegister with value -1 (111111111111111111111111111111)

TwosComplementRegister width: 30 value: SmallInteger maxVal + 1 ==> a TwosComplementRegister with value 0 (000000000000000000000000000000+)

Author: Dave Lewis
License: MIT

Members

Creator:Dave Lewis
Admin:Dave Lewis

Tags

learning

License

Code commited to this repository will be automatically under MIT license.

Registration

MCHttpRepository
location: 'http://www.squeaksource.com/TwosComplement'
user: ''
password: ''

Packages

  • TwosComplement

Links

http://www.squeaksource.com/TwosComplement.html
http://www.squeaksource.com/TwosComplement

Global:Read

Statistics

Registered:3 October 2011 4:05:12 am
Total Releases:0
Total Versions:10
Total Downloads:5493
XHTML | CSS | RSS26 April 2024