Question

In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump should not contain a reference to M, and vice versa. Dis...

  • In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump should not contain a reference to M, and vice versa. Discuss why this should be avoided.

Research the concept of interrupts in a computer. You may want to look into how the Z80 microprocessor handles interrupts. A good source of Z80 information is the Rodnay Zaks book, "How to Program the Z80."

FYI, The Z80 8 bit microprocessor has been in production for forty years. Knowledge of the Z80 is a great lead in for further study in more complicated machines.

Please don't copy past.

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump should not contain a reference to M, and vice versa. Dis...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT