15

Use of PC in Writing and Executing 8085 Programs

images Steps needed to run an assembly language program

images Assembly language program

images Creation of .ASM file using a text editor

images Generation of .OBJ file using a cross-assembler

images Translation in prompt mode

images Translation in command mode

images Generation of .HEX file using a linker

images Prompt mode

images Command mode

images Data file mode

images Downloading the machine code to the kit

images Setting up the ALS-SDA-85 kit for serial mode

images Running the downloaded program on the kit

images Running the program using the PC as a terminal

images Running the entire program in a single operation

images Running the program in single-step mode

images Questions

In Chap. 5, we have discussed the use of the kit in the keyboard mode. In this case, the user had to translate the assembly language program into machine code, and enter the program in hexadecimal using the keyboard. This translation is quite monotonous, especially when the program is quite long.

If we have a computer with an ASCII keyboard, the program can be entered into the computer memory straightaway as an assembly language program. Then, the assembler program in the computer can translate this assembly language program to machine code, relieving the user from this monotonous task.

The machine code can finally be downloaded from the computer to the kit using RS-232C serial link. The user can then execute the downloaded program on the kit.

Also, the user can upload a machine language program from the memory of the kit to the hard disk or the floppy disk on the computer. The hard disk or floppy disk is non-volatile, which means it does not lose the information even after power is switched off and then turned on. Thus the user programs can be stored as disk files on the computer, for downloading later to the kit for execution.

However, the cost goes up in serial mode, as a computer is a must in addition to the kit. Also, there must be an assembler software on the computer. The circuitry and the monitor software on the kit also is increased. But, with the reduction in cost of hardware and software, and the increase in cost of technical manpower, software development tools become necessary. Assembler is one such major software development tool. Use of assembler is explained in this chapter.

images 15.1 STEPS NEEDED TO RUN AN ASSEMBLY LANGUAGE PROGRAM

The following steps are needed for running an assembly language program.

  • Entering the program on a PC using a text editor. The file so created is given a suitable file name with .ASM extension.
  • The file with .ASM extension is assembled to machine code using a 8085 cross-assembler. This generates the file with .OBJ extension.
  • The file with .OBJ extension is linked to generate Intel Hex file using a linker. This generates the file with .HEX extension.
  • The file with .HEX extension is downloaded to the kit using RS-232C serial interface and driver software.
  • The program can now be executed on the kit using the keyboard mode of operation. Alternatively, serial monitor commands can be used to run the program. In such a case, the commands are issued using the PC, and the results are displayed on the CRT terminal of the PC. This method is more user-friendly, and the development of programs will be faster. Figure 15.1 illustrates the steps needed for running an assembly language program.

images

Fig. 15.1 Steps needed to run an assembly language program

To illustrate the various processes starting from entering the program, to final testing of the program, we consider a very simple assembly language program.

15.1.1 ASSEMBLY LANGUAGE PROGRAM

Let us say, we have some 8-bit numbers in symbolic memory locations X and Y. We want to compute their product and store the 16-bit result in symbolic memory location Z and Z+1.

We need to have memory locations X and Y in the RAM area of the kit. The RAM space in the kit is C000H to C7FFH. So let us arbitrarily choose X as memory location C100H, Y as memory location C200H, and Z as memory location C300H. Let us say we want the program to start at location C000H.

Assembly language program to solve this simple problem is as follows. This problem was discussed towards the end of the previous chapter.

ORG C100H   ; ORG can be replaced by ORIGIN
X:         DB 04H           ; DB can be replaced by .DB, BYTE, or .BYTE

           ORG C200H
Y:         DB       05H

           ORG C300H
Z:         DW                  ;DW can be replaced by .DW, WORD, or .WORD

           ORG C000H

CURAD:     EQU  FFF7H ;EQU can be replaced by EQUAL
UPDAD:     EQU  06BCH

BEGIN:     LXI H,X
           MOV E, M
           MVI D, 00H

           LXI H, Y
           MOV A, M

           LXI H, 0000H
           CPI 00H
           JZ EXIT

AGAIN:    DAD D
DCR A
JNZ AGAIN

EXIT:     SHLD Z

          SHLD CURAD
          CALL UPDAD
          HLT        ;CHANGE THIS TO ‘RST 1’ FOR SERIAL MODE
          END BEGIN

