SOFTWARE SIMULATION IMPLEMENTATION of INTEL 8085 MICROPROCESSOR INSTRUCTION EXECUTION on INTEL 80386 BASED CPU's and UNDER WIN32 OPERATING SYSTEM ENVIRONMENT

Çaðrý CAMCIOÐLU

Hacettepe University
Department of Electrical and Electronics Engineering
ELE 402 Final Project Report
Instructor: Asst. Prof. Ali Ziya ALKAR

Spring 2000


 

ABSTRACT

This project is prepared in the aim of helping to understand of the instruction execution and memory management of 8-bit Intel 8085 microprocessor. For this purpose, a program, which is run on Intel 80386 based CPU's and under Win32 operating system, is written using a high level visual programming language. With this program, namely Sim8085, one can be write a 8085 microprocessor assembly language code in text format and then simulate it line by line just as it runs on the original CPU. While the assembly codes are executed (simulated), the register, memory (code, stack or data) and port contents can be viewed instantly. There can be also made some modifications to these values at run-time, if needed. With the Sim8085, all the work is done in very user-friendly environment. This report will guide reader in detail about the program specifications, program usage and language coding steps with operating system background.

 

INTRODUCTION

Nowadays, personal computers (PC) do all the hard work for us, including the complex calculations and scheduling. There are many different microprocessor based platforms and we can also simulate these different platforms on PC's. One of them is 8085 microprocessor (µp). It is one of the first produced controllers in the electronics age.
Writing a program means that, building algorithm(s) for doing something according to a purpose. And than, check the whole for any error (bug). For the point of engineering, writing 8085-µp assembly programs and checking them for error under 8085-µp environment is quite difficult and it takes long time. At this point, the PC's come to the help of us.
The "8085 Microprocessor Simulator", Sim8085, is such a Win32 based program that runs on Intel 80386 based 32-bit microprocessors and simulates the original 8085-µp with its instructions. The program(s) and/or algorithm(s) can be debugged within the program. In addition, it has a text editor with very enhanced functions that you can write your assembly code without any external text editor.

So, the Sim8085 is mainly separated into two parts:

Editor: Sim8085 has an enhanced internal text editor with standard and Sim8085 specific functions. The Editor also has a build-in compiler that makes the syntax checking. There are some pseudo-directives that included for coding easily. (e.g., "FillByte", "Org", "Db", "KickOff") With these pseudo-directives, Sim8085 does the all related hard work instead of user. The object and binary (machine) codes of the written program(s) can also be obtained, while syntax checking is made.

Debugger:"Debug" means, find and correct the mistakes, if any. From this point, the debugger part is designed to analyse the implemented code easily. There is a 64-KB virtual memory where the written program is kept as 8085-µp machine codes. All the register, flag, code, data, stack and port contents can be viewed while tracing thorough the code lines. The content of the areas mentioned above is changed instantly according to the instruction that just executed. Port operations can also be viewed and controlled visually.

 

PROGRAM SPECIFICATIONS

2.1 Editor Part

The Sim8085 has a very user-friendly text editor. A general layout is shown at figure 2.1. There can be opened up to ten different files at a time. Default file extension for opening and saving files is "85".

Figure 2.1 "Editor Mode Screen Snapshot"


There is an adjustable undo-buffer. And, in a visual manner, there is some more: Firstly, background and foreground of the text can be chosen. Also, editor can make syntax highlighting to written text; user can choose the color of the all reserved assembly words. Secondly, there are some information-based tags: Cursor position, editor buffer modification, editor cursor mode, file read-only info, and context sensitive help are shown instantly at the "Status Bar". The editor and file commands in the Sim8085 are: "New", "Open", "ReOpen", "Save", "Save As", "Save All", "Close", "Print", "Undo", "ReDo", "Cut", "Copy", "Paste", "Select All", "Find", "Replace".
The editor part has a built-in compiler that checks the written assembly code for syntax errors. After all the lines are checked, the erroneous line is shown with respective error message and line number, if there is any mistake; otherwise, the user is informed with a message including the compiled code size. Screen snapshots are shown below.

