انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية العلوم للبنات
القسم قسم الحاسبات
المرحلة 2
أستاذ المادة نور كاظم ايوب مهدي المهدي
05/05/2019 21:20:08
3.1 Instruction Formats Operands specify the value an instruction is to operate on, and where the result is to be stored. Instruction sets are classified by the number of operands used. An instruction may have no, one, two, or three operands. Based on the no. of operands in the instruction, we get four instruction formats : 1- Standard format: 2- Two address: 3- Three address: 4-Zero address: these instructions have field only, the operation field. 3.2 Instruction Length instruction length is the number of bits or bytes which defines an instruction. This can be done simply by specifying how many bits in each field.The length of opcode field is Inferred from the No. of instruction supported by the processor to the form 2n , n will be the No. of bits for (opcode field). The length of address field is inferred from memory which is formulated as 2n B or 2n W (30 KW, 256 MB, 1GB…..) n will be the No. of bits in each address Field. For example, if the memory size = 1 KB : 1K = 210 ? n= 10 ? address bits =10
3.3 instruction types Depending on the previous format, we can classify instructions into 4 types. When an expression is executed by the cpu using specific type, it is partitioned into steps each of which formed by the format of this type: 1- Three addresses (operands) In instruction that have three operands, one of the operand specifies the destination as an address where the result is to be saved. The other two operands specify the source either as addresses of memory location or constants. Step No. Step description 1 mul R1,c,b R1? c*b 2 sub R2,r,d R2 ? r-d 3 div x , R1,R2 X ? r1/r2
Sol :
2- Two addresses In this type both operands are sources. But the first operand is used as destination therefore the first operand must be an address in memory, but the second may be an address or a constant.
Step No. Step description 1 mov R1,c R1? c 2 mul R1,b R1 ? R1*b 3 Mov R2,r R2 ? r 4 Sub R2,d R2?R2-d 5 Div R1,R2 R1?R1/R2 6 Mov x,R1 x? R1 Sol:
Note that : a- In this type of instruction we can use (mov) beside the arithmetic operations. b- This method requires more steps than previous method to represent the same instruction. c- For temporary storage use a register. 3- One address Some computer have only one general purpose register, usually called on Ac. It is implied as one of the source operands and the destination operand in memory instruction the other source operand is specified in the instruction as location in memory.
Step No. Step description 1 load r Ac? r 2 Sub d Ac ? Ac-d 3 Store t T ? Ac 4 load c Ac ? c 5 Mul b Ac ? Ac*b 6 Div t Ac ? Ac/t 7 Store x X ? Ac SOL:
Note that : a- In this type of instruction we can use (load) and (store) beside the arithmetic operations. b- This method requires more steps than previous methods to represent the same instruction. c- For temporary storage use a memory location and is not a register. Why?? 4- Zero address Some computers have arithmetic instruction in which all operands are implied, these zero operand instruction use a stack, a stack is a list structure in which all insertion and deletion occur at one end, the element on a stack may be removed only in the reverse of the order in which they were entered. The process of inserting an item is called Pushing, removing an item is called Popping.
Step No. Step description 1 Push d TOS ? d 2 Push r TOS ? r 3 Sub Pop d Pop r Sub them TOS ? (r-d) 4 Push b TOS ? b 5 Push c TOS ? c 6 Mul Pop c Pop b multiply them TOS ? (c*b) 7 Div Pop (c*b) Pop (r-d) Divide TOS ? (c*b) / (r-d) 8 Pop x X ? TOS SOL:
Hint : TOS stands for top of stack.
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|