Assembly language programs make use of the following features in addition to instruction mnemonics.

  • – Assembler directives like ORG, DB, DW, EQU, etc.
  • – Symbolic addresses like X in ‘LXI H, X’ instruction
  • – Labels like EXIT for an instruction like SHLD Z
  • – Comments are liberally used to make the program understandable.

Assembler Directives: Assembler directives are also called as pseudoinstructions. There are a number of assembler directives. They enable us to control the way a program is assembled and listed. They do not generate any machine code for execution. The most commonly used assembler directives are ORG, DB, DW, EQU, and END.

ORG Directive: This directive provides the origin or starting address for the assembly. It can also be written as ORIGIN. If this directive is not used, the starting address defaults to 0000H. For example, ORG C100H directive informs the assembler to assemble the code or data that follows the ORG directive from memory location C100H.

DB Directive: DB stands for define byte. It can also be written as .DB or .BYTE or BYTE. This directive reserves 1 byte of memory and initializes it with the value following the DB directive. If no value is indicated after the DB directive, the value defaults to 00H. If more than one value is indicated with comma as the separator, they are stored in consecutive byte locations.

Example 1

ORG C150H
P:     DB 12H

This tells the assembler that P is a symbolic memory location where a byte value of 12H is stored. Because of the ORG C150H directive, symbolic address P is treated as memory address C150H. In the previous example, 12H could have been written in any of the following equivalent ways:

  • — 12h (in hexadecimal notation);
  • — 18 or 18D or 18d (in decimal notation);
  • — 00010010B or 00010010b or 10010B or 10010b (in binary);
  • — 22O or 22o or 22Q or 22q (in octal notation).

Example 2

ORG C400H
Q:        DB

This tells the assembler that Q is a symbolic memory location where a byte value of 00H (default value) is stored. Because of the ORG C400H directive, symbolic address Q is treated as memory address C400H.

Example 3

ORG C500H
R:         DB 04H,23,15D,00111010B,22Q,33O

Because of the ORG C500H directive, symbolic address R is treated as memory address C500H. Starting from location C500H the following values are stored in consecutive locations: 04H, 17H (23 decimal), 0FH (15 decimal), 3AH (00111010 binary), 12H (22 octal), and 1BH (33 octal).

Memory location containing 17H (23 decimal) is referred to as symbolic location R+1. Similarly, location R12 contains 0FH, etc.

DW Directive: DW stands for define word. It can also be written as .DW or .WORD or WORD. This directive reserves one word of memory (2-byte locations) and initializes it with the value following the DW directive. If no value is indicated after the DW directive, the value defaults to 0000H. If more than one value is indicated with comma as the separator, they are stored in consecutive word locations.

Example 1

ORG C150H
P:         DW 1234H

This tells the assembler that P is a symbolic memory location where a word value of 1234H is stored. Because of the ORG C150H directive, symbolic address P is treated as memory address C150H. In location P the value 34H is stored, and in location P+1 the value 12H is stored. This is the byte reversal method of word information storage. In the earlier example, 1234H could have been written using decimal, octal, or binary notation also.

Example 2

ORG C400H
Q:        DW

This tells the assembler that Q is a symbolic memory location where a word value of 0000H (default value) is stored. Because of the ORG C400H directive, symbolic address Q is treated as memory address C400H.

Example 3

ORG C500H
R:         DW 04H, 23

Because of the ORG C500H directive, symbolic address R is treated as memory address C500H. Value 0004H is stored in byte reversal form in word location C500H, and 0017H (23 decimal) is stored in byte reversal form in word location C502H. Memory location containing 17H (23 decimal) is referred to as symbolic location R+2.

EQU Directive: This directive equates the label to the left of EQU directive with the value to the right of the EQU directive. The value on the right of the EQU directive could be a number or an arithmetic expression or another symbol.

Normally, there will be a number to the right of the EQU directive. The EQU directive can also be written as EQUAL. The EQU directive does not reserve any memory locations, and it does not initialize the contents of any memory location.

Example

CURAD:          EQU FFF7H

This indicates that wherever we come across CURAD, it is to be treated as FFF7H. For example, if we come across the instruction ‘SHLD CURAD’, it is to be treated as ‘SHLD FFF7H’.

END Directive: This directive defines the physical end of a program. There can be a symbolic address immediately following the END directive. It is optional. If the address is specified, it indicates the program starting address. Without this address, the program execution will be from the first executable instruction in the program.

