Programming the Microprocessor - PowerPoint PPT Presentation

About This Presentation
Title:

Programming the Microprocessor

Description:

Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia Some programming techniques : Macro sequences keyboard ... – PowerPoint PPT presentation

Number of Views:188
Avg rating:3.0/5.0
Slides: 32
Provided by: acid150
Category:

less

Transcript and Presenter's Notes

Title: Programming the Microprocessor


1
Programming the Microprocessor
  • A Course in Microprocessor
  • Electrical Engineering Dept.
  • University of Indonesia

2
  • To develop programs and programming techniques
    using
  • the MASM macro assembler program,
  • the DOS function calls,
  • and the BIOS function Calls
  • (see Appendix A)

3
Some programming techniques
  • Macro sequences
  • keyboard and display manipulation
  • program modules
  • library files
  • using the mouse
  • interrupt hooks

4
Modular Programming
  • The assembler and Linker
  • The assembler program converts a symbolic source
    module (file) into a hexadecimal object file
  • Example 7-1 shows how the assembler dialog that
    appears as a source module named NEW.ASM is
    assembled
  • Source file are created using WorkBench, an
    editor that comes with the assembler, or by
    almost any other word processor or editor capable
    of generating an ASCII file

5
Modular Programming(contd)
  • The linker program
  • which executes as the second part of ML, reads
    the object files, created by the assembler
    program, and links them into a single execution
    file (.EXE)
  • Example 7-2 shows the protocol involved with the
    linker program when it is used to link the files
    NEW, WHAT, and DONUT
  • PUBLIC and EXTRN
  • PUBLIC is used to declare that labels of code,
    data, or entire segments are available to other
    program modules ( see Example 7-3 )

6
Modular Programming(contd)
  • EXTRN (external) is used to declare that labels
    are external to a module (see Example 7-4)
  • Libraries
  • they are collections of procedures that can be
    used by many different programs
  • The procedures are assembled and compiled into a
    library file by the LIB program that accompanies
    the MASM assembler program
  • Creating a Library File
  • is created with the LIB command typed at the DOS
    prompt

7
Modular Programming(contd)
  • is a collection of assembled .OBJ files that each
    perform one procedure or task (see Example 7-5)
  • After each file is assembled, the LIB program is
    used to combine them into a library file (see
    Example 7-6)
  • Macros
  • it is a group of instructions that perform one
    task, just as a procedure performs one task
  • the difference is that a procedure is accessed
    via a CALL instruction, while a macro is inserted
    in the program at the point of usage as a new
    sequence of instructions

8
Modular Programming(contd)
  • the MACRO and ENDM directives are used to
    delineate a macro sequence
  • Example 7-8 shows how a macro is created and used
    in a program
  • Local Variables in a Macro
  • A local variable is one that appears in the
    macro, but is not available outside the macro
  • To define a local variable, use the LOCAL
    directive
  • See Example 7-9

9
Modular Programming(contd)
  • Conditional Statement in Macro Sequences
  • create instructions that control the flow of the
    program
  • they are variations of IF-THEN, IF-THEN-ELSE,
    DO-WHILE, FOR and REPEAT-UNTIL statement
  • See Table 7-1, Table 7-2, Example 7-10, 7-11,
    7-12, 7-13, 7-14

10
Using The Keyboard and Video Display
  • Reading the Keyboard with DOS Functions
  • the keyboard of PC is read via a DOS function
    call
  • There are three ways to read the keyboard
  • reads a key and echoes (or displays) the key on
    the video screen
  • simply tests to see if a key is pressed-if it is,
    the function reads the keyotherwise, it returns
    without any key
  • allows an entire character line to be read from
    the keyboard

11
Using The Keyboard and Video Display (contd)
  • Reading a Key with an Echo
  • Example 7-15 shows how a key is read from the
    keyboard and echoed (sent) back out to the video
    display using a prosedure called KEY
  • Reading a Key without an Echo
  • Example 7-16 shows a procedure that uses function
    number 06H to read the keyboard
  • Read an Entire Line with an Echo
  • Use one function call (number 0AH). This function
    reads an entire line of information-up to 255
    characters-from the keyboard (see Example 7-17 )

12
Using The Keyboard and Video Display (contd)
  • Writing to the Video Display with DOS Functions
  • Use functions 02H or 06H for displaying one
    character at a time or function 09H for
    displaying an entire string of characters (see
    Example 7-18 and 7-19
  • Using BIOS Video Function Calls at INT 10H (see
    Table 7-4 and Example 7-20)

13
Using The Keyboard and Video Display (contd)
  • Display Macro
  • a register can be specified as the argument, an
    ASCII character in quotes, or the numeric value
    for an ASCII character (see Example 7-22)
  • The Mouse
  • The mouse pointing device is controlled with INT
    33H
  • The function number is selected through the AL
    register an AH is usually set to 00H before the
    INT 33H is executed

14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com