• No se han encontrado resultados

Análisis comparativo de ensayos de tracción

ANÁLISIS DE RESULTADOS

3.1 Análisis comparativo de ensayos de tracción

The following table represents what happens as the computer begins running. Each row represents the contents of the registers (written in hexademical) at the beginning of a clock pulse, in which the computer performs either the fetch or execute process.

PC IR AC action

00 00 00 The computer automatically starts with zero in each of its registers. 00 85 00 Fetch: CPU fetches the memory at address PC

into IR.

01 85 07 Execute LOAD: CPU fetches the memory at address

into AC and places PC

into PC.

01 C5 00 Fetch: CPU fetches the memory at address PC

into IR.

02 C5 0E Execute ADD: CPU adds the memory at address

into AC and places PC into

PC.

02 C5 0E Fetch: CPU fetches the memory at address PC

into IR.

03 C5 15 Execute ADD: CPU adds the memory at address

into AC and places PC into

PC.

03 A6 15 Fetch: CPU fetches the memory at address PC

into IR.

04 A6 15 Execute STORE: CPU stores AC

15

into memory at address

and places PC into PC.

04 00 15 Fetch: CPU fetches the memory at address PC

into IR. 04 00 15 Execute HALT: CPU does nothing.

04 00 15 Fetch: CPU fetches the memory at address PC

into IR. 04 00 15 Execute HALT: CPU does nothing.

..

. The computer continues fetching the same HALT instruction and doing nothing. It has stopped performing useful computation.

What the computer has accomplished here is to take the number at M

, add M

to it, and add M

again, placing the result into M

. Since we had at M

, the program placed 21 15 into M before it halted.

5.2

Machine language features

So far, we have seen how the computer executes a straightforward program. In this section we’ll consider more complex programming features that enable us to build more sophisticated programs with HYMN.

5.2.1 Input and output

While our program to place three times the contents of memory at address 5 into memory at address 6 is nice, it would be even better if could have a program that interacts with the user. To accomplish this, we’ll modify HYMN’s structure to include two new components — a keypad and a display — attached to the bus.

central processing

unit (CPU)

random access

memory (RAM) display

addr 30 addr 31 addr 0-29

bus

keypad

We dedicate a memory address to each of these devices: The keypad gets address 30, and the display gets address 31. RAM will not respond to these addresses.

When the CPU sends a request to load information from address 30 onto the bus, RAM doesn’t respond. Instead, the keypad waits until the user types a number, and it sends that number to the CPU via the bus as its response. Similarly, when the CPU sends a request to store a number to address 31, the display handles the request (by showing the number on the screen).

The following program reads a number from the user and displays on the screen.

addr value op data

0 10011110 (9E ) LOAD 30 1 10100110 (A6 ) STORE 6 2 11000110 (C6 ) ADD 6 3 11000110 (C6 ) ADD 6 4 10111111 (BF ) STORE 31 5 00000000 (00 ) HALT — 6 00000000 (00 ) 0

It works by loading into AC a number the user types on the keypad (instruction 0), then storing this number in

M

(instruction 1). Then it adds M

to the accumulator twice (instructions 2 and 3); now AC holds . It

stores AC in M

(instruction 4) which effectively displays on the screen, before halting (instruction 5).

5.2.2 Loops

HYMN includes three instructions that are useful for writing programs to perform a process repeatedly: JUMP, JPOS, and JZER. The JUMP instruction works by placing the

of the instruction into the PC; thus, in the next fetch-execute cycle, the computer will fetch and then execute the instruction at the address given in the JUMP instruction. The effect of this is that the computer jumps to the instruction mentioned in the

of the JUMP instruction, rather than merely continuing to the next instruction as with the LOAD, STORE, and ADD instructions.

The JPOS (“jump if positive”) and JZER (“jump if zero”) instructions are similar, except that for these the CPU will copy

into PC only if the AC holds a positive number (for JPOS) or zero (for JZER). Otherwise, the CPU will increment PC so that the next instruction executes.

The following program, which uses the JPOS instruction, displays the numbers from 10 down to 1.

addr value op data

0 10011110 (9E ) LOAD 6 1 10111111 (BF ) STORE 31 2 11100101 (E5 ) SUB 5 3 01100001 (61 ) JPOS 1 4 00000000 (00 ) HALT — 5 00000001 (01 ) 1 — 6 00001010 (0A ) 10

To understand this program, let’s trace through the process of HYMN executing it. PC IR AC action

00 00 00 The computer starts with zero in each register. 00 9E 00 Fetch: CPU fetches the memory at address PC

into IR.

01 9E 0A Execute LOAD: CPU fetches the memory at address

into AC and places PC

into PC.

01 BF 0A Fetch: CPU fetches the memory at address PC

Documento similar