In the earlier program we have used ‘END BEGIN’. It could have been just END directive without the address following. In fact, the program is correctly translated even without the END directive. As such, END is not compulsory in a program. The assembly process is terminated when end of the file is encountered.

What is the need for END directive when HLT instruction informs the processor to halt? The answer is: HLT is an executable instruction of 8085. It is translated by the assembler. Generally HLT is the last instruction in many simple programs. But, in more lengthy programs, HLT instruction can be seen at many places in the program. In such a case, the translation operation by the assembler should not stop at the first occurrence of the HLT instruction! The END directive appears only at the end of the program, and clearly indicates to the assembler that the translation is to be stopped.

Symbolic Addresses: In the earlier program we came across the instruction ‘LXI H, Y’. In this instruction, Y is a symbolic memory location that stands for memory location C200H. Thus ‘LXI H, Y’ is same as ‘LXI H, C200H’. This is because, using the ORG directive as shown below, we have indicated that Y stands for memory location C200H.

ORG C200H
Y:         DB  05H

Similarly X stands for memory location C100H, and Z stands for memory location C300H.

Labels: In the earlier program we see the instruction ‘AGAIN: DAD D’. This instruction is at memory location C012H. In this instruction, AGAIN is a label. It stands for memory location C012H, where the instruction is stored. There must be a colon between a label and an instruction.

A little later in the program we come across the instruction ‘JNZ AGAIN’, which now stands for ‘JNZ C012H’. With this feature, the programmer simply provides a symbolic name or label to a branch destination, and uses that symbolic name in the branch instruction as the branch destination. Similarly in the instruction ‘EXIT: SHLD Z’, EXIT is a label, which stands for memory location C017H.

Comments: Comments are liberally used to make the program understandable. What is present in a line after a semicolon is treated as a comment, and is not translated. A comment can be just after an instruction or an assembler directive, and is separated by a semicolon. If we want the entire line to be a comment, the line should start with a semicolon.

images 15.2 CREATION OF .ASM FILE USING A TEXT EDITOR

The assembly language program is entered using any editor, preferably a screen editor. While entering the program, the exact column at which label, instruction, and comment start is unimportant. But the instruction should start after column 1. However, the program is easy to read if the various fields are properly aligned. Any editor generally provides a help feature, using which the user can become familiar with the editor commands, and use them to enter the program.

The file so created is given a suitable file name with .ASM extension. For example, the earlier program may be entered as a file using, say, Norton editor with MULT.ASM as the file name. This .ASM file is called the source file.

images 15.3 GENERATION OF .OBJ FILE USING A CROSS-ASSEMBLER

The MULT.ASM created using an editor is just a text file. It cannot be directly executed. We have to first assemble, and then link it. The assembly step involves translating the assembly language program into machine code. This step generates an .OBJ file.

In the examples given in this text, we have used ‘2500 A.D. 8085 cross-assembler—version 4.01’.

15.3.1 TRANSLATION IN PROMPT MODE

Type ‘X8085<cr>’ to perform translation in prompt mode. Here, ‘<cr>’ stands for ‘carriage return’, which is done by typing the key on which ‘Enter’, is marked. The assembler prompts at every step in this mode. The advantage then is that there is no need to memorize the required steps.

After typing ‘X8085<cr>’ the assembler will prompt with:

Listing destination? (N, T, P, D, E, L, <cr> = N>)

where listing stands for listing the source code, object code, and details of errors encountered, if any. The listing could be on terminal, or printed using printer, or stored as a file with .LST extension on disk. Further the listing, if desired, could be confined to listing only erroneous source code lines.

In the equation shown, the abbreviations stand for:

  • N—None (no listing will be made),
  • T—Terminal (listing will be on terminal),
  • P—Printer (listing will be printed using printer),
  • D—Disk (listing stored as a .LST disk file),
  • E—Error only will be listed,
  • L—List On/Off (refer to manual for details).

If we are not interested in listing, just type ‘<cr>’. However, it is good to respond with typing ‘T’. Then, the listing will be on terminal. The listing will pause at the source code where an error occurs. The user can note the error, and then type ‘<cr>’ to proceed further and see the next error. If we respond with typing ‘E’, the assembler will prompt the user as follows:

Error only listing destination? (T, P, D, <cr> = T)