Figure 2.2 "Erroneous Code Screen Snapshot"

Figure 2.3 "Compiled Code Screen Snapshot"


 
The list and object files can be generated automatically every time the source code is compiled or manual by the user, depending on the settings. Screen snapshots of these text-based files are shown below.

Figure 2.4 "List File Screen Snapshot"

Figure 2.5 "Object File Screen Snapshot"


Sim8085 assembly compiler has some more flexible rules: There can be entered binary, decimal and hexadecimal numbers. Comment lines can be included. These lines are begun separated with a semicolon and discarded by the compiler. Loop names can be entered up to thirteen characters ended by a colon. Also, there are some pre-assigned words, which are called as "Pseudo-Directives". These directives make the writing of programs and/or algorithms easy.The meaning and usage syntax of each pseudo-directive is shown below:

"FillByte count,byte": Fills the memory starting from the current memory address with the given byte at a given count.

"Org address": Tells to the compiler to place the machine codes starting from the given address.

"KickOff address": Tells to the compiler that where the entry point (starting address) of the written assembly code is.

"Db string of bytes/characters": This directive makes the entry of any string, character or byte is easy. The all characters in a string are individually follows each other in the memory. An example of usage is, "Db 13,10,'This is a sample text…',13,00001010b,24h"

2.2 Debugger Part

After the source code is compiled successfully, meaning there is no any syntax error, debugger mode can be begun. Debugger screen consists of a code pane, a register pane, a flag pane, a stack pane and a data pane. The screen layout is shown below.

Figure 2.6 "Debugger Mode Screen Snapshot"


In fact, code, stack and data panes show the memory content according to their duties; however, the memory location they point can be different. Code pane interprets the bytes in virtual memory as 8085-µp machine codes; whereas data pane interprets the bytes in virtual memory as pure characters, but also showing the hexadecimal equivalents. Both the code and stack panes show their content with the respective offset address in a tabular form. Stack pane shows the memory location as two bytes (word), indicated by the stack pointer register, SP, with a range of ?5 words. Register pane shows the all 8085-µp register contents and also the memory byte location indexed by HL register pair. Likewise, flag pane shows the flag register and the individual bits of it. To make the following easy, the changed registers and flag bits are drawn with a separate color while tracing. The current line or location in each pane is shown by a highlighted bar. The user can be cycle through the panes with keyboard or even a mouse click. Contents of the ports can be viewed and even changed bit by bit within the "Ports Form". Port numbers are pre-assigned and can be changed from the "Options Menu". Values are shown in decimal, hexadecimal and octal, too. Snapshot is show below.

Figure 2.7 "Ports Form Screen Snapshot"

The debugger mode has a unique advantage that makes the usage so easy with allowing instant changes to any register or memory content while still debugging the code. User can add, delete and change the instructions in the code pane by writing as string or hexadecimal bytes. Likewise, in the data pane, user can change the memory content by inserting new data bytes or just changing the old ones as string or hexadecimal bytes. With this way, user does not have to go back into the editor mode and change the written assembly text code for small changes or tests. But, of course, the original code text does not change after leaving the debugger mode. All the changes made in debugger mode are discarded.
The simulation of 8085-µp instructions is done with some trick: Instead of completely simulating all these instructions by software, it is used some CPU help. For instance, the CPU of the PC has done parts of all arithmetic instructions, since addition or multiplication logic does not change according to CPU platform, except instruction syntax changes.
There are keyboard shortcuts that assigned to events like above and they are explained here for convenience.

In the Code Pane:
Enter: Edits the current line
Insert: Inserts a new code line into the current line
Delete: Deletes the current code line
Home: Jumps to the beginning of code (offset 0000)
End: Jumps to the end of code (last offset address)
Page Up: Scroll the code pane view 15 lines up
Page Down: Scroll the code pane view 15 lines down
Ctrl+Page Up: Scroll the code pane view 60 lines up
Ctrl+Page Down: Scroll the code pane view 60 lines down
Shift+A: Go to an address entered by user
Shift+O: Go to origin, which is the current code line
Shift+C: Caller; returns to the entry point within a "call" function
Shift+F: Fallow; fallows a "call" or "jump" function entry point
Shift+N: New Origin; marks the current code line as origin
Shift+S: Searches a given string or hexadecimal byte(s) in memory
Shift+L: Continues to search again

