170 likes | 325 Views
Computer Architecture CST 250. Assembly Language Prepared by:Omar Hirzallah. Contents. Assembly Language Instruction Types Introduction to Programming With Assembly. Assembly Language.
E N D
Computer ArchitectureCST 250 Assembly Language Prepared by:Omar Hirzallah
Contents • Assembly Language • Instruction Types • Introduction to Programming With Assembly
Assembly Language • An assembly language is a low-level programming language for a computer,microcontroller, or other programmable device, in which each statement corresponds to a single machine code instruction. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple systems.
Instructions • Syntax of assembly language • Operation [operand] , [operand/number] Examples:
Instructions • Syntax of assembly language • Operation [operand] , [operand/number] Examples:
Instructions Examples:
Instructions Examples:
Instructions Examples:
Instructions Examples: JUMP (Loops and if statements ) There are two : Conditional and Unconditional
ALU Operation Examples: JUMP (Loops and if statements ) Unconditional jump used at any time without CMP Instruction Conditional jump are used after CMP Instruction
Instruction types • Data transfer instructions: They move data from one register/memory location to another. 2. Arithmetic instructions: They perform arithmetical operations. 3. Logical instructions: They perform logical operations. 4. Control transfer instructions: They modify the program execution sequence. 5. Input/output (I/O) instructions: They transfer information between external peripherals and system components ( CPU/Memory) • Processor control instructions: They control processor operation.
Example of : Arithmetic instruction Add register1, register2 Flags ALU Operation [ A ]
Examples What will be the value of DX register after executing the following assembly code mov DX, 12 shl DX, 1 Add DX, 5 Mov CX, 40 Shr CX, 2 Add DX,CX
Examples How many times the following code block will execute mov DX, 12 XYZ: Sub DX, 02 Add DX, 04 Mov CX, 34 And BX, 03 Xor DX, DX Cmp DX, 0 je XYZ
Examples Write the assembly instruction that clears bit # 1,2,4,7 of CL Register Solution clear means make the bit value is 0 Remember X . 1 = X X . 0 = 0 and CL, 01101001b
Examples Write the assembly instruction that sets bit # 1,2,4,7 of CL Register Solution Set means make the bit value is 1 Remember X + 1 = 1 X + 0 = X Or CL, 10010110b
Examples Write the assembly instruction that changes bit # 1,2,4,7 of CL Register Solution Change means if value is 0 make it 1 and if value is 1 make it 0 Remember X + 1 = X’ X + 0 = X xor CL, 10010110b