If we respond with ‘<cr>’, the errors only will be listed on the terminal. In case many errors are encountered during the assembly process, it is better to generate a .LST file on the disk by responding to the prompt with ‘D’. Anyway, after the user responds to the prompt for listing destination, the assembler prompts the user for the source file as shown:

Input filename :

The user should respond with the source file name. In this example, the user should respond with ‘MULT.ASM’. Even ‘MULT’ will suffice. Then the assembler prompts the user for output file name as follows:

Output filename :

If the user responds with ‘<cr>’, the output file name in this example would be ‘MULT.OBJ’. If the user responds with ‘DIV’, the output file name would be ‘DIV.OBJ’. Generally, the user responds to the output file name prompt with ‘<cr>’.

Suppose we choose to generate MULT.LST file on disk for this example. Then using a text editor we can see the contents of MULT.LST and identify the errors. After this, we make the necessary corrections in MULT.ASM file using the editor.

Finally, when the assembly process is successful without any error, the result will be placed in MULT.OBJ file.

15.3.2 TRANSLATION IN COMMAND MODE

The translation in command mode takes less number of steps. But the steps have to be remembered. We generally use this mode when we are very familiar with the necessary steps.

Type ‘X8085 MULT.ASM <cr>’ to perform translation in command mode. Even ‘MULT’ will suffice in place of ‘MULT.ASM’. The source code in MULT.ASM is translated to the object code. The result will be placed in MULT.OBJ file.

To help in debugging the source code during assembly, we commonly use the following options depending on the user taste and convenience. It is assumed that the source file name is ‘MULT.ASM’.

Option Function
X8085 MULT-T Displays listing on terminal. It pauses
when error is encountered
Continues when <cr> is pressed
X8085 MULT-P Prints listing using printer
X8085 MULT-D Generates .LST file on disk
X8085 MULT-ET Displays only error listing on terminal
X8085 MULT-EP Prints only error listing using printer
X8085 MULT-ED Generates .LST file containing errors only

Suppose we choose to generate MULT.LST file on disk for this example. Then using a text editor we can see the contents of MULT.LST and identify the errors. After this, using the editor we make the necessary corrections in MULT.ASM file.

Finally, when the assembly process is successful without any error, the result will be placed in MULT.OBJ file. For more details about the assembler, refer to the assembler manual.

images 15.4 GENERATION OF .HEX FILE USING A LINKER

The next step is to link the object module MULT.OBJ, which contains the machine code. We use the ‘2500 A.D. linker’. The linker enables the user to write assembly language programs consisting of several object modules. The linker will resolve external references and performs address relocation. This linker is capable of generating all of the most common file formats. Thus, it eliminates the need for an additional format conversion. The linker may be invoked in prompt mode, command line mode, or data file mode.

15.4.1 PROMPT MODE

To run the linker in this mode type ‘LINK85<cr>’. The linker will respond with a prompt requesting the user for file name. In this example, respond with ‘MULT.OBJ<cr>’. Even ‘MULT<cr>’ will suffice.

Then the linker will prompt for the offset address. This offset value input by the user is added to the value of any ORG statements in the file. Generally, the user responds with <cr>, so that there is no offset value.

The linker then prompts for an output file name. Generally the user responds with <cr>. This causes the linker to generate an output file with the same name as the input file, but with a three-character extension that is determined by the output file type.

After the output file name is entered (or after responding with <cr>), the linker will prompt for library file names. We respond with <cr> in simple programs where we are not using library file names.

Then the linker will prompt for any linker options. For this we respond with <cr>, which results in generating .HEX file. In our example, the file created by the linker will be MULT.HEX, which will be in Intel HEX format. For more details about the linker refer to the ‘X8085 cross-assembler’ manual.

15.4.2 COMMAND MODE

To run the linker in this mode type ‘LINK85 -C MULT.OBJ<cr>’. Just ‘MULT’ is enough in place of ‘MULT.OBJ’ in the above command. The -C option indicates that we are running the linker in command mode. This command generates MULT.HEX file, which will be in Intel Hex format. For more details about the possible options, refer to ‘X8085 cross-assembler’ manual.

15.4.3 DATA FILE MODE

Refer to ‘X8085 cross-assembler’ manual for details.

Intel Hex format: MULT.HEX file is shown below.

