Registers are storage locations internal the the processor. CPU instructions operate on these values directly. On RISC processors, all data must be moved into a register before it can be operated. On CISC (Intel) chips, there are a few operations that can load data from RAM, process it, and save the result back out, but the fastest operations work directly with registers.
Each register also has a size that determines the maximum amount of data that can be processed at a time. The registers on Pentium chips, for example, are 32 bits.
Finally, there are generally only a few registers available on a processer. Intel chips, for example, have 6 general purpose registers, and several specialized registers including a base register, stack register, flags register, program counter, and some addressing registers.
Memory, or RAM, is located external to the CPU. Generally speaking, data has to be loaded into a CPU register from memory before the CPU can process it, RAM is much slower than registers, there is a lot more RAM than registers, and generally memory can be addressed on a byte boundaries, where registers may not be able to access all the bytes in a register.
The 32 MIPS registers are partitioned as follows:
Register 0 : $zero always stores the constant 0
Regs 2-3 : $v0, $v1 return values of a procedure
Regs 4-7 : $a0-$a3 input arguments to a procedure
Regs 8-15 : $t0-$t7 temporaries
Regs 16-23: $s0-$s7 variables
Regs 24-25: $t8-$t9 more temporaries
Reg 28 : $gp global pointer
Reg 29 : $sp stack pointer
Reg 30 : $fp frame pointer
Reg 31 : $ra return address
Memory-register operation
The data transfer instruction that copies data from
memory to a register is traditionally called load.
The format of the load instruction is the name of the
operation followed by the register to be loaded, then a constant and register used to access memory.The sum of the constant portion of the instruction and
the contents of the second register forms the memory address.The actual MIPS name forthis instruction is lw, standing
for load word.
Data may be copied to and from memory and registers by a MOV instruction which may transfer 8-bits, 16-bits, or 32-bits of data. Instead of using words like load, store or copy, using MOV or words move of the operation to make a copy of the state of the object at A and overwrites the old state of B in this process. The operands for the MOV commands can either be registers, a segment register or a memory address since the command is executed in a single CPU work cycle.
For example.There is a succession as in:
- move the contents of the memory into the register ax:
MOV ax, [address1]
- also move the contents of the register bx into the register ax
MOV ax, bx
- move the contents of the register ax into the referenced memory block
MOV [address], ax
However, Memory to memory moves, such as
MOV [address1], [address2]
are not possible. To achieve this, MOV must be used in sequence:
MOV ax, [address2] MOV [address1], ax
GOH MENNING B031210149
It was good. The flow of the notes is easy to follow. well, it can be better too. haha
ReplyDeletei can understand well.^^
ReplyDeletewas a good explanation..keep it
ReplyDelete