Computer Architecture CST 250

Slides:



Advertisements
Similar presentations
ASSEMBLER M. Antczak, S. Wąsik. Debug session: starting of the example.exe program debugging process debug example.exe checking the value that is stored.
Advertisements

Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
80x86 Instruction Set Dr. Qiang Lin.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language for Intel-Based Computers
Flow Control Instructions
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
Microcomputer & Interfacing Lecture 3
Ch. 7 Logic, Shift and Rotate instr.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Department of Computer Science and Software Engineering
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
1 ICS 51 Introductory Computer Organization Fall 2009.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/09/29
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Review of Assembly language. Recalling main concepts.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
CS2422 Assembly Language and System Programming 0 Week 13 & 14 Codes in Assembly Language.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Unit 1 Instruction set M.Brindha AP/EIE
Introduction to assembly programmıng language
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
1. Introduction A microprocessor executes instructions given by the user Instructions should be in a language known to the microprocessor Microprocessor.
EE3541 Introduction to Microprocessors
INSTRUCTION SET.
Multiplication and Division Instructions
INSTRUCTION SET.
Assembly Language Programming Part 2
Microprocessor and Assembly Language
Processor Processor characterized by register set (state variables)
(The Stack and Procedures)
CS-401 Assembly Language Programming
UNIT: 2 INSTRUCTION SET OF 8086.
Arithmetic Instructions
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Fundamentals of Computer Organisation & Architecture
(The Stack and Procedures)
Shift & Rotate Instructions)
Symbolic Instruction and Addressing
Shift & Rotate Instructions)
Flow Control Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
University of Gujrat Department of Computer Science
Computer Architecture CST 250
X86 Assembly Review.
EECE.3170 Microprocessor Systems Design I
UNIT-II Assembly Language Programs Involving Logical
Computer Organization and Assembly Languages Yung-Yu Chuang 2005/09/29
Process.
CNET 315 Microprocessor & Assembly Language
Multiplication and Division Instructions
Multiplication and Division Instructions
(The Stack and Procedures)
Chapter 8: Instruction Set 8086 CPU Architecture
Presentation transcript:

Computer Architecture CST 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 Examples: Operation [operand] , [operand/number] Examples: instruction Explanation mov ah, 25 Put 25 in ah register  dh=25 inc dx increase the value of dx by  dx=dx+1 add ax, bx add the contents of bx into ax. The result will be in ax register  ax=ax+bx sub cx, bx subtract the contents of bx from cx. The result will be in cx register  cx=cx-bx

Instructions Syntax of assembly language Examples: Operation [operand] , [operand/number] Examples: instruction Explanation mov dh, 00000101b Put 5 in dh register  dh=5 add ax, 00001111b add the 15 into ax. The result will be in ax register  ax=ax+15

Instructions Examples: Decrease the value of dx by 1  dx=dx-1 Explanation dec dx Decrease the value of dx by 1  dx=dx-1 and ax, bx Do logical AND for ax with bx. The result will be in ax register  ax=ax && bx xor cx, bx Do logical XOR for bx with cx. The result will be in cx register  cx=cx ^ bx Mov ah, [x] Put the content of the memory variable x in ah  ah=x hlt Stop the processor

Instructions Examples: Shift all bits of dx (1 position) to the right Explanation shr dx,1 Shift all bits of dx (1 position) to the right  dx=dx/2 shr dx, 2 Shift all bits of dx (2 position) to the right  dx=dx/4 shr dx, 3 Shift all bits of dx (3 position) to the right  dx=dx/8 shr dx, 4 Shift all bits of dx (4 position) to the right  dx=dx/16 shr dx, 5 Shift all bits of dx (5 position) to the right  dx=dx/32

Instructions Examples: Shift all bits of dx (1 position) to the left Explanation shl dx,1 Shift all bits of dx (1 position) to the left  dx=dx * 2 shl dx, 2 Shift all bits of dx (2 position) to the left  dx=dx * 4 shl dx, 3 Shift all bits of dx (3 position) to the left  dx=dx * 8 shl dx, 4 Shift all bits of dx (4 position) to the left  dx=dx *16 shl dx, 5 Shift all bits of dx (5 position) to the left  dx=dx * 32

Instructions Examples: JUMP (Loops and if statements ) There are two : Conditional and Unconditional Instruction Explanation Cmp dx,1 je lable1 cmp means compare Je means jump if equal If(dx==1) Do the instruction in front of lable1 mov dx, 1 dec dx cmp dx, 0 je xyz add dx,5 xyz: inc dx .. If (dx != 0) { dx=dx-1; dx=dx+5 } dx=dx+1

ALU Operation Examples: JUMP (Loops and if statements ) Instruction Cmp dx,1 je jne jl jle jg jge Instruction jmp 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 CL x and 1 CL x 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 CL x OR 1 CL 1 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 CL x XOR 1 CL x xor CL, 10010110b