In the Data Pane:
Enter: Edits current byte
Insert: Inserts byte(s) or string
Ctrl+Page Up: Scroll the data pane view 60 lines up
Ctrl+Page Down: Scroll the data pane view 60 lines down
Shift+A: Go to an address entered by user
Shift+O: Go to origin, which is the current code line
Shift+S: Searches a given string or hexadecimal byte(s) in memory
Shift+L: Continues to search again

In the Register Pane:
Enter: Changes the current register value
Numerical Pad (+) : Increases the current register value
Numerical Pad (-) : Decreases the current register value

In the Flags Pane:
Enter: Toggles the current flag bit

In the Stack Pane:
Enter: Changes the current stack value

2.3 General Usage

Though the Sim8085 is a visual Win32 program, the usage is more likely based on keyboard rather than mouse. Although mouse has the same functionality, keyboard shortcuts make the life easy and quick. With mouse, user can click to the related function buttons or can simply select the function from the main menu. (see figure 2.6) The set of shortcuts for keyboard usage are listed below:

In the Editor Mode:
File Menu, New File: Ctrl+Shift+N
File Menu, Open File: Ctrl+Shift+O
File Menu, Save File: Ctrl+Shift+S
File Menu, Close File: Ctrl+Shift+C
File Menu, Print File: Ctrl+P
File Menu, Exit Program: Alt+X

Edit Menu, Undo: Ctrl+Z
Edit Menu, Redo: Ctrl+D
Edit Menu, Cut: Ctrl+X
Edit Menu, Copy: Ctrl+C
Edit Menu, Paste: Ctrl+V
Edit Menu, Select All: Ctrl+A
Edit Menu, Find: Ctrl+F
Edit Menu, Replace: Ctrl+R

Project Menu, Compile: Ctrl+F9
Project Menu, Debug: Ctrl+F10

In the Debugger Mode:
Project Menu, Terminate: Ctrl+F2
Project Menu, ReLoad: Ctrl+L
Project Menu, Trace Into: F7
Project Menu, Step Over: F8
Project Menu, Run Here: F4
Project Menu, Run: F9
Project Menu, Breakpoint: F5
Project Menu, Breakpoint State Change: Ctrl+F5
Tools Menu, Show Ports: Ctrl+Alt+P
Next Pane: F6 or Ctrl+Right Arrow
Previous Pane: Shift+F6 or Ctrl+Left Arrow

In General:
Tools Menu, Ascii Table: Ctrl+Alt+A
Tools Menu, Base Converter: Ctrl+Alt+B
Tools Menu, Character Map: Ctrl+Alt+C
Tools Menu, Hex Calculator: Ctrl+Alt+H
Tools Menu, Keyboard Scan Codes: Ctrl+Alt+S
Navigation: Arrow Keys

There're other menu items that are not listed here, which don't have keyboard shortcuts but can be accessed through the main menu.Sim8085 can accept a file name as a parameter when it first runs. Also, it has a buffer to keep the last opened five files for quick accessing. All the settings can be made within the "Options" menu.

 

CONCLUSION

In this project, simulation of Intel 8085 microprocessor instructions on a different CPU and operating system is discussed. For this purpose, a program, which called as Sim8085, is written in a high level visual language on an Intel 80386 based CPU and Windows™ 95 based operating system. For the point of engineering, program developing on an 8085-µp environment is hard and hence, means that losing time. With the Sim8085, writing 8085-µp assembly language based algorithms and checking them for error is so much easy; Sim8085 has come over all these difficulties easily.

 

REFERENCES

Gaonkar, Ramesh S., 1989, "Microprocessor Architecture, Programming, and Applications", Macmillan Publishing Company, New York, Second Edition.