• Aucun résultat trouvé

Hardware or software; wh ich is best? This question faces many designers when creati ng new systems. This article describes a soft­

ware version of a hardware project detailed in December 1 976 BYTE by J onathan K Mil len in h is article "A Universal Turing Machine, " page 1 1 4.

The universal Turing mach ine (UTM) is elegantly simple an d capable of emu lating the instruction set of any computer. The Turing machine was invented by Alan Turing (1 91 2-1 954) . It is an abstract computing device that contains al l the fundamental properties a computer system must possess and is used to study com puter concepts.

Although difficult to program, its back-to­

basics nature is all uring to anyone interested in the fundamentals of computers.

The un iversal Turing machine designed by j onathan Mil len has two memories: one for program storage and the other for the main storage or "tape." The tape is a sup­

posed ly infinite (but actually 1 024 bits long) memory wh ich is a series of 1 s and Os. A bit on the tape is pointed to by a counter known as the head. A program counter points to a state in the program being exe­

cuted. Each state consists of two instruc­

tions: one to be used if the cu rrent bit under the head of the tape is a 1 , the other if it is a 0. Each instruction con tains fields describing whether to write a 1 or a 0 on the tape, which direction to move the tape (left or right one position), and the address of the next state to be executed.

Each instruction contains the fol lowing information :

Bit 0: Write bit. Write this bit on the tape after the head is adjusted.

Bit 1 : Direction bit. If this is a 0, move the tape to the left;

i{ it is a 1 , move the tape to the right.

Bits 2 th ru 7: Next state. These six bits are the number of the next state to be executed.

The reader is referred to M il len's article for a complete descripti on of the universal Turing mach ine. His design im plements this machine with about 1 5 integrated circuits. The memories are 2 1 02s, the head and program counter are counters, and the control logic consists of various fli p flops, shift registers, clocks and d ecoders. The memories are loaded and examined with switches and a 7 segment l ight emitting d iode (LED). The d esign is capable of executing about 40,000 instructions per second.

A Software Approach

The program in l isting 1 is the logical equ ivalent of M i l l en 's hard ware version for the Motorola 6800 processor. The pro­

gram storage, tape, program co unter and head are parts of the computer's m emory set aside for those purposes. The memory organ­

ization is shown in tabl e 1 . The rest of the logic is program med via the 6800's instruc­

tion set. Table 2 is a comparison of the various fu nctions and their implementation in the two approaches.

The program is a relatively straightfor­

ward program ming of the hardware version . The basic cycle of functions to be performed is:

Test the bit on the tape under the head .

Write a 1 or 0 according to the write bit of the instruction ind icated by the program counter and the tape bit.

Move the tape (adjust the head) accord ing to the instruction's direc­

tion bit.

Set the program cou nter equal to the add ress specified by the address bits of the instruction.

Go back to the first step.

Since the 6800 is a byte oriented machi ne, the head must keep track of both a byte in memory and a bit within the byte. The

Tinker, Tailor, Soldier, Sailor . . . Doctor, Lawyer . . . the Chieftain's here.

No matter whether you're a serious hobbyist or a serious busi nessman , the Chieftain 6800 microcomputer with ca­

pabilities that surpass the �-80 is made for you.

S m o k e S i g n a l ' s q u a l i t y - p a c k e d Chieftain I features two 5.25-inch mini­

floppy drives and Chieftain II fea-tures two 8-inch floppy drives.

B o t h m i c r o c o m p u t e r s provide 32K static memory, two serial I/ 0 ports, a 2 MHz processor board, a 2K RAM monitor, a nine-slot motherboard with built­

in baud rate gene rator and gold connectors for h i g h r e [ i a b i l i t y . T h e Chieftain's stylish leath­

er-grained cabinet houses the above with its own cooling fan and regulated power supply.

E v ery C h i e ft a i n i s c o m p l e t e w i th system software and is totally burned-in as well as tested to further insure high relia ility.

And it's expandable to 64K memory w i th u p to 2 m e g a b y t e s f l o p p y d i s k storage.

S o see you r nearest S m oke S i gnal dealer, he'll be glad to show you how to get your wampum's worth. Systems

start at $2,595.

- - - -1

D Send information on your Chieftain I

microcomputer I

D Send name of nearest dealer 1 Name ______ -=--------

-Address'

---Company

---=---City ___ _:___ ________ _ I I I I I I

State/Zip I I

• SIDlE SIGNIL l

� BRDIDCISTING

3�336 Via Colinas. Westlake Village. I

I

.

...::��:

a

��

6

!_:�

1

� �::��--�

Dealer inquiries invited.

Smoke Signal Broadcasting, 3 1 336 Via Colinas, Westlake Village, CA 9 1 36 1 , (213) 889-9340

Circle 320 on inquiry card. BYTE December 1978 27

Listing 7: 6800 assembler version of the universal Turing machine, which im­

itates the hardware version built by jonathan Millen.

This program is capable of executing 70,000 uni­

versal Turing machine in­

structions per second.

Address Code Label Op Code Operand Commentary

0200

28 Decemb<r 1978 © BYTE Publications Inc R O L A

The logic to test the current bit is:

TEST LDX H EAD Load head byte

mented. The procedure is similar for moving the tape l eft.

The universal Turing m achine program is stored in the first 1 28 bytes of memory. accomplished by the rotate left i nstruction :

Before shift 0 0 1 0 1 .0 0 1 = decim al � 1 state type, the two designs provide some insights into the benefits and costs of each approach . The most significant benefit of the hard­

ware approach is speed . The program can only process 1 0,000 universal Turing ma­

chine i nstructions per second, or 25 percent of the circuit's capability.

The most significant benefit of the soft­

ware approach is its flexibility. For example, suppose the address field of the instruction

Hexadecimal

Addresses Use

0000 thru 007F Universal Turing machine pro-0080 thru OOFA gram and state storage area.

Universal Turing machine tape storage area.

OO FB thru OOFC Universal Turing machine pro-gram counter address of next state.

OOFD Tape head mask.

OOF E thru DOFF Tape head address.

0200 thru 0237 6800 interpreter program (listing 1 ) .

Table 7: Memory allocation for the software implementation of the universal Turing machine.

North Star Systems