We help IT Professionals succeed at work.

on
Hi,

I'm trying to read some spec for an emulator, and I've come across this sentence:

"The machine is word addressable and has a memory of 600 words, each consisting of 4 decimal digits"

What is a word though? I'm interpreting that like:

memory[600];   // memory is a type that can hold numbers 0 - 9999.

but that's not like any data type I've heard of (char, short, int, float, double) don't have such a range definition. Am I missing what this is? (well I know I am, can anyone explain?)

Thanks
Comment
Watch Question

## View Solution Only

CERTIFIED EXPERT
Top Expert 2012

Commented:
A "word" is usually defined as "a group of bits or digits/characters processed as a unit" (see also http://en.wikipedia.org/wiki/Word_%28computing%29) . To quote that article further

"The size of a word is reflected in many aspects of a computer's structure and operation. The majority of the registers in the computer are usually word-sized. The typical numeric value manipulated by the computer is probably word sized. The amount of data transferred between the processing part of the computer and the memory system is most often a word. An address used to designate a location in memory often fits in a word"

So, a 32bit system has a word size of four bytes, 1 1bit one of two etc.
CERTIFIED EXPERT
Top Expert 2009

Commented:
That doesn't explain why a word on this machine consists of 4 decimal digits ... Is this an actual machine ? (which ?) Or is this just a theoretical exercise ?
Data Warehouse / Database Architect
CERTIFIED EXPERT
Commented:

Emulator.  Now THERE's a word that I've gotten to know well in recent years, having written several.  :)

>> The machine is word addressable and has a memory of 600 words, each consisting of 4 decimal digits.

This suggests to me that the machine does a form of BCD math, as that's pretty typical of machines that natively operate on character (ASCII, EBCDIC, etc.) data.  IBM built an entire industry doing character based math, though they support a lot more than just those two types.

Memory therefore probably looks like:

unsigned char Memory[600][4];

"Word addressable" suggests that memory is accessed via Memory[word] and is transferred to/from a CPU register 4 bytes at a time.  The emulator (and hardware implementation) can not access memory as Memory[word][byte].

Good Luck,
Kent
CERTIFIED EXPERT
Top Expert 2009

Commented:
I would assume that if it's BCD, then it's 2 bytes per word, and not 4 (ie. 2 decimal digits per byte - 1 decimal digit per nibble).

Commented:
It may well be a real machine, but this is just an excercise from a brain teaser book. I guess they mean:

unsigned char [600][4] cause the grammar that goes along with it comes in blocks like:

1004
9049

and they say you ignore the first character and the last three characters are the memory address. Then they go on to show how this is out of memory range:

2780

->   780 > 600

Yeah............
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> but this is just an excercise from a brain teaser book.

That's what I thought :) It sounded a bit too theoretical heh. 600 words of main memory is a bit small for most practical uses.

>> I guess they mean:
>>
>> unsigned char [600][4]

Not necessarily, because they didn't relate the decimal digits to bytes. There might be 2 digits per byte of 8 bits. Or maybe a byte is only 4 bits wide ... Maybe the machine uses some kind of 10-state storage cell, instead of a binary one (as long as we're dealing with a theoretical exercise, why not ;) )

My point is that the actual storage apparently doesn't matter, so a more accurate way to model the memory is probably something like this :

decimal_digit word[4];
decimal_digit memory[600][4];

where decimal_digit is a type that can hold a decimal digit.
CERTIFIED EXPERT
Top Expert 2012

Commented:
Well, then the term "a group of bits or digits/characters processed as a unit" also applies ;o)
CERTIFIED EXPERT
Top Expert 2009

Commented:
Sure jkr ... I just wanted to go a bit deeper into this ... ;)

Commented:
four decimal digits, that could be done with a 16-bit word. Use 4 bits per digit.

CERTIFIED EXPERT
Top Expert 2009

Commented:
>> four decimal digits, that could be done with a 16-bit word. Use 4 bits per digit.

I think that has already been mentioned ;)
Data Warehouse / Database Architect
CERTIFIED EXPERT

Commented:

Hi Infinity,

I stand by the 600x4 configuration based on the term 'decimal digits', though nothing is certain as this is merely an exercise..

Had "packed decimal" (or similar) been intended, I feel sure that it would have been indicated.

Kent