Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

68K Microprosessor

VIEWS: 55 PAGES: 27

This article will help us in getting to know the programmer view of the 68000 or 68K and get familiar with the structure of a 68K assemble program. Next, how to write and program in 68K assembler. Then, how to differentiate between assembler and machine code.

More Info
  • pg 1
									    EEB 2023
        Microprocessor

        Getting to know the 68000
         microprocessor




Microprocessor

           1
                                    Jump to first page
Objectives
I   Get to know the programmer view of the 68000
I   Get familiar with structure of a 68000 assembler
    program
I   Writing an 68000 assembler program




    Microprocessor

               2
                                           Jump to first page
Outcomes
I    To be able describe the 68000 software
     model
I    To be able explain the difference between
     assembler and machine code
I    To be able write an 68000 assembler program




    Microprocessor

               3
                                         Jump to first page
                 Software Model


Microprocessor

           4
                              Jump to first page
                       Programmer View (Model)
                             of the 68000

                          Hardware View




Microprocessor
                 Software Model of the 68000
           5
                                            Jump to first page
THE 68000's SET OF REGISTERS

                              Data registers




                               Address registers



                               Stack pointer
  Microprocessor
                   Software Model of the 68000
             6
                                               Jump to first page
I   The Motorola 68000 processor has 18 registers that are
    directly accessible by the user.
    •   8 general-purpose data registers numbered from
        D0 to D7
    •   8 address registers numbered from A0 to A7
    •   1 Program Counter (the PC)
    •   1 Status Register (the SR), which is divided in 2
        parts: the System Byte, which we'll consider in
        later lectures, and the Condition Code Register
        (the CCR).



    Microprocessor

               7
                                                 Jump to first page
I   All the data registers, all the address registers and the
    Program Counter are 32-bits (4 bytes) wide.
             Program counter




I   The Status Register, or SR, is 16 bits (2 bytes) wide. Only
    the low-order byte of the SR, which is called the CCR, or
    Condition Code Register, can be accessed by the user.
                                  Status register
I   System Byte, can be seen and
    accessed only by the Operating
    System during special emergency
    cases e.g. interrupts and
    exceptions.
                                               Condition code register

    Microprocessor

               8
                                                       Jump to first page
I   The data registers are used to store any data. They are
    general-purpose registers, because they haven't been
    reserved for any specific task by the 68000 chip
    designers, and they are interchangeable, in the sense
    that whatever you can do with register D1 you can also
    do with register D2.
I   The address registers are used to store addresses of
    locations in main memory. Address registers are
    pointers to locations in memory. Registers A0 to A6 are
    general-purpose and interchangeable.
I   Register A7, also referred to as SP, is more special: it is
    the processor's stack pointer
                       Stack pointer

    Microprocessor

               9
                                                     Jump to first page
I   Registers have the potential to accommodate 32 bit
    numbers (one long-word), but they don't limit the user to
    perform operations only on 32 bit numbers. In fact, the
    programmer can work with either




     Microprocessor

               10
                                                    Jump to first page
SAQ
I   What is difference between data and
    address registers?

    IData registers are used to store any data
    IAddress registers are used to store addresses

    of locations in main memory




    Microprocessor

              11
                                           Jump to first page
Introduction to 68000 Programming
                            Start Address

           Org        $400           ;Start address
Start      Move.w     #$4321,d0      ;Moves 4321h into register d0
           Add.w      #$2000,d0      ;Adds 2000h to d0
           Move.w     d0,d1          ;Saves result in d1
           End        $400                      Comments
Label
        Instruction   Operand



         Move.w -          move word (16-bit)
         Add.w             add word

   Microprocessor

             12
                                                     Jump to first page
Producing Assembler Code
 A specific format must be used, consisting of four fields:

 I   Label
      N this is optional and used to name sections of the
        program.
 I   Mnemonic
      N the program instruction (opcode)
 I   Operand(s)
      N containing the data used by the program instruction
 I   Comments
      N optional text to give a greater clarity to the program

 Microprocessor

           13
                                                  Jump to first page
Assembly
Programming
                 Some Basic Stuff…




Microprocessor

          14
                              Jump to first page
Machine Code
I   The language that the machine understands
    directly without the need for any translation
