+ All Categories
Home > Documents > Chapter7.1-mikroprocessor

Chapter7.1-mikroprocessor

Date post: 12-Nov-2014
Category:
Upload: teknik-komputer-ui
View: 448 times
Download: 1 times
Share this document with a friend
Description:
 
Popular Tags:
31
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia
Transcript
Page 1: Chapter7.1-mikroprocessor

Programming the Microprocessor

A Course in Microprocessor

Electrical Engineering Dept.

University of Indonesia

Page 2: Chapter7.1-mikroprocessor

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)

Page 3: Chapter7.1-mikroprocessor

3

Some programming techniques :

Macro sequences keyboard and display manipulation program modules library files using the mouse interrupt hooks

Page 4: Chapter7.1-mikroprocessor

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

Page 5: Chapter7.1-mikroprocessor

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 )

Page 6: Chapter7.1-mikroprocessor

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

Page 7: Chapter7.1-mikroprocessor

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

Page 8: Chapter7.1-mikroprocessor

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

Page 9: Chapter7.1-mikroprocessor

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

Page 10: Chapter7.1-mikroprocessor

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

Page 11: Chapter7.1-mikroprocessor

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 )

Page 12: Chapter7.1-mikroprocessor

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)

Page 13: Chapter7.1-mikroprocessor

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 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

Page 14: Chapter7.1-mikroprocessor

14

Page 15: Chapter7.1-mikroprocessor

15

Page 16: Chapter7.1-mikroprocessor

16

Page 17: Chapter7.1-mikroprocessor

17

Page 18: Chapter7.1-mikroprocessor

18

Page 19: Chapter7.1-mikroprocessor

19

Page 20: Chapter7.1-mikroprocessor

20

Page 21: Chapter7.1-mikroprocessor

21

Page 22: Chapter7.1-mikroprocessor

22

Page 23: Chapter7.1-mikroprocessor

23

Page 24: Chapter7.1-mikroprocessor

24

Page 25: Chapter7.1-mikroprocessor

25

Page 26: Chapter7.1-mikroprocessor

26

Page 27: Chapter7.1-mikroprocessor

27

Page 28: Chapter7.1-mikroprocessor

28

Page 29: Chapter7.1-mikroprocessor

29

Page 30: Chapter7.1-mikroprocessor

30

Page 31: Chapter7.1-mikroprocessor

31


Recommended