if结构和switch结构用于根据条件选择执行不同的语句块;

while,do-while和for结构用于根据条件循环执行一段代码;

对象是一种复合数据类型,可以将多种数据类型集合在一个数据单元内,并允许通过对象名来存取这些数据;同时,对属性(也就是对象的数据,相当于变量)也可以通过方法(相当于函数)进地处理;方法也可以通过对象名进行调用。

所以对象是一种比较实用、合理的数据结构;

对象也可以理解为一个数据(属性),函数(方法)的集合;

system bus

Physically,a bus is a set of wires.The components of the computer are connected to the buses.To send information from one component to another,the source component outputs data onto the bus.The destination component then inputs this data from the bus.As the complexity of a computer system increases,it becomes more efficient(in terms of minimizing connections) at using buses rather than direct connections between every pair of devices.Buses use less space on a circuit board and require less power than a large number of direct connections.They also require few pins on the chip or chips that comprise the CPU.

When the cpu reads data or instruction from or writes data to memory,it must specify the address of the memory location it wishes to access.It outputs this address to the address bus;memory inputs this address from the address bus and use it to access the proper memory location.Each I/O devices,usch as a keyboard,monitor,or disk device,has a unique address as well,when accessing an I/O device,the cpu places address of the device on the address bus.Each bus can read the address off the bus and determine whether it is the device being access by the cpu.Unlike the other buses,the address bus always receives data form the cpu,the cpu never reads the address bus.

Data is transfered via the data bus.When the cpu fetches data from memory,it first outputs the memory address on its address bus.Then memory outputs the data onto the data bus,the cpu can then read the data from the data bus.When writing data to memory,the cpu first outputs the address onto the address bus,then outputs the data onto the data bus.The memory then reads and stores the data at proper location.The processes for reading data from and writing data to the I/O devices are similar.

The control bus is different from the other two buses.The address bus consists of a lines,which combine to transmit one -bit address value.Similarly,the lines of the data bus work together to transmit a single multi-bit value.In contrast,the control bus is a collection of individual control signals.These signals indicate whether data is to be read into or written out of the cpu,whether the cpu is accessing memory or an I/O devices or memory is ready to transfer data.The control bus is really a collection of (mostly) undirectional signals.Most of these signals are output from the memory and I/O subsystems,although a few are output by these subsystems to the cpu.

A system may have a hierarchy of buses.for example,it may use its address,data and control buses to access memory,and an I/O controller.The I/O controller,in turn,may access all I/O devices using a second bus,often called an I/O bus or a local bus.

The control unit of CPU

It uses an instruction pointer to keep track of the sequence of instruction that is supposed to be processed.Using the pointer as a guide,the control unit retrieves each instruction in sequence from RAM and places it in a special instruction register.The control unit interprets the instruction to find out what needs to be done.According to its interpretation,the control unit sends signals to the data bus to fetch data from RAM,and to the ALU to perform a process.

Data are brought into the ALU by the control unit and the ALU performs whatever arithmetic or logical operations are required to help carry out the instructions.

Registers

A register is a storage location inside the processor.Rigisters in the control unit are used to keep track of the overall status of the program that is running.Control unit registers store information such as the current instruction,the location of the next instruction to be executed,and the operands of the instruction.In the ALU,registers store data items that are added,substracted,multiplied,divided,and compared.Other registers store the results of arithmetic and logical operations.

The fetch and execute cycles

At the beginning of each instruction cycle the cpu fetches an instruction from memory.In a typical cpu,a register called the program counter(PC) is used to keep track of the next instruction in sequence.So,for example,consider a computer in which each instruction occupied on 16-bit word of memory,assume that the program counter is set to location 300.The cpu will next fetch the instruction at location 300.On succeeding instruction cycles,it will fetch instruction from location 301,302,303 and so on.

The fetched instruction is loaded into a register in the cpu known as the instruction register.The instruction is in the form of a binary code that specifies what action the cpu is to take.The cpu interprets the instruction and performs the required action.In general these actions fall into four categoies:

1 cpu-memory:Data may be transferred from the cpu to memory or from memory to cpu;

2 cpu-I/O:Data may be transferred to or from the outside world by transferred between the cpu and an I/O module.

3 Data processing:the cpu may perform some arithmetic or logic operation on data;

4 contrl.

A computer contains a system clock that emits pluses to establish the timing for system operations.The time to complete an instruction cycle is measured in megahertz(mHz) or millions of cycles per second.

Word size

Refers to the number of bits that the central processing unit can manipulate at one time.Word size is based on the size of the registers in the cpu and the number of data lines in the bus.For example,a cpu with an 8-bit word size is referred to as an 8-bit processor it has 8-bit register and manipulates 8-bit at a time.

Accessing memory

The instruction cycle is the procedure a microprocessor goes through to process.First the microprocessor fetches,or reads,the instruction from memory.Then it decodes the instruction,determining which instruction it has fetched.Filally,it performs the operations necessary to execute the instruction.Each of thes function-fetch,decode,and execute-consists of a sequence of one or more operations.

Let's start where the computer starts,with the microprecessor fetching the instruction from memroy.First,the microprocessor places the address of the address of the instruction on to the address bus.The memory subsystem inputs this address and decodes it to access the sured memory location.

After the microprocessor allows sufficient time for memory to decode the address and access the requested memory location.The microprocessor asserts a READ control siganl.The READ signals a signal on the control bus,which the microprocessor asserts when it is ready to read data from memory or an I/O device.Some processor have a different name for this signal,but all microprocessors have a signal to perform this function.Depending on the microprecessor,the READ signal mya be active high(asserted-1) or active low(asserted-0).

When the READ siganl is asserted the memory subsystem places the instruction code to be fetched onto the computer system's data bus the microprocessor then inputs this data from the bus and stores it in one of its internal registers.At this point the microprocessor has fetched the instruction.

Next the microprocessor decodes the instruction.When the microprocessor decodes the instruction,it determines which instruction it is in order to select the correct sequence of operations to perform.This is done entirely within the microprocessor,it does not use the system buses.

Finally,the microprocessor executes the instruction.The sequence of operations to execute the instruction varies from instruction to instruction.The execute routine may read data from memory,write data to memroy,read data from or write data to an I/O device,perform only operations within the cpu,or perform some combination of these operations.

The symbol,CLK,is the computer system clock.The microprocessor uses the system clock to synchronize its operations.The microprocessor places the address onto the bus at the biginning of a clock cycle.One clock cycle later to allow time for memory to decode the address and access its data the microprocessor asserts the READ signal.This causes memory to place its data onto the system data bus.During this clock cycle,the microprocessor reads the data off the system bus and stores it in one of its registers.At the end of the clock cycle it removes the address from the address bus and cancel the READ signal.Memroy then removes the data from the data bus completing the memory read operation.

The processor places the address and data onto the system buses during the first clock cycle of the memory WRITE operation.The microprocessor then asserts a WRITE control signal(or its equivalent) at the start of the second clock cycle.Just as the READ signal causes memeory to read data,the WRITE triggers memeory to store data.Sometime during this cycle,memory writes data on the data bus the memory location whose addess is on the address bus.At the end of this cycle the processor completes the memory write operation by removing the address and data from the system buses and canceling the WRITE signal.