Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia
<ul><li>To develop programs and programming  techniques using : </li></ul><ul><ul><li>the MASM macro assembler program,  <...
Some programming techniques : <ul><li>Macro sequences </li></ul><ul><li>keyboard and display manipulation </li></ul><ul><l...
Modular Programming <ul><ul><li>The assembler and Linker </li></ul></ul><ul><ul><ul><li>The  assembler program  converts a...
Modular Programming(cont’d) <ul><ul><li>The linker program </li></ul></ul><ul><ul><ul><li>which executes as the second par...
Modular Programming(cont’d) <ul><ul><ul><li>EXTRN  (external) is used to declare that labels are external to a module (see...
Modular Programming(cont’d) <ul><ul><ul><ul><li>is a collection of assembled .OBJ files that each perform one procedure or...
Modular Programming(cont’d) <ul><ul><ul><li>the  MACRO  and  ENDM  directives are used to delineate a macro sequence  </li...
Modular Programming(cont’d) <ul><ul><ul><li>Conditional Statement in Macro Sequences </li></ul></ul></ul><ul><ul><ul><ul><...
Using The Keyboard and Video Display  <ul><li>Reading the Keyboard with DOS Functions </li></ul><ul><ul><li>the keyboard o...
Using The Keyboard and Video Display  (cont’d) <ul><ul><li>Reading a Key with an Echo </li></ul></ul><ul><ul><ul><li>Examp...
Using The Keyboard and Video Display  (cont’d) <ul><li>Writing to the Video Display with DOS Functions </li></ul><ul><ul><...
Using The Keyboard and Video Display  (cont’d) <ul><li>Display Macro </li></ul><ul><ul><li>a register can be specified as ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Upcoming SlideShare
Loading in …5
×

Chapter7.1-mikroprocessor

449 views

Published on

  • Be the first to comment

  • Be the first to like this

Chapter7.1-mikroprocessor

  1. 1. Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia
  2. 2. <ul><li>To develop programs and programming techniques using : </li></ul><ul><ul><li>the MASM macro assembler program, </li></ul></ul><ul><ul><li>the DOS function calls, </li></ul></ul><ul><ul><li>and the BIOS function Calls </li></ul></ul><ul><ul><li>(see Appendix A) </li></ul></ul>
  3. 3. Some programming techniques : <ul><li>Macro sequences </li></ul><ul><li>keyboard and display manipulation </li></ul><ul><li>program modules </li></ul><ul><li>library files </li></ul><ul><li>using the mouse </li></ul><ul><li>interrupt hooks </li></ul>
  4. 4. Modular Programming <ul><ul><li>The assembler and Linker </li></ul></ul><ul><ul><ul><li>The assembler program converts a symbolic source module (file) into a hexadecimal object file </li></ul></ul></ul><ul><ul><ul><li>Example 7-1 shows how the assembler dialog that appears as a source module named NEW.ASM is assembled </li></ul></ul></ul><ul><ul><ul><li>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 </li></ul></ul></ul>
  5. 5. Modular Programming(cont’d) <ul><ul><li>The linker program </li></ul></ul><ul><ul><ul><li>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 ) </li></ul></ul></ul><ul><ul><ul><li>Example 7-2 shows the protocol involved with the linker program when it is used to link the files NEW , WHAT , and DONUT </li></ul></ul></ul><ul><ul><li>PUBLIC and EXTRN </li></ul></ul><ul><ul><ul><li>PUBLIC is used to declare that labels of code, data, or entire segments are available to other program modules ( see Example 7-3 ) </li></ul></ul></ul>
  6. 6. Modular Programming(cont’d) <ul><ul><ul><li>EXTRN (external) is used to declare that labels are external to a module (see Example 7-4 ) </li></ul></ul></ul><ul><ul><li>Libraries </li></ul></ul><ul><ul><ul><li>they are collections of procedures that can be used by many different programs </li></ul></ul></ul><ul><ul><ul><li>The procedures are assembled and compiled into a library file by the LIB program that accompanies the MASM assembler program </li></ul></ul></ul><ul><ul><ul><li>Creating a Library File </li></ul></ul></ul><ul><ul><ul><ul><li>is created with the LIB command typed at the DOS prompt </li></ul></ul></ul></ul>
  7. 7. Modular Programming(cont’d) <ul><ul><ul><ul><li>is a collection of assembled .OBJ files that each perform one procedure or task (see Example 7-5 ) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>After each file is assembled, the LIB program is used to combine them into a library file (see Example 7-6 ) </li></ul></ul></ul></ul><ul><ul><li>Macros </li></ul></ul><ul><ul><ul><li>it is a group of instructions that perform one task, just as a procedure performs one task </li></ul></ul></ul><ul><ul><ul><li>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 </li></ul></ul></ul>
  8. 8. Modular Programming(cont’d) <ul><ul><ul><li>the MACRO and ENDM directives are used to delineate a macro sequence </li></ul></ul></ul><ul><ul><ul><li>Example 7-8 shows how a macro is created and used in a program </li></ul></ul></ul><ul><ul><ul><li>Local Variables in a Macro </li></ul></ul></ul><ul><ul><ul><ul><li>A local variable is one that appears in the macro, but is not available outside the macro </li></ul></ul></ul></ul><ul><ul><ul><ul><li>To define a local variable, use the LOCAL directive </li></ul></ul></ul></ul><ul><ul><ul><ul><li>See Example 7-9 </li></ul></ul></ul></ul>
  9. 9. Modular Programming(cont’d) <ul><ul><ul><li>Conditional Statement in Macro Sequences </li></ul></ul></ul><ul><ul><ul><ul><li>create instructions that control the flow of the program </li></ul></ul></ul></ul><ul><ul><ul><ul><li>they are variations of IF-THEN , IF-THEN-ELSE , DO-WHILE , FOR and REPEAT-UNTIL statement </li></ul></ul></ul></ul><ul><ul><ul><ul><li>See Table 7-1 , Table 7-2 , Example 7-10 , 7-11 , 7-12 , 7-13 , 7-14 </li></ul></ul></ul></ul>
  10. 10. Using The Keyboard and Video Display <ul><li>Reading the Keyboard with DOS Functions </li></ul><ul><ul><li>the keyboard of PC is read via a DOS function call </li></ul></ul><ul><ul><li>There are three ways to read the keyboard : </li></ul></ul><ul><ul><ul><li>reads a key and echoes (or displays) the key on the video screen </li></ul></ul></ul><ul><ul><ul><li>simply tests to see if a key is pressed-if it is, the function reads the key;otherwise, it returns without any key </li></ul></ul></ul><ul><ul><ul><li>allows an entire character line to be read from the keyboard </li></ul></ul></ul>
  11. 11. Using The Keyboard and Video Display (cont’d) <ul><ul><li>Reading a Key with an Echo </li></ul></ul><ul><ul><ul><li>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 </li></ul></ul></ul><ul><ul><li>Reading a Key without an Echo </li></ul></ul><ul><ul><ul><li>Example 7-16 shows a procedure that uses function number 06H to read the keyboard </li></ul></ul></ul><ul><ul><li>Read an Entire Line with an Echo </li></ul></ul><ul><ul><ul><li>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 ) </li></ul></ul></ul>
  12. 12. Using The Keyboard and Video Display (cont’d) <ul><li>Writing to the Video Display with DOS Functions </li></ul><ul><ul><li>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 </li></ul></ul><ul><li>Using BIOS Video Function Calls at INT 10H (see Table 7-4 and Example 7-20 ) </li></ul>
  13. 13. Using The Keyboard and Video Display (cont’d) <ul><li>Display Macro </li></ul><ul><ul><li>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 ) </li></ul></ul><ul><li>The Mouse </li></ul><ul><ul><li>The mouse pointing device is controlled with INT 33H </li></ul></ul><ul><ul><li>The function number is selected through the AL register an AH is usually set to 00H before the INT 33H is executed </li></ul></ul>

×