Hack Machine Language

Hack Machine Language is used in Hack Computers. Hack Machine Language have two type of instructions-

  • 16-bit A- instructions.
  • 16-bit C-instructions.

Hack Computer Understands three registers-

  • M(Selected register) represents the RAM register addressed by A.
  • A register
  • D register

A-instruction -

@21 //This instruction sets A=21 and RAM[21] becomes selected register which then is M=RAM[21].

A-instruction use @x and select x location from RAM and sets that to M.

C-instruction --

Semantics - dest = comp ; jump {dest and jump are optional}

Here dest stands for destination, comp stands for computation and jump means jump directive.

Here after computing we can do one of two things either to store the computed value in destination or can jump to some instruction.

we should not contain a reference to M in jump because it causes a conflicting use of A as A selects RAM register which sets M. and if we jump to M then it would be conflicting.

Interrupts-

An interrupt in a computer is a signal which needs immediate attention for execution emitted by hardware or software. Its priority is high so whatever the processor is doing if an interrupt occurs it stops its current work , save its state and call interrupt handler. after completing the execution of interrupt it resumes its work.

Basically interrupt Handler function is used by operating system to prioritize all the occuring interrupts and saves them in queue and executes them in their given priority order as computer can perform one instruction at a single time.

Two types of interrupts are there-

  • Hardware interrupts - it occurs when some I/o Operation completes like reading or writing
  • Software interrupts. - it occurs when some software finishes its execution or is demanding some resourses for its completion.

Z80 -

Z80 MPU implements the function of CPU within one chip, ,ALU, its internal registers and a control unit as a part of its architecture.

It creates three buses an 8-bit bidirectional data bus, 16-bit unidirectional address bus and a control bus.

Interrupts provide the mechanism by which the Z80 can process asynchronous events such as timers, sensor input and peripheral communication.

When an interrupt is received the Z80 executes a sub-routine known as an Interrupt Handler.

The Z80 microprocessor supports three interrupts modes; 0, 1, and 2.

In interrupt mode 0 the Z80 gets an instruction from the data bus and executes it. This instruction resets the Z80 to a specific location given by that instruction.

In interrupt mode 1 the Z80 jumps to some address where it runs a routine implemented by programmer. For this to happen-

  • Interrupts must be enabled.
  • Your peripheral must be connected to the /INT input on the Z80.
  • An interrupt routine must be programmed at the correct place in memory.

In interrupt mode 2 the Z80 gets a byte from the data bus and jumps to the 16-bit address formed by combining the ‘I’ (interrupt vector) register and the supplied byte from the peripheral.

Want latest solution of this assignment