chapter 3_ short circuit

Upload: guganesvaran-rajadurai

Post on 06-Jul-2018

250 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/17/2019 Chapter 3_ Short Circuit

    1/92

    DFT 1113

    COMPUTER

    ORGANISATION

    CHAPTER 3INSTRUCTION SET AND

    ASSEMBLY LANGUAGEPROGRAMMING NOR ZAMIRABINTI OTHMAN

    JTMK

  • 8/17/2019 Chapter 3_ Short Circuit

    2/92

    3.1 UNDERSTAND INSTRUC TION SET AND ASSEMB LY

    LANGUAGE.

    3.1.1 Define Instruction set, machine and assembly language.

    3.1.2 Describe the addressing modes using proper instruction

    format 3.1.3 Describe various types of addressing modes with example.

    3.2 APPLY ASSEMB LY LANGUAGE .

    3.2.1 Write a simple program in assembly language for:

    a. arithmetic operation

    b. logic operation

    3.2.2 Use tools in analyzing and debugging assembly language

    programs

    LEARNING OUTCOMES

  • 8/17/2019 Chapter 3_ Short Circuit

    3/92

    Capability of processor determine the capability of thecomputer system. Therefore, processor is the keyelement or heart of a computer system.

    Other than PC, microprocessors are used in variouscomputerized system such as industrial automation.

    INTRODUCTION  

  • 8/17/2019 Chapter 3_ Short Circuit

    4/92

    Message sent by programmers (program

    instructions) understood by the computer and

    vice versa.

    Language that friendly to human alsounderstandable to computer systems.

    Three level of language:

    Low level – machine languageMiddle level – assembly language

    High level – high-level language

    3.1. UNDERSTAND THE INSTRUCTION SET

    AND ASSEMBLY LANGUAGE.

  • 8/17/2019 Chapter 3_ Short Circuit

    5/92

  • 8/17/2019 Chapter 3_ Short Circuit

    6/92

    INSTRUCTION SET :

    The complete collection of instructions that are understoodby a CPU

    • Known also as Machine Code/Machine Instruction• Binary representation

    • Usually represented by assembly codes

    3.1.1 DEFINE INSTRUCTION SET, MACHINE

    AND ASSEMBLY LANGUAGE

  • 8/17/2019 Chapter 3_ Short Circuit

    7/92

    Machine language is a binary program (or binary code).

    Binary code is a sequence of instruction and operand in

    binary that list the exact representation instruction as

    they appear in computer memory.

    Natural language of a particular computer system.

    Strings of numbers or binary codes (0 or 1).

    MACHINE LANGUAGE: 

  • 8/17/2019 Chapter 3_ Short Circuit

    8/92

    Machine-dependent (differ from one µP to other µP.

    Program written in any other language must be

    translated to binary representation of instruction

    before they can be executed by computer.

    Programmers need to know specifically the

    architecture of CPU.

  • 8/17/2019 Chapter 3_ Short Circuit

    9/92

    MACHINE LANGUAGE:

  • 8/17/2019 Chapter 3_ Short Circuit

    10/92

    The program is difficult to 

    understand 

    The program is long 

    and arduous 

    The program did not specify the

     

    tasks 

    we perform require a computer. 

    The program is slow to key-

    in to the computer

     

    due 

    to the input one bit by one bit at a time 

    LIMITATIONS IN PROGRAMMING USING 

    MACHINE LANGUAGE 

  • 8/17/2019 Chapter 3_ Short Circuit

    11/92

    To overcome these problems, the use of

    easily remembered code (mnemonic) was

    introduced. It is apply with the use of

    Assembly Language 

  • 8/17/2019 Chapter 3_ Short Circuit

    12/92

    Assembly language is a symbolic representation of a

    machine language of specific processor. Assembly language

    is a form that is very dependent on the underlying

    architecture.

    Using english-like abbreviations (MUL), ( ADD), (SUB)

    Assembler as translator.

    Assembler - Translate ordinary mnemonics such as MOVEData, Acc, into their corresponding machine language

    (the only form of instruction that computer can

    executed)

    ASSEMBLY LANGUAGE

  • 8/17/2019 Chapter 3_ Short Circuit

    13/92

    Assembly Process - Process of translating an assembly

    language programs into a machine language programs.

    The assembly process is straightforward (one -to-one

    mapping of assembly languages statements to their

    machine language counterpart) and rather simple

    Programmer need to know the basic architecture.

    ASSEMBLY LANGUAGE (AL) 

  • 8/17/2019 Chapter 3_ Short Circuit

    14/92

    It clarifies the execution of instruction.

    It shows how the data represent in memory.

    It show how a program interacts with the operating system

    (OS), processor and, input and output (I/O) system.

    It clarify how a program access external devices

    Sometimes difficult to access hardware drive and system

    tool if using (register transfer languages) RTL

    WHY ASSEMBLY LANGUAGE STUDY IS

    IMPORTANT?

  • 8/17/2019 Chapter 3_ Short Circuit

    15/92

    Easy to make compilers, debuggers and other device tools.

    Allow accessing information that is not accessible

    (restricted) from high level languages.

    More function library that can be used in programming

    development.

    Possibility to make library function that compatible withdifferent compiler and operating system

    ADVANTAGES USING ASSEMBLY

    LANGUAGES

  • 8/17/2019 Chapter 3_ Short Circuit

    16/92

    (Development) Requires longer development time

    (Reliability & Security) Easy to makes error

    (Debug) More possibility for errors

    (Maintain) Difficult to modify because it allows

    unstructured code.

    (Portability) Difficult to porting to different

    platforms.

    DISADVANTAGES USING ASSEMBLY

    LANGUAGES

  • 8/17/2019 Chapter 3_ Short Circuit

    17/92

    Using everyday English and common mathematical

    notation. (x = I + j)

    Overcome problems : assembly language require manyinstruction to accomplish a simple task.

    Single instruction in HLL = several AL instructions.

    Compiler as translator.

    Programmers do not need to know the architectu re of CPU.

    HIGH LEVEL LANGUAGE (HLL)

  • 8/17/2019 Chapter 3_ Short Circuit

    18/92

    THREE DIFFERENT LEVELS OF LANGUAGE

  • 8/17/2019 Chapter 3_ Short Circuit

    19/92

    COMPARISON OF INSTRUCTIONS OF

    THREE DIFFERENT LANGUAGES

  • 8/17/2019 Chapter 3_ Short Circuit

    20/92

    COMPARISON OF INSTRUCTIONS OF

    THREE DIFFERENT LANGUAGES

  • 8/17/2019 Chapter 3_ Short Circuit

    21/92

    The term microprocessor typically refers to the central processing unit

    (CPU) of a microcomputer, containing the arith metic logic unit (ALU)

    and the control units (CU).

    Performs the main tasks for the comp uter system

    data transfer between (registers) and memory or I/O

    arithmetic and l ogic operations. Example: ADD, SUB, AND, OR, etc

    program flow via s imple decisions. Example: Zero, Sign, Carry, etc

    MICROPROCESSOR OVERVIEW

  • 8/17/2019 Chapter 3_ Short Circuit

    22/92

  • 8/17/2019 Chapter 3_ Short Circuit

    23/92

    BIT

    binary digit

    hold only two values: 0 or 1

    Smallest unit of data

    1 bit : the smallest.

    4 bit : nibble.

    8 bit : byte; indicated (.B) notation

    16 bit : word; indicated (.W) notation

    32 bit : long word; indicated (.L) notation

    DATA SIZES

  • 8/17/2019 Chapter 3_ Short Circuit

    24/92

    For the data which has more bits, it is divided into dual-half portions upper (MSD section)

     lower portions (LSB section).

    1 Byte consists of two nibbles;  upper nibble

    lower nibble.

    1 Word consists of two bytes;

    upper byte lower byte.

    1 Long Word consists of two word;  upper word

     lower word.

    DATA SIZES

  • 8/17/2019 Chapter 3_ Short Circuit

    25/92

    Can store either

    Longword

    Word

    Byte

    DATA SIZES

    1 0 0 1 1 0 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1

    0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1

    0 1 0 0 0 1 0 1

  • 8/17/2019 Chapter 3_ Short Circuit

    26/92

    NOTATIONS FOR INFORMATION

    REPRESENTATION

    64 bits

    8 bytes

    2 words

    1 doubleword

    Q: How do we number these various units of information in a consistent manner?

    9 6 2 1 7 6 6

    Most Significant Digit (MSD) Least Significant Digit (LSD)

    1 2 3 4 5 6

    “Big End” -ian Numbering

    6 5 4 3 2 1

    “Little End” -ian Numbering

  • 8/17/2019 Chapter 3_ Short Circuit

    27/92

    NOTATIONS FOR INFORMATION

    REPRESENTATION

  • 8/17/2019 Chapter 3_ Short Circuit

    28/92

    A single cell sized 1 bit can store either logic -0 or logic-1.

    Thus the range of data is 0 –  1 .

    Data size: n = 1

    Data capacity : 2n = 21 = 2

    Range : 0 –  1

    A single cell sized 4 bit (Nibble) can store 16 possible

    situations

    Data size: n = 4Data capacity : 2n = 24 = 16

    Range : 0 - 15

    DATA SIZE

  • 8/17/2019 Chapter 3_ Short Circuit

    29/92

    DATA SIZE

    Data

    size

    N

    ( in bit) 

    Data type  Data capacity

    2n 

    Range 

    Bit 

    0 – 1 

    4  Nibble  16  0 - 15 

    Byte 

    256 

    0 – 255 

    16 

    Word 

    65536 

    0 – 65535 

    32 

    Long Word 

    4,294,967,296  0 -

    4,294,967,295 

  • 8/17/2019 Chapter 3_ Short Circuit

    30/92

    Internal Register – theworking element of µp.

     MC68000 – an internal 32-

    bit processor  Register Set

     8 data register (D0-D7)

    7address register(A0-A6) 

    2 stack pointer(USP&SSP) 1 program counter (PC)

    1 status register (SR)

    REGISTER SET OF MC68000

  • 8/17/2019 Chapter 3_ Short Circuit

    31/92

  • 8/17/2019 Chapter 3_ Short Circuit

    32/92

  • 8/17/2019 Chapter 3_ Short Circuit

    33/92

    DATA TYPE : BINARY

  • 8/17/2019 Chapter 3_ Short Circuit

    34/92

    DATA TYPE : OCTAL

  • 8/17/2019 Chapter 3_ Short Circuit

    35/92

    DATA TYPE : HEXADECIMAL

  • 8/17/2019 Chapter 3_ Short Circuit

    36/92

    DATA TYPE : DECIMAL 

  • 8/17/2019 Chapter 3_ Short Circuit

    37/92

    ASCII CHARACTER

  • 8/17/2019 Chapter 3_ Short Circuit

    38/92

    DATA TYPE

    %binary number

    @

    octal number$hexadecimal number

    No sign decimal number

    Character ASCI code

  • 8/17/2019 Chapter 3_ Short Circuit

    39/92

     

    3.1.2 DESCRIBEADDRESSING MODES

    USING PROPER

    INSTRUCTION FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    40/92

    There are many MC68000 instr uctions. However, thesesinstructions comply to a standard instruction format:

    INSTRUCTION FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    41/92

    INSTRUCTION FORMAT

    CommentsLabel>

    CommentsLabel>

    CommentsLabel>

  • 8/17/2019 Chapter 3_ Short Circuit

    42/92

    LABEL –  pointer to the instruct ion’s memory location  

    OPERATOR -operation code ( ie;MOVE,ADD…)

    OPERAND  –  Depends on the operator, may has more

    than one operand. COMMENT  –  Explanation about the execution of

    instruction.

    Data format - Byte | Word | Longword | Sign-extended

    INSTRUCTION FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    43/92

    INSTRUCTION FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    44/92

    Label are optional

    Label –  a user-defined symbol representing theaddress associated with the instruction.

    Up to 8 alphanumeric, begin with letter, terminated bya space.

    LABEL

  • 8/17/2019 Chapter 3_ Short Circuit

    45/92

    Opcode is an opera tion code that will be executed by

    microprocessor

    It is abbreviation of English- like word for an operation

    For example MOVE – Transfer data from source to destination

    ADD – Add two binary numbers stored in registers

    Associates with the size of data to be execute

    Can be either Byte: .B

    Word: .W

    Longword: .L 

    OPCODE/OPERATION CODE / MNEMONIC

  • 8/17/2019 Chapter 3_ Short Circuit

    46/92

    OPERANDS

  • 8/17/2019 Chapter 3_ Short Circuit

    47/92

    Comment is optional

    Comment provide readability for future reference

     Explain the operation of each instruction

    Any line beginning with an * is a comment.  Any line beginning with a ; (semi -colon) is a comment.

    Example ;

    COMMENT

    org $1000 ; set the location counter to $1000

  • 8/17/2019 Chapter 3_ Short Circuit

    48/92

    mnemonics are postfixed with symbol ".B", ".W", ".L".

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    49/92

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    50/92

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    51/92

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    52/92

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    53/92

    DATA FORMAT

  • 8/17/2019 Chapter 3_ Short Circuit

    54/92

    3.1.3 DESCRIBE

    VARIOUS TYPES OFADDRESSING MODES

    WITH EXAMPLE.

  • 8/17/2019 Chapter 3_ Short Circuit

    55/92

    Data transfer Group

     Arithmetic Group

    Logical Group

    Shift and rotate Group

    Branch & Subroutine

    Stack & Queue

    CLASSIFICATION OF INSTRUCTION SETS

  • 8/17/2019 Chapter 3_ Short Circuit

    56/92

    These instructions transfer or move data between its

    internal registers, between an internal register and a

    storage location in memory, or between two locationsin memory.

     - memory to register

    - register to memory

    - register to register

    - memory to memory

    DATA TRANSFER GROUP

  • 8/17/2019 Chapter 3_ Short Circuit

    57/92

    DATA TRANSFER GROUP

  • 8/17/2019 Chapter 3_ Short Circuit

    58/92

    Byte(B), Word(W) and Long word(L).

    R  R , R  M , M  M , EA  SR , USP  An

    Example 1:

    MOVE.B #$72,D1

    Before : D1 = $00200500 After : D1 = $00200572

    Example 2:

    MOVE.B D0,D1 Before : D1 = $00200500 , D0 = $00002222

    After : D1 = $00200522 , D0 = $00002222  Example 3:

    MOVE.W $3000,D1 Before : D1 = $00200500 , After : D1 = $00203243 ,

    MOVE (SOURCE TO DESTINATION)

    # indicate actual

    value$ indicate

    hexadecimal value

    $3000 32

    $3001 43

    $3002 98

  • 8/17/2019 Chapter 3_ Short Circuit

    59/92

    Example 4 :

    MOVE.W D6,$4000

    Before: D6 = $AB206541 ,

    After : D6 = $AB206541

    Example 5:

    MOVE.W D2,(A1)

    Before : D2 = $AB206541 ,

    A1 = $00000501 After : D2 = $AB206541 ,

    A1 = $00000501 

    MOVE (SOURCE TO DESTINATION)

    $4000 3254

    $4002 4377

    $4004 9868

    $4000 32

    $4001 54

    $4002 43

    $4000 6541

    $4002 4377

    $4004 9868

    $4000 65

    $4001 41

    $4002 43

    $501 65

    $502 41

    $503 FF

    $501 FF

    $502 FF

    $503 FF

    before

    After

    Before After

  • 8/17/2019 Chapter 3_ Short Circuit

    60/92

    Provides a means of initializing an address register.

    Only a  word or longword operand is allowed to betransferred into the specified address register.

    For a word operation, the source operand is sign -extended before being loaded into the addressregister.

    Example 5:

    MOVEA.W D6,A2Before : D6 = $AB206541 , A2 = $ABCD1234

    After : D6 = $AB206541 , A2 = $00006541

    MOVEA (MOVE ADDRESS)

  • 8/17/2019 Chapter 3_ Short Circuit

    61/92

    Example 6:

    MOVEA.W $8C00,A0

    Before : A0 = $FFFFFFFF

    After : A0 = $FFFF8C00

    Example 7:

    MOVEA.W D6,A2

    Before : D6 = $AB20A541 , A2 = $ABCD1234

    After : D6 = $AB20A541 , A2 = $FFFFA541

    Example 8:

    MOVEA.L D6,A2

    Before : D6 = $AB206541 , A2 = $ABCD1234

    After : D6 = $AB206541 , A2 = $AB206541

    MOVEA (MOVE ADDRESS)

  • 8/17/2019 Chapter 3_ Short Circuit

    62/92

    • A short form of the move instruction for transferringan immediate operand to a data register .

    • The immediate operand is limited to the range of

      -128 to 127.

    • The operation size is implied to be longword.

    • Therefore the 8-bit immediate operand is sign-extended to 32 bits before being loaded into thedestination, which must be a data register.

    MOVEQ (MOVE QUICK)

  • 8/17/2019 Chapter 3_ Short Circuit

    63/92

    MOVEQ (MOVE QUICK)

  • 8/17/2019 Chapter 3_ Short Circuit

    64/92

    Example 1:

    MOVEQ #$04,D3  Before : D3 = $AB206541After : D3 = $00000004

    Example 2:

    MOVEQ #$80,D3Before : D3 = $AB206541After : D3 = $FFFFFF80

    Example 3:

    MOVEQ #-3,D2Before : D2 = $AB206541After : D2 = $FFFFFFFD

    MOVEQ (MOVE QUICK)

  • 8/17/2019 Chapter 3_ Short Circuit

    65/92

    Transfer words or longwords between a register listand consecutive memory locations.

    In the case of a word transfer to the registers, eachmemory word is sign-extended before being loadedinto the respective register.

    MOVEM (MOVE MULTIPLE REGISTERS

    MOVEM (MOVE multiplr registers)

  • 8/17/2019 Chapter 3_ Short Circuit

    66/92

    Example 1:

    MOVEM.W D2/D5/D0,$200

    Before : D0 = $11112222 ,D2 = $33334444 ,

    D5 = $55556666 ,

    After : D0 = $11112222 ,

    D2 = $33334444 ,

    D5 = $55556666 ,

    Example 2 :

    MOVEM.L D2/D5/D0,-(A4)

    Before : D0 = $11112222 , D2 = $33334444 ,

    D5 = $55556666 , A4 = $0000050C

    After : D0 = $11112222 ,

    D2 = $33334444 ,

    D5 = $55556666 ,

    A4 = $00000500

    $200 6541$202 4377

    $204 9868

    $200 4444

    $202 6666$204 2222

    $500 451287A4

    $504 54A2F221

    $508 846AC1DD

    $50C 45123211$500 33334444

    $504 55556666

    $508 11112222

    Predecrement (tolak dulu)B : – 1 , W : – 2 , L : – 4

    Dlm contoh ada 3 daftarmaka 3x4=12 ,50C – C = 500

    MOVEM (MOVE multiplr registers)

    MOVEM (MOVE multiplr registers)

  • 8/17/2019 Chapter 3_ Short Circuit

    67/92

    Example 3 :

    MOVEM.W $200,D2/D5/D0

    Before : D0 = $11112222 ,D2 = $33334444 ,

    D5 = $55556666 ,

    After : D0 = $FFFF9868 ,

    D2 = $00006541 ,

    D5 = $00004377 ,

    Example 4 :

    MOVEM.L (A4)+,D2/D5/D0

    Before : D0 = $1111222 , D2 = $33334444 ,

    D5 = $55556666 , A4 = $00000500

    After : D0 = $846AC1DD ,

    D2 = $451287A4 ,

    D5 = $54A2F221 ,

    A4 = $0000050C

    $200 6541$202 4377

    $204 9868

    $200 6541

    $202 4377$204 9868

    $500 451287A4

    $504 54A2F221

    $508 846AC1DD

    $50C 45123211$500 451287A4

    $504 54A2F221

    $508 846AC1DD

    Posincrement (tmbh kmdn)B : + 1 , W : + 2 , L : + 4

    Dlm contoh ada 3 daftarmaka 3x4=12 ,500 + C = 50C

    MOVEM (MOVE multiplr registers)

  • 8/17/2019 Chapter 3_ Short Circuit

    68/92

    EXG (EXCHANGE)

    • EXG interchanges the contents of two

    registers.

    • operand size for EXG is longword

     Example 1:

    EXG D1,D5

    Before : D1 = $11223344 , D5 = $66778899After : D1 = $66778899 , D5 = $11223344

  • 8/17/2019 Chapter 3_ Short Circuit

    69/92

    SWAP

    • SWAP exchanges the lower word of the specifieddata register with its upper word.

    • the operand size for SWAP is word.

     Example 1 SWAP D1 Before : D1 = $11223344 After : D1 = $33441122

     

    Example 2

    SWAP D1 Before : D1 = $1234567 After : D1 = $45670123

     

  • 8/17/2019 Chapter 3_ Short Circuit

    70/92

    Transfers the source operand address rather than its content

    to the destination address register.

    Therefore:

    MOVEA.L OPER,A1 is equivalent toLEA OPER,A1

    LEA (LOAD EFFECTIVE ADDRESS)

    OPER EQU $2001

    LEA OPER,A1

  • 8/17/2019 Chapter 3_ Short Circuit

    71/92

     

    Loads the target with 0

    Example 1:

    CLR.B D1

    Before : D1 = $11223344

    After : D1 = $ 11223300 

    CLR

  • 8/17/2019 Chapter 3_ Short Circuit

    72/92

    ARITHMETIC GROUP

    • Similarly as the operation of mathematic,

    addition (+), subtraction (-), multiplication (x),

    division (÷)

    • Binary arithmetic instructions performs signed

    and unsigned operations.

  • 8/17/2019 Chapter 3_ Short Circuit

    73/92

    ARITHMETIC GROUP

  • 8/17/2019 Chapter 3_ Short Circuit

    74/92

    ADD (ADDITION)

    • 68000 MP allows addition of 3 data size i.e 8 bit (.B),16 bit (.W), and 32 bit (.L)

    • Data is accessed via register (D0 to D7), memory,absolute data and I/O port.

    • < Destination> +

    • Both can be data registers

    • At least one must be a data register

  • 8/17/2019 Chapter 3_ Short Circuit

    75/92

     

    Example 1:

    ADD.L D0,D1

    Before : D1 = $00200500 , D0 = $00002222After : D1 = $00202722 , D0 = $00002222

    Example 2:

    ADD.W $3000,D1Before : D1 = $00200500 ,

    After : D1 = $00203743 , 

    ADD (ADDITION)

    $3000 32

    $3001 43

    $3002 98

  • 8/17/2019 Chapter 3_ Short Circuit

    76/92

    Example 3:

    ADD.B D0, D1

    ADD (ADDITION)

    .B

    HH

    22

    + 44

    66

  • 8/17/2019 Chapter 3_ Short Circuit

    77/92

    $4000 3254

    $4002 4377

    $4004 9868

    $4000 32

    $4001 54

    $4002 43

    $4000 9795

    $4002 4377

    $4004 9868

    $4000 97

    $4001 95

    $4002 43

    ADD (ADDITION

    Example 4:

    ADD.W D6,$4000

    Before: D6 = $AB206541 ,

    After : D6 = $AB206541 ,  

  • 8/17/2019 Chapter 3_ Short Circuit

    78/92

    “ADDI.W #$72,D1” and 

    “ADD.W #$72,D1” are equivalent

    But “ADDI #” can add to a

    memory location

    ADDI (ADD IMMEDIATE)

    Add an immediate value

    Cannot be done using ADD as one operand must

    be a data register

    • Example :ADDI.W  #$1234,(A0)

    Example 1:

    ADDI.W #$72,D1Before : D1 = $00200500After : D1 = $00200572

  • 8/17/2019 Chapter 3_ Short Circuit

    79/92

    • ADDA – destination of add is an address register

    Example 1:

    ADDA.W D6,A2 Before : D6 = $AB206541 , A2 = $ABCD1234 After : D6 = $AB206541 , A2 = $ABCD7775

    Example 2:

    ADDA.L D6,A2 Before : D6 = $AB20A541 , A2 = $ABCD1234 After : D6 = $AB206541 , A2 = $56EDB775 , C = 1

    Example 3:

    ADDA.W #$8122,A0 Before : A0 = $FFFFFFFF After : A0 = $FFFF8122

    ADDA (ADDITION)

  • 8/17/2019 Chapter 3_ Short Circuit

    80/92

    1 until 8

    ADDQ (ADDITION

    • ADDQ – Add a constant (1 to 8) to a memorylocation, or register. It is executed faster.

    • ADDQ #4, D1• Speed is faster than ADD #4, D1

    Example 1:

    ADDQ.B #$04,D3 (ADDQ #XXX,Dn)Before : D3 = $AB206541After : D3 = $AB206545

  • 8/17/2019 Chapter 3_ Short Circuit

    81/92

    ADDX (ADD EXTENDED)

    • Add source and destination plus contents of the Xbit of the condition code register

    • Both source and destination must be dataregisters

    Example 1:

    ADDX.B D2,D3Before : D2 = $AB206541 , D3 = $ABCD1234 , X = 1

    After : D2 = $AB206541 , D3 = $AB206576 , X = 1

  • 8/17/2019 Chapter 3_ Short Circuit

    82/92

    SUB (SUBTRACTION)

    < Destination> -

    •  SUB, SUBA, SUBQ, SUBI, SUBX – the

    subtractions equivalents of ADD

    Example 1:

    SUB.W #$80,D3Before : D3 = $AB206541

    After : D3 = $AB2064C1 

  • 8/17/2019 Chapter 3_ Short Circuit

    83/92

    Example 2:

    SUBI.L #10,D2

    Before : D2 = $AB206541

    After : D2 = $AB206537

    Example 3:

    SUBQ.W #@11,D3 (SUBQ #XXX,Dn)

    Before : D3 = $AB206541

    After : D3 = $AB200038

    SUB

    -128 (80) until 127 (7F)

  • 8/17/2019 Chapter 3_ Short Circuit

    84/92

    Example 1:

    MULU #2,D2  ;16 bit x 16 bit = 32 bit

    Before : D2 = $AB206541

    After : D2 = $0000CA82Example 2:

    MULU #2,D2

    Before : D2 = $AB20FFFF

    After : D2 = $0001FFFE

    MULU

    @ octal no.% binary no.

    No sign decimal no.

  • 8/17/2019 Chapter 3_ Short Circuit

    85/92

    Example 1:

    DIVU #2,D3  ;32 bit / 16 bit = 16 bit lower (result)

    16 bit upper ( remainder)

    Before : D3 = $00006541

    After : D3 = $000132A0

    Example 2:

    DIVU #$1234,D0 ;32 bit / 16 bit = 16 bit lower(result)

    16 bit upper ( remainder)

    Before : D0= $00005678

    After : D0 = $0DA80004

    DIVU

    6541F = 25921 32A016

     = 1296010

  • 8/17/2019 Chapter 3_ Short Circuit

    86/92

     

    NEG – Take the 2’s complement of target  

    Example 1:

    NEG.W D3

    Before : D3 = $AB206541

    After : D3 = $AB209ABF

    NEG

    NEG = 2’s complement 

    $41 = 01000001Invert 10111110

    + 1

    $BF = 10111111

  • 8/17/2019 Chapter 3_ Short Circuit

    87/92

     

    Similar to the logic gate, logical operations

    involve AND, OR, and NOT.

    The content of the register and memory arecompared.

    The operation is implemented in ALU.

    LOGICAL GROUP

  • 8/17/2019 Chapter 3_ Short Circuit

    88/92

    LOGICAL GROUP

  • 8/17/2019 Chapter 3_ Short Circuit

    89/92

    Example 1:

    AND.B $3E, D3 [D3(B) AND $3E D3 (B) ]

    (8 bit data in data register D3 is AND-ed with 8 bit

    absolute data, and the product is stored in D3)

    AND

  • 8/17/2019 Chapter 3_ Short Circuit

    90/92

    Example 1:

    OR.B D0, D1 [D1 (B) or D0 (B) D1(B) ]

    8 bit data in data register D1 is OR-ed with 8 bit data in data

    register D0, and the product is stored in D1)

    OR

    NOT

  • 8/17/2019 Chapter 3_ Short Circuit

    91/92

    Example 1:

    NOT.B D1 [D1(B) NOT D1 ]

    (content in D1 is NOT, and the product is stored back

    to D1) 

    NOT

  • 8/17/2019 Chapter 3_ Short Circuit

    92/92