:01 C100 00 04 3A
:01 C200 00 05 38
:02 C300 00 00 00 3B
:10 C000 00 21 00 C1 5E 16 00 21 00 C2 7E 21 00 00
FE 00 CA 90
:10 C010 00 17 C0 19 3D C2 12 C0 22 F7 FF 22 00
C3 CD BC 06 D3
:01 C020 00 76 A9
:00 0000 01 FF

The file consists of several lines called records. A record starts with the character ‘:’. The next two characters indicate the record length field in hexadecimal. If this value is 00, as it is in the last record, it indicates EOF (end-of-file) record. This will be the last line of the file. The next four characters indicate the load address field in hexadecimal. The next two characters indicate the record-type field. It will be 00 for a data record, and 01 for end of the file record. Even program code is stored as data record. Thus, only the last record will have 01 in this field. After the record-type field, except the last two characters, we have the data bytes. The last two characters form the check sum. It is generated as the 2's complement of modulo 8-bit addition of length field, load address field, record-type field, and data bytes.

For example, in the fourth line of MULT.HEX we have

:10 C000 00 21 00 C1 5E 16 00 21 00 C2 7E 21 00 00 FE 00 CA 90

It is interpreted as follows. 10 indicates that there are 10H = 16 data bytes in the record. C000 indicates that they are stored in locations starting from C000H. The 00 indicates that the record-type is Data record. The 16 data bytes in hexadecimal are 21,00, C1, …, and CA. 90 is the check sum and is obtained as follows.

10 + C0 + 00 + 00 + 21 + 00 + C1 + … + CA = 70 with carry of 5. Ignoring the carry we get the result of modulo 8-bit addition. Thus the result of modulo 8-bit addition is 70H = 0111 0000B. Its 2's complement is 1001 0000B = 90H, which is the check sum.

images 15.5 DOWNLOADING THE MACHINE CODE TO THE KIT

Now we have to download the MULT.HEX file, which is in Intel Hex format to the 8085 kit. A driver program that is used for communication between a PC and the ALS-SDA-85 kit using RS-232C interface does this. In the discussion that follows, we use PCLINK as the driver software for communication. The kit is assumed to be ALS-SDA-85M. PCLINK driver program can be used with any 8085 kit that has RS-232C interface.

First of all connect the kit to COM2 serial port of the PC using RS-232C cable. This is because generally in present-day computers, COM1 port is used for mouse, and is not free as such. However, if COM1 port is free, it can be used to connect to the kit. In the following discussion, it is assumed that COM2 port is used for connecting the kit.

Invoke the driver program by typing ‘PCLINK<cr>’. It is a menu driven program. The PCLINK program first displays a welcome message, and then displays the main menu as shown in the following.

MAIN MENU

  1. Terminal mode
  2. Disk catalog
  3. File download
  4. File upload
  5. Configuration
  6. Exit program

Enter your choice [1-6]?

First of all, select configuration choice by typing 5. Then the configuration menu appears on the screen. It indicates the current status, and allows you to change the current status by displaying the menu as follows.

CONFIGURATION MENU

  1. Baud rate
  2. Word length
  3. Stop bits
  4. Parity
  5. Serial port
  6. Exit Configuration

Enter your choice [1-6]?

Select serial port choice by typing 5. Then the display indicates the current status, and allows you to select COM1 or COM2 by displaying the menu as follows.

SERIAL PORT

  1. COM1
  2. COM2

Enter your choice [1-2]?

Select COM2 by typing 2. Then the display indicates the current status. The current status of COM2 will be generally as follows.

Baud rate : 9600 Word length : 8bits Parity : none

Stop bits : 1 Port : COM2

The menu allows you to change the current status by displaying the menu as follows.

To change, select from the following:

  1. Baud rate
  2. Word length
  3. Stop bits
  4. Parity
  5. Serial port
  6. Exit Configuration

Enter your choice [1-6]?

The current status with baud rate of 9,600, word length of 8 bits, no parity bit, and 1-stop bit is quite satisfactory. So we select Exit configuration choice by typing 6. Then once again the Main menu as shown in the following is displayed.

MAIN MENU

  1. Terminal mode
  2. Disk catalog
  3. File download
  4. File upload
  5. Configuration
  6. Exit program

Enter your choice [1-6]?

