1 COE 205 - 3 Computer Organization & Assembly Language IntroductionMachine Language
2 Machine LanguageComputers only understand programs in their own machine language. A machine language program written for one type of computers, say a Sun-Ultra 20 machine wont work with another type of computers say an IBM-compatible PC.It is impractical to ask programmers to write their programs in machine language. Thus, programmers write their programs in HLL and/or assembly languageEach command of the program is called an instruction (a command that instructs the computer what to do)Computers only deal with binary data, hence the instructions must be in binary format (0s and 1s)The set of all instructions (in binary form) makes up the computer's machine languageHence, the program has to be translated to the computer's machine language before it is stored in the memoryCompilers translate HLL instructions to machine languagesAssembler translate assembly instructions to machine languagesTerm 042COE 205Dr.Talal AlKharobi
3 Micro-OperationsThe computer breaks down machine instructions into smaller operations that are called micro-operationsThese micro-operations are performed by the computer automatically (i.e. the programmer does not specify them)Example of micro-operations for an instruction that add two operands areFetching the operands,Add the operandsWriting back the result to the memoryTerm 042COE 205Dr.Talal AlKharobi
4 Instruction FieldsMachine language instructions usually are made up of several fields. Each field specifies different information for the computer. The major two fields are:Opcode field: stands for operation code and it specifies the particular operation that is to be performed. Each operation has its unique opcode and may take the computer several micro-operations to accomplish.Operands fields: specify where to get the source and destination operands for the operation specified by the opcode. The source/destination of operands can be the memory or one of the general-purpose registers.Term 042COE 205Dr.Talal AlKharobi
5 Assembly instructions and machine code. This table shows a number of assembly instructions and their corresponding machine code.The first column shows the address at which the instruction is stored,The second column shows the machine code for the instructionThe third column shows the corresponding assembly instruction.Term 042COE 205Dr.Talal AlKharobi
6 Machine instructionsAs can be see from the table, instruction sizes are not the sameSome instructions have 2 bytes, some 3 and some 4 bytesFor example, you can see that the instruction MOV AX, 1 is stored at address Since the size of this instruction is 3 bytes, the next instruction will be stored at address =0008As you can see, for the first seven instructions the first byte encodes the opcode and also the code for the register. It can be observed that the least significant 2 bits are encoding the registerThe last two bytes encode the constant. Since the register is 16 bits, the constant size is also 16 bits and this is why 2 bytes are allocatedTerm 042COE 205Dr.Talal AlKharobi
7 Machine instructionsYou can observe that when both the operands are registers that the instruction size is 2 bytesNote the difference between the machine code for the instructions MOV AX, 1 and ADD AX, 1.Also, note that for the instruction ADD AX, i two bytes are allocated to store the address of variable i which is in this example In 8086 machines, an address requires 2 bytes.In order for one to completely understand the mapping between assembly instructions and machine code, it is required to know the various instructions formats and the syntax and semantics of each format.Term 042COE 205Dr.Talal AlKharobi
Your consent to our cookies if you continue to use this website.