Presentation is loading. Please wait.

Presentation is loading. Please wait.

Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.

Similar presentations


Presentation on theme: "Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization."— Presentation transcript:

1 Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization & Assembly Language Lecture 12 Basic Instructions

2  Text Book: Chapter 4  Named Constants  Instruction Types  Basic Instructions  MOV, EXCH  ADD, SUB  INC, DEC  LEA, NEG Basic Instructions2

3  To assign a name to a constant, we can use the EQU pseudo-op.  Syntax: name EQU constant  Examples :  LF EQU 0AH MOV DL,0AH = MOV DL,LF  PROMPT EQU 'Any Thing' MSG DB 'Any Thing' = MSG DB PROMPT  Note: no memory is allocated for EQU names. 3

4 Basic Instructions  Data transfer instructions:  Between registers.  Between registers and memory.  Between registers and I/O devices.  Examples: move, exchange, push, pop, input, output.  Data manipulation instructions:  Arithmetic operations: add, subtract.  Logical operations: and, or.  Shift/Rotate: shift right, shift left.  Program control instructions:  Examples: jump, call, loop, test, compare. 4

5 Basic Instructions  The MOV (move) instruction is used to:  Transfer data between Registers.  Transfer data between registers and memory locations.  Move a number directly into a register or memory location.  Syntax: MOV destination, source  Example: MOV AX, WORD1 MOV AX, BX MOV AX, 'A' Note: any register can be used except CS & IP Before After 0006 0008 AX 0008 0008 WORD1 5

6 Basic Instructions  Illegal: MOV WORD1, WORD2 Legal: MOV AX, WORD2 MOV WORD1, AX  Illegal: MOV DS, CS Legal: MOV AX, CS MOV DS, AX Destination Operand General Segment Memory Source operand register register location Constant General register yes yes yes no Segment register yes no yes no Memory location yes yes no no Constant yes no yes no 6

7 Basic Instructions  The XCHG (exchange) operation is used to exchange the contents of:  Two registers.  A register and a memory location.  Syntax: XCHG destination, source  Example:  XCHG AH, BL  XCHG AX,WORD1 Before After AH AL AH AL BH BL BH BL 1A 00 05 00 00 05 00 1A 7

8 Basic Instructions Destination Operand Source Operand General Memory register location General register yes yes Memory location yes no 8

9 Basic Instructions  The ADD (add) and SUB (subtract) instructions are used to:  Add/subtract the contents of:  Two registers.  A register and a memory location.  Add/subtract a number to/from a register or memory location.  Syntax: ADD destination, source SUB destination, source  Examples: ADD WORD1, AX SUB AX, DX 9 Before After 01BC 01BC AX AX 0523 06DF WORD1 WORD1 Before After 0000 FFFF AX AX 0001 0001 DX DX

10 Basic Instructions  Illegal: ADD BYTE1, BYTE2  Legal: MOV AL, BYTE2 ADD BYTE1, AL 10 Destination Operand General Memory Source Operand register location General register yes yes Memory location yes no Constant yes yes

11 Basic Instructions  INC (increment) is used to add 1 to the contents of a register or memory location.  DEC (decrement) is used to subtract 1 from a register or memory location.  Syntax: INC destination DEC destination  Examples: INC WORD1 DEC BYTE1 11 Before After WORD1 WORD1 0002 0003 Before After BYTE1 BYTE1 FFFE FFFD

12 Basic Instructions  NEG is used to negate the contents of the destination.  It does this by replacing the contents by its two’s complement.  Syntax: NEG destination  Examples: NEG BX 12 Before After BX BX 0002 FFFE Negative integers are stored using 2’s complement in the computer Example: Want to store -5 in memory 1’s complement= 11111010 +1 11111011


Download ppt "Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization."

Similar presentations


Ads by Google