This is Register.m in view mode; [Download] [Up]
//
// Register
//
// An Objective-C class for simulating computer registers.
//
#import "Register.h"
@implementation Register
- initNumBits:(int)nbits
in:innode // Where it gets its data.
out:outnode // Where it puts its data.
load:loadnode // Load signal.
{
[super initNumBits:nbits]; // Call Node method.
INITDEVTYPE("Register");
TESTNODE("IN", innode, numbits); // Test the interface nodes to make sure
TESTNODE("OUT", outnode, numbits); // they are the right sizes.
TESTNODE("LOAD", loadnode, 1);
IN = innode; // Remember our interface nodes.
OUT = outnode;
LOAD = loadnode;
return self;
}
- cycle
{
int i;
bit *inbits = [IN getBits];
if(*([LOAD getBits])) // If we are supposed to load,
for(i = 0; i < numbits; i++)
data[i] = inbits[i];
[OUT setBits:data]; // Set out output node's bits to register value.
return self;
}
@end
//
// End of file.
//These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.