SDSU Template, Version 11.1
Total Page:16
File Type:pdf, Size:1020Kb
ENHANCEMENT OF MC68000 SIMULATOR MACROS TO SUPPORT FLOATING POINT NUMBER _______________ A Thesis Presented to the Faculty of San Diego State University _______________ In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science _______________ by Honey Walia Spring 2012 iii Copyright © 2012 by Honey Walia All Rights Reserved iv ABSTRACT OF THE THESIS Enhancement of MC68000 Simulator Macros to Support Floating Point Number by Honey Walia Master of Science in Computer Science San Diego State University, 2012 The purpose of this thesis is to write macros to support floating point number for BSVC simulator. This simulator provides a runtime environment which simulates a Motorola 68000 family CPU system. This system is currently used at SDSU to teach machine organization and assembly language programming to students in CS237. This thesis provides significant enhancements to the functionality of the system, making it more valuable tool for classroom instruction. v TABLE OF CONTENTS PAGE ABSTRACT ............................................................................................................................. iv LIST OF FIGURES ................................................................................................................ vii ACKNOWLEDGEMENTS ................................................................................................... viii CHAPTER 1 INTRODUCTION .........................................................................................................1 1.1 BSVC History ....................................................................................................1 1.2 Motivation ..........................................................................................................2 2 MOTOROLA 68000 ASSEMBLY LANGUAGE BACKGROUND ...........................3 2.1 The MC68000 Family ........................................................................................3 2.2 Trap ....................................................................................................................3 2.3 Macro .................................................................................................................4 2.4 Macro Preprocessor ...........................................................................................4 2.5 Trap 13 ...............................................................................................................4 3 TRAP14 .........................................................................................................................6 3.1 What are Floating Point Numbers? ....................................................................6 3.2 Storage Layout ...................................................................................................6 3.2.1 The Sign Bit ..............................................................................................7 3.2.2 The Exponent ............................................................................................7 3.2.3 The Mantissa .............................................................................................7 3.2.4 Putting it All Together ..............................................................................8 3.3 The Problem .......................................................................................................8 3.4 The Solution .......................................................................................................8 3.4.1 Addition ....................................................................................................8 3.4.2 Subtraction ................................................................................................9 3.4.3 Multiplication ............................................................................................9 3.4.3.1 Code Snippet ..................................................................................10 3.4.3.2 Special Case ...................................................................................11 vi 3.4.3.3 Code Snippet ..................................................................................11 3.4.4 Division ...................................................................................................13 3.4.5 Special Case ............................................................................................14 4 FUTURE WORK DOUBLE PRECISION FLOATING POINT NUMBERS ............15 REFERENCES ........................................................................................................................16 APPENDIX A BSVC SYSTEM ..........................................................................................................17 B FLOAT I/O MACRO ...................................................................................................19 C TRAP 14.S ...................................................................................................................24 D TRAP14 MACRO ........................................................................................................50 E TRAP14 DEMO PROGRAM ......................................................................................57 vii LIST OF FIGURES PAGE Figure 3.1. Floating-point representation...................................................................................7 viii ACKNOWLEDGEMENTS I want to express my gratitude to my advisor Mr. Alan Riggins for giving me an opportunity to work on this thesis project and for his constant guidance, support and motivation throughout this project. I am grateful to Dr. Leland Beck, for trusting me with this project. I am also thankful to Professor Tunc Geveci for being on my committee and for his co-operation. 1 CHAPTER 1 INTRODUCTION 1.1 BSVC HISTORY BSVC is a microprocessor simulation framework written in C++ and TCL/TK. It simulates Motorola 68000 family of microprocessors. It was developed as a senior design project at North Carolina State University by Bradford W. Mott in 1993. Since then, many professors and students have been using BSVC and found it a very useful tool in courses based on the Motorola 68000 family (for different parts of simulator see Appendix A).. BSVC was originally written for Unix operating system, however, it has been ported to windows. The Windows version has the same features as the Unix version except the Motorola 68000 simulator does not support the M68681 Dual UART. The Computer Science department of San Diego State University has been using BSVC for its undergraduate assembly class and has found BSVC to be a very useful tool. However input and output are not part of the assembly language. They need to be accomplished by the use of library functions. The original development of BSVC does not include input and output libraries. This made work requiring input and output impossible, which is inconvenient to both students and professors who are using the simulator. In 1998, Professor Marko Vuskovic at San Diego State University wrote a trap 15 that contained some I/O routines to handle input and output on a Unix system. Trap 15 was revised and expanded to include a complete set of I/O routines by Professor Sara Baase and Alan Riggins at San Diego State University [1]. The new library was renamed trap13 to distinguish it from Professor Vuskovic's work. In 2003, Alan Riggins ported the I/O routines to windows system. Before that any programming requiring input/output had to be done either at school, which is inconvenient to students, or using x-window to remote log in to the school server from a PC, which makes the remote connection very slow. 2 1.2 MOTIVATION The Motorola 68881 and Motorola 68882 were floating-point coprocessor chips that were used in some computer systems in conjunction with the 68020 or 68030 CPUs. The addition of one of these chips added a floating point unit that could rapidly perform floating point math calculations. This was useful mostly for scientific and mathematical software. BSVC simulator does not support floating point numbers. Floating point numbers have a variety of practical uses and are a very important component to an assembly language. Without support for floating-point numbers, the BSVC simulator is incomplete and it is difficult for professors and students to program any floating-point number related programs. Because of this Professor Carl Eckberg at San Diego State University proposed to write a trap that would add floating- point number input/output, addition, subtraction, multiplication and division into the BSVC simulator. In 2004, Huijuan Yin, student at San Diego State University wrote a trap 14 to support floating point numbers. Trap 14, when given input greater than 7 digits before decimal point or greater than three digits after decimal point it failed. So, Professor Alan Riggins proposed to find a solution to support floating point calculations (32 bit- precision) for all valid inputs. 3 CHAPTER 2 MOTOROLA 68000 ASSEMBLY LANGUAGE BACKGROUND 2.1 THE MC68000 FAMILY Early computer systems were programmed using machine language which was slow and error prone. High level programming languages increase programmer productivity but compiled code is usually both larger and less efficient. The need for a language that can directly access machine instruction is obvious. Assembly language grew out of this need then. Assembly language programming is writing machine instructions in mnemonic form, using an assembler to convert these mnemonics into actual processor instructions and associated