Select terminal mode choice by typing 1. This option allows us to use the PC as an ordinary display terminal. Whatever we type on the PC keyboard will appear on the screen and will be sent to the kit. Whatever is transmitted by the kit will appear on the PC screen. When we are in this mode, we have to press ‘F10’ key to exit the terminal mode and get back to Main menu.

15.5.1 SETTING UP THE ALS-SDA-85 KIT FOR SERIAL MODE

When COM2 is programmed for 9,600 baud, it is necessary that the kit is also programmed for 9,600 baud. Loading location FFA6H on the kit with 0AH and location FFA7H with 00H does this. As per the kit manual, this sets the baud rate to 9,600. Then the ‘Reset’ button on the kit is pressed. Finally, the keys ‘E’ and ‘0’ on the kit are pressed, which transfers the control to the PC. The keyboard on the kit will now be disabled (except the ‘Reset’ and ‘Vect Intr’ key). The ‘>’ prompt will now appear on the PC screen. Now we are ready to use the ‘ALS-SDA-85 serial monitor version 2.00’ commands. For setting up 8085 kits from other manufacturers, you have to refer to relevant kit manuals.

To know the various commands available in the ALS serial monitor, type ‘H<cr>’ when the ‘>’ prompt appears on the screen. Remember to type ‘H’ and not ‘h’. It accepts commands typed in capitals only. Now the following menu will be displayed on the PC screen.

images

The commands available in the serial mode of other kits can be different to some extent. Refer to relevant kit manuals for details.

To download the MULT.HEX file from the PC to the kit, type ‘L’ at the ‘>’ prompt. The system prompts the user to enter offset. Generally, we respond with <cr>. Then the following message will be displayed.

Go to main menu by pressing ‘F10’ key, and select option 3

So we press ‘F10’ key. Then the Main menu appears on the screen. Now, select option 3 (File download option). Then the following prompt appears on the screen.

Name of file to download?

Type ‘MULT.HEX<cr>’, or just ‘MULT<cr>’. The download operation from the PC to the kit starts. When the download operation is over, the main menu appears on the screen.

If our interest is to run the program on the kit using keyboard mode, we respond with selecting option 6 (exit program). If we desire to run the program on the kit using serial mode, we select option 1 (terminal mode).

images 15.6 RUNNING THE DOWNLOADED PROGRAM ON THE KIT

Now that the program has been downloaded to the kit from the PC, we can run the program in the keyboard mode, which is quite familiar by now. Just press the ‘Reset’ key on the kit. The ‘-Sda 85’ prompt appears on the seven-segment display of the kit. Now we can run the program by typing ‘Go’ key -followed by the starting address of the program. The result is displayed in the address or data field of the display, if we have used UPDAD or UPDDT utilities in the program. Otherwise, we can use ‘subst mem’ key followed by memory address to check the results stored in memory locations.

images 15.7 RUNNING THE PROGRAM USING THE PC AS A TERMINAL

Now that the program has been downloaded to the kit from the PC, we can run the program on the kit by issuing commands to the kit in serial mode, using the PC as a terminal. The result is also transmitted from the kit to the PC for display on the terminal. In this mode, the six-digit display on the kit will be blank. The program can be run in a single burst without any pause after every instruction execution. Or, we can step through the program one instruction at a time for debugging purposes.

15.7.1 RUNNING THE ENTIRE PROGRAM IN A SINGLE OPERATION

We generally run the program in this mode and hope to get the correct results straightaway. If we are unsuccessful, we attempt single-stepping through the program.

At the ‘>’ prompt, type ‘G’. Notice the absence of <cr> after G. The system prompts as follows:

Starting address: xxxx - yy/

where xxxx is a memory address and yy is the content of that memory location. It allows the user to respond with the desired starting address. If our program is to be executed from location xxxx, we just respond with <cr>. If our program is from location C000H, we respond with ‘C000<cr>’.

Then the program is executed in a fraction of a second, and the result 0014 is displayed on the terminal. In this case, 0014H (decimal 20) is the result of multiplication of 04H at C100H, and 05H at C200H.

If our program ends with a HLT instruction, as is the case, it appears that the system does not respond to commands any more, after the display of 0014. This is because the HLT instruction is executed by 8085, and so 8085 has entered the halt state. Thus the kit can no longer communicate with the PC. All we have to do is press ‘Reset’ button on the 8085 kit, and then press ‘E’ and ‘0’ keys on the kit. The ‘>’ prompt reappears, and we can issue commands from the PC keyboard.

