Download presentation
Presentation is loading. Please wait.
Published byAnn Montgomery Modified over 6 years ago
1
Chapter 3 Machine Language and Assembly Language
2
Generation of programming language.
3
Machine Language Consisting of strings of 1’s and 0’s and stored as binary numbers. Also known as machine code or object code. To solve this problem; mnemonics (Assembly language).
4
Fields In Machine Language
Contain of two fields: Operation code (Op-Code) What operation must done by processor Operand Contain of memory address or data address.
5
Assembly Language Is a symbolic representation of machine code (mnemonic). Easy to programmer. To write a program, a programmer must know how many register and internal structure of CPU.
6
Relationship between machine and assembly language
7
Advantages & Disadvantages of Machine Language
Efficient - making optimum use of both computer memory and processing time. Do not use any translator. Disadvantages Difficult to write, read and understand. Easy to make a mistake.
8
Advantages & Disadvantages of Assembly Language
Easy to write, read and understand. Disadvantages Must be translated into machine code by a separate program called an assembler.
9
Why Use Assembly Language?
Low level control When you need to change the flags, or the control registers of the processor, as when entering protected mode. Speed Programs written in machine language execute fast!. It can execute times the speed of BASIC, and about twice as fast as a program written in C or Pascal.
10
Why Use Assembly Language?…
Time critical code Critical sections of programs written in higher level languages can be written in assembly to speed up sections. Small program size. When you write a TSR for example this is very useful. Writing interrupt handlers is where assembly language shines. Assembly language is very flexible and powerful; anything that the hardware of the computer is capable of doing can be done in assembly.
11
Three type of instruction
Executable statements Assembler Directives (Pseudo-Instruction) Macro Instruction
12
1. Executable statements
One of the processor’s valid instructions which can be translated into machine code by the assembler Example: MOVE ADD ADDA ADDI CMP SUB MOVE.L #4, D2 ;Tells the CPU to put the value of 4 in register 2.
13
2. Assembler Directives (Pseudo-Instruction)
Assembler directives cannot be translated into machine code; they simply tell the assembler things it needs to know about the program and its environment. Link symbolic names to actual values. Set up predefined constants. Allocate storage for memory. Control the assembly process.
14
Example of Assembler Directives
Mostly the same as for our generic CPU, but with the size specify (.B, .W or .L) added for DC & DS
15
3. Macro Instruction A macro instruction is a program which are codified only once and can be used as many times as necessary. Macro instruction is a module with specific function which can be used by different programs. It’s very useful for the programmer in writing program (Do not write many times). It is found in many other high-level languages, such as C.
16
Assembly language format
Contain of 4 fields [Label:] Op Code [Operand/s] [;Comments] The symbol [ ] is optional Every field must at least 1 blank space.
17
Label It is an optional field. If this field is exist, so it must start in first column. Although there is no limit on length for this field but the assembler just consider only 8 characters to be significant. The characters can be Letter (a-z, A-Z) Digits (0-9) Special characters like $(dollar), .(dot) and _(underscore)
18
Label… Cannot put blank space in the label.
It cannot begin with a digit. The assembler is not a case-sensitive Eg: Value1 and value1 is same Exercise: X, 4DATA, ORG, .Value1
19
Op Code Sometime it also call as ‘pseudo op’.
This field is in mnemonics form. This is important field – (must have). The assembler will translated the mnemonics to machine code. Eg: MOVE, ADD, SUB, BNE If this field contain of assembler directive it will not translated to machine code. Eg: ORG, END, DC, DS
20
Operand/s The operand will use the data that can be executed.
General format: <source>,<destination> The statement can be 0,1 or 2 operand. When two or more operand subfields appear within a statement, they must be separated by a comma. Eg: ADD.L D1,D2 2 operand CLR.B D4 1 operand RTS 0 operand
21
Comment The comment start with symbol (;).
The assembler will ignore after this symbol. Example: MOVE.L #4,D3; Move the value (4) of data to register 3 ; all this line is a comment.
22
Reference Language level Finaly the real CPU
Level of programming languages Macro Instruction
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.