I   It is essentially numbers.
    N   To the machine, each number is an instruction to
        execute or a piece of data to process
    N   Numbers are hard to memorize
    N   Branching/jumps must be calculated by the programmer
I   All Programs must be translated to machine codes,
    either directly or indirectly, in order to be executed


Microprocessor

          15
                                                 Jump to first page
Assembly Language
I    Use mnemonics (memory aid) instead of numbers
I    Classified as a Low Level Language
I    Processor-specific
      N An assembly language program written for a
        particular processor family is not compatible with
        other processors
I    Assembler
      N Converts assembly language program to
        machine code

    Microprocessor

              16
                                                   Jump to first page
High Level Programming
Languages
I   Powerful programming constructs, a more friendly operator interface
    and correspondingly easy to use
I   This type of code is often portable implying that the code can be
    compiled for a range of target systems
I   Compiler
     N Converts high level language program to machine code or
        sometimes to assembly language (Most C compilers do this)
     N C, C++, Pascal, Java…
I   Interpreter
     N Executes single lines of the program in real-time (does not produce
        code)
     N BASIC, Java, Javascript…
I   Compilers and interpreters are machine specific
    Microprocessor

              17
                                                          Jump to first page
Considerations when choosing a
programming language…
  I   Speed
       N Generally, assembly language programs run
         faster than equivalent high level language
         programs
       N However, the intermediate step (assembly or
         compilation) slows down program development.
  I   Real-Time Applications
       N These are applications where considerations
         outside of the program determine the programs
         completion time.
 Microprocessor

           18
                                              Jump to first page
      Assembly Language:
      The Translation Process
          Assemble              Link   Load

I   Assembler
     N Undertakes the
       initial translation of
       an assembly                     I   Hex file or S file
                                           are useful for
       language module                     downloading over
       into machine code                   serial lines
       (the object file)

       Microprocessor

                 19
                                             Jump to first page
 An example of an Intel HEX file:
:10001300AC12AD13AE10AF1112002F8E0E8F0F2244
:10000300E50B250DF509E50A350CF5081200132259
:03000000020023D8
:0C002300787FE4F6D8FD7581130200031D
:10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016
:04003F00A42EFE22CB
 An example of a Motorola S file:
 S00B00004441544120492F4FF3
 S113000000FF0004000400040004000400040004D1
 S113001000040004000400040004000400040004BC
 S113002000040004000400040004000400040004AC
 S1130030000400040004000400040004000400049C
 S1130040000400040004000400040004000400048C
   Microprocessor   Another example can be found in Antonakos,pg 409
             20
                                                       Jump to first page
The process that produces an executable file
I An assembler translates a file of assembly

  language into an object file, which is linked with
  other files and libraries into an executable file.
 Microprocessor

           21
                                           Jump to first page
Linker
I   Links
    assembled
    object files and
    libraries for
    complete
    programs, then
    constructs an
    executable file
                       Executable file




    Microprocessor

              22
                                 Jump to first page
Loader
I   Loads the program into physical memory from
    where it can be executed (Loaded and
    Relocated)




Microprocessor

          23
                                       Jump to first page
The Assembler
Translates program text into a form much closer to
the microprocessor machine language (object code)


          Line of Source        One or more
               Code              Bytes of
                                object code

      I   Before returning to the operating system, the
          assembler saves the object code to a suitably
          named file
      I   Most Assemblers are two pass.
           N 1st pass - constructs a symbol table
           N 2nd pass - creates the object code
Microprocessor

          24
                                                 Jump to first page
Programming Stages
                                                                                   Idea for a
                                                                                    Program


                                                           Design It on Paper


                                        Write Assembly
                                       Code and Debug
                                       for Syntax Errors

                      Compile & Link                                   ADD.B D3,D6
                       into Machine
                       readable code
 Download to 68000
 and debug/test for
   Logical errors                           1101 111 000 000 0112               DE0316

 Microprocessor
                        Success
            25
                                                                            Jump to first page
Writing Assembly Code
There are opportunities for errors to occur at two
stages of the programming cycle. If errors of either
type exist then it is necessary to go back and modify
the source code


  Write          Assemble   Syntax                  Logical
                                     Test &
 Source           Source     Error                   Error
                                     Debug
  Code             Code




Microprocessor

          26
                                              Jump to first page
Microprocessor

          27
                 Jump to first page

								
To top