In view of this, it is desirable to end our programs on the ALS-SDA-85 kit with ‘RST 1’ instruction instead of ‘HLT’ instruction. Even if our program uses UPDAD and UPDDT monitor routines, it is desirable to end with RST 1, when program commands are issued in serial mode. Then, as soon as 0014 is displayed on the terminal, the 8085 executes ‘RST 1’ instruction. This results in the control being transferred to the Monitor program in the EPROM of the kit. However, note that in the keyboard mode we must end the program with HLT instruction, if we are using UPDAD and/or UPDDT monitor routines.

15.7.2 RUNNING THE PROGRAM IN SINGLE-STEP MODE

This mode is useful when we find that our program has not yielded desired results after executing in a single burst. In other words, it is used for debugging the program.

At the ‘>’ prompt, type ‘S’. Notice the absence of <cr> after S. The system prompts as follows:

Starting address: xxxx - yy/

where xxxx is a memory address and yy is the content of that memory location. It allows the user to respond with the desired starting address for single-stepping. If our program is to be executed from location xxxx, we just respond with <sb>. Here <sb> stands for pressing the SPACE BAR key, which is the widest on the keyboard. If our program is from location C000H, we respond with ‘C000<sb>’.

Then the system displays ‘C000-21/’, where 21 is the content of memory location C000H. Now we respond with <sb>. Then the instruction at C000H is executed, and it displays the address of the next instruction along with the contents of that location. Only when we respond with <sb> the instruction is executed, and the address of the next instruction and the contents of that location are displayed. If we desire to stop the single-stepping, and check the contents of various registers and memory locations, we respond with <cr> instead of <sb>. Then the ‘>’ prompt reappears.

Examine registers command: To check register values, type ‘X’ without <cr>. The system prompts as follows:

Register :

The user is required to respond with the desired register name. If you want to see contents of the C register, type C without <cr>. Immediately, it responds with

C5xx-

where xx is the content of the C register, and it allows the user to enter a new value in place of xx. For example, if we want C register to have 36H, we respond with 36 and <cr> or <sb>. If the user does not want to change the contents of the register, he has to respond with <cr> or <sb>. If it is <cr>, the X command will be terminated, and the ‘>’ prompt reappears. If it is <sb>, the system displays content of D register automatically, and allows the user to optionally enter a new value into D the register. Using <sb> repeatedly, we can see the contents, and if desired modify the contents, of all registers. If we start with Register A, the sequence of registers will be as follows:

A, B, C, D, E, F, I, H, L, SPH, SPL, PCH, and PCL

where F is the Flags register, SPH and SPL are the MS and LS bytes of SP, PCH and PCL are the MS and LS bytes of PC. The 8 bits of register I provide the interrupt mask status as shown in the following.

images

Display memory command: To display memory contents, type ‘D’ without <cr>. The system prompts as follows:

Starting address :

The user is required to respond with the desired starting address for memory display. The user is required to provide the memory address in hexadecimal without the H suffix and <cr> (e.g. ‘C200<cr>’).

Then the system prompts the user for ending address. When the user provides the ending address, the contents of the desired memory locations are displayed on the terminal, and the ‘>’ prompt reappears. Using this command we can only see the contents of a number of memory locations, but not alter them. To modify the contents of memory locations we have to use the ‘modify memory command’.

Continuing with single step after checking registers/memory: Let us say, we are satisfied with the register contents and memory contents after single-stepping through the program by a few instructions. Then we want to continue with the remaining program in single-step mode.

At the ‘>’ prompt, type ‘S’ without <cr>. The system prompts as follows:

Starting address: xxxx - yy/

where xxxx is a memory address and yy is the content of that memory location. Here xxxx is the correct instruction address where the single-stepping has to continue. So keep responding with <sb> as many times as desired to single step through the instructions. To terminate single-stepping respond with <cr>, and the ‘>’ prompt reappears. Once again, the register contents and memory contents can be checked, and the single-stepping may be continued till the end of the program.

QUESTIONS

  1. List the steps needed for executing an 8085 assembly language program.
  2. What are assembler directives? Explain with examples the following assembler directives.
    1. ORG
    2. DB
    3. DW
    4. EQU
    5. END
  3. Explain Intel Hex format of storing a file.
  4. What are the advantages of using 8085 kit in serial mode compared with keyboard mode?
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.20.90