Docsity

Computer Architecture Cheat Sheet, Cheat Sheet of Computer Architecture and Organization

Toggle sidebar
bg1
Computer Architecture summary 1
Cheat Sheet
Progra๎˜mming I/O Devices
What is I/O?
I/O is the commun๎˜ication between an inform๎˜ation processin g system, such as a computer, with the outside world, possib ly a human or another system.
Inputs are signals or data received by the system, and outputs are signals or data sent by it.
What are the components of I/O device?
There are 2 main components of I/O Device: Hardware Interf๎˜ace and Internal Struct๎˜ure.
What is hardware structure?
Hardware Structure is the device interface. it represents the interface used by the system to control the device, and every de vice has an inte๎˜rface and
a prot๎˜ocol for typical intera๎˜ction.
How many registers are used in the hardware of an I/O de vice?
There are 3 registers in use: Status Regist๎˜er, used to get the status of the device, Command Regist๎˜er, used to tell the device to perform a certain
task, and Data Regist๎˜er, used to pass data to the device, or ge t data from the device.
What is internal structure of an I/O device?
Internal Structure is the device abstract implem๎˜ent๎˜ation, it is devic e specif๎˜ic(๎˜meaning it depends on the device itself). Simple dev ices need one or few
hardware chips to implement their functi๎˜ona๎˜lity, while more complex devices need a simple CPU(also called a micro-๎˜con ๎˜tro๎˜ller), a general purpose
memory๎˜(either DRAM, SRAM or both), and device spe cific chips to get their jobs done.
Why are I/O slow
They are slow for 3 reasons:
1- They are the main way of intera๎˜ction between the user and the computer, so they can be as fast as the user.
2- Their signal is analog and need to be converted to digital.
3- They depend on mechanical movements which is slow com pared to digital signals.
What 2 components each I/O device need?
Each I/O device must have: a buffer and a s tatus regist๎˜er .
Define a buffer?
A buffer is a sequence of memory locations, its size depends on the I/O device, it is used to hold data tempor๎˜arily until it is pr ocessed by the CPU.
Define the status register?
It is a sequence of bits, its size depends on the I/O device, it is u sed to report the status of the I/O to the CPU?
What is the most important bit in the status register?
The most important bit is the ready bit.
pf3
pf4

Partial preview of the text

Download Computer Architecture Cheat Sheet and more Cheat Sheet Computer Architecture and Organization in PDF only on Docsity!

Computer Architecture summary 1

Cheat Sheet

Programming I/O Devices

What is I/O? I/O is the communication between an information processing system, such as a computer, with the outside world, possibly a human or another system. Inputs are signals or data received by the system, and outputs are signals or data sent by it.

What are the components of I/O device? There are 2 main components of I/O Device: Hardware Interface and Internal Structure.

What is hardware structure? Hardware Structure is the device interface. it represents the interface used by the system to control the device, and every device has an interface and a protocol for typical interaction.

How many registers are used in the hardware of an I/O device? There are 3 registers in use: Status Register , used to get the status of the device, Command Register , used to tell the device to perform a certain task, and Data Register , used to pass data to the device, or get data from the device.

What is internal structure of an I/O device? Internal Structure is the device abstract implementation, it is device specific(meaning it depends on the device itself). Simple devices need one or few hardware chips to implement their functionality, while more complex devices need a simple CPU(also called a micro-controller), a general purpose memory(either DRAM, SRAM or both), and device specific chips to get their jobs done.

Why are I/O slow They are slow for 3 reasons: 1- They are the main way of interaction between the user and the computer, so they can be as fast as the user. 2- Their signal is analog and need to be converted to digital. 3- They depend on mechanical movements which is slow compared to digital signals.

What 2 components each I/O device need? Each I/O device must have: a buffer and a status register.

Define a buffer? A buffer is a sequence of memory locations, its size depends on the I/O device, it is used to hold data temporarily until it is processed by the CPU.

Define the status register? It is a sequence of bits, its size depends on the I/O device, it is used to report the status of the I/O to the CPU?

What is the most important bit in the status register? The most important bit is the ready bit.

Programmed I/O Technique

What is the protocol of programmed I/O technique? The protocol has 4 steps: 1- poll the device to see if it's ready to receive a command(this is done by repeatedly reading the status register). 2- The OS sends data to the data register.{{n}} 3- The OS writes a command to the command register, this also implicitly tells the device that the data is present in the data register and that it should begin working on the command. 4- The OS waits for the device to finish by again polling it in a loop to see if it has finished(it may then get an error indicating a success or a failure).

When do we call something PIO(programmed I/O)? We call it PIO when the CPU is involved in the movement of the data.

What are the advantages of PIO? This technique is simple and working.

What are the disadvantages of PIO? This technique wastes a great deal of CPU time just waiting for the potentially slow I/O device to complete its activity.

Write the corresponding Assembly code for (cin >> x) using Programmed I/O method. NotReady: IN AL , StatusD1 โ†’ The status register of Device # AND AL , MaskD JZ NotReady IN AL , BufferD1 โ†’ The Buffer of Device # MOV X , AL

Write the corresponding Assembly code for (cout<<x) using Programmed I/O method. NotReady: IN AL , StatusD AND AL , MaskD JZ NotReady MOV AL , X OUT BufferD2 , AL

Interrupt Driven Technique

What is an interrupt? An interrupt is a signal emitted to the processor by software or hardware, to indicate that there is an event(which is temporary) that requires immediate attention.

How does the processor responds to an interrupt? It responds by suspending its current activities , saving its state , and executing a special function called interrupt handler or Interrupt service routine.

What do we mean by interrupt service routine? Interrupt Service Routine(ISR): is a special function that is called when there is an interrupt, this function is called by the processor and not the programmer.

What values do we need to save when an interrupt happens? The typical values include: condition code flags((flag registers) and contents of any register used by both the interrupted program and ISR

Interrupt Driven Technique (cont)

What does each ISR takes 4 bytes in the IVT? it takes 4 bytes because each ISR address is made of:

- code segment register(16 bit or 2 bytes) - Instruction Pointer(16 bit or 2 bytes).

What is the use of CLI and STI commands?

- CLI clears the IF(interrupt flag) , by setting it to zero and thus interrupts are disabled - STI sets the IF(interrupt flag) , by setting it to 1 and thus interrupts are enabled.

What is the 8259A? It is a PIC (Programmable Interrupt Device), which allows us to have more than 2 levels of interrupts (It allows to have up to 255 levels), it works by combining multiple interrupt inputs into one output which connects to microprocessor.

What are the main pins in 8259A?

- D0-D7: Bidirectional Data connections. - IR0-IR7: Interrupt request inputs. - INT(Output): Connects to the microprocessor INTR pin. - INTA(Input): connects to the microprocessor INTA pin.

Q / Write a program in interrupt driven to convert cin >> x to Assembly code, presume that the device we are dealing with is a keyboard, and is device0 ( D0 ) ISRD0: ; Interrupt Service Routine for device 0 CLI ; Clear Interrupt Flag (Set it to zero and don't allow interrupts) PUSH AX ; Put the value of AX into the stack IN AL, BUFFD0 ; Put the value of the buffer of device 0 into AL MOV X, AL ; Put the value of AL into X POP AX ; Take out the value of AX from the stack STI ; Set Interrupt Flag (Set it to one and allow interrupts) IRET ; Interrupt Return (This pops the value of IP, CS and Flags from the stack)