INTRODUCTION

1.2Programming a Microcomputer counts the number of words to be stored.

1.2.1 Machine Language Programming

When finished the processor continues on

to the next instructions.

 

A microprocessor is instructed what to do by programming it with a series of instructions stored in Program Memory. The processor fetches these instructions one at a time and performs the operation indicated. These instructions must be stored in a form that the processor can understand. This format is referred to as Machine Language. For most microprocessors this instruction is a group of a binary bits (1'sand O's)called a word (also called a byte if the word is a-bits). Some instructions require more than one location in Program Memory. To execute a multi-byte instruction, the processor must execute multiple fetches of program memory before performing the instruction. Because mUlti- byte instructions take more Program Mem- ory and take longer to execute than single byte instructions their use is usually kept to a minimum.

A processor may be programmed by writing a sequence of instructions in the binary code (ones and zeros) which the machine can interpret directly. This is machine language programming and it is very useful where the program to be written is small and the application requires that the designer have an intimate knowledge of the microprocessor. Machine language pro- gramming allows the user, because of his detailed knowledge, to use many program- ming "tricks" to produce the most compact and efficient code possible.

The following is an example of a machine language program: This program reads 5 sequential 8-bit words in from an I/O port and stores them sequentially in data memory. The program starts by initializing two registers, one which determines where the data is to be stored and another which

Step Machine

Number Code Explanation

01011 1000 Load decimal 32 in

100100000 register RO

21011 1010 Load decimal 5 in

300000101 register R2

400001001 Load Port 1 to accu- mulator

510100000 Transfer contents of accumulator to reg- ister addressed by register 0

60001 1000 Increment RO by 1

711101010 Decrement register 2

80000 0100 by 1, if result is zero continue to step 9, if not go to step 4

9

10

As you can see, writing machine instruc- tions in ones and zeros can be very laborious and subject to error. It is almost always more efficient to represent each a-bits of machine language code in a shorthand format called Hexadecimal. The term hexadecimal results from the character set used in hexadecimal notation. Hexadecimal is merely an extension of the normal decimal numbers by the addition of the first six letters of the alphabet. This gives a total of 16 different characters. Each hexadecimal "digit" can represent 16 values or the equivalent of four binary bits; therefore, each a-bit machine language word can be represented by 2 hexadecimal (hex for short) digits. The correspondence among the decimal, binary, and hex number systems is given below:

1-10

Page 19
Image 19
Intel mcs-48 manual When finished the processor continues on, To the next instructions