1 / 31

Programming the Microprocessor

Programming the Microprocessor. A Course in Microprocessor Electrical Engineering Dept. University of Indonesia. To develop programs and programming techniques using : the MASM macro assembler program, the DOS function calls, and the BIOS function Calls (see Appendix A).

Download Presentation

Programming the Microprocessor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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(cont’d) • 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(cont’d) • 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(cont’d) • 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(cont’d) • 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(cont’d) • 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 key;otherwise, it returns without any key • allows an entire character line to be read from the keyboard

  11. Using The Keyboard and Video Display (cont’d) • 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 (cont’d) • 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 (cont’d) • 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 pointingdevice 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

More Related