ON-WEB-VISUALIZING A MECHANISM OF A SINGLE CHIP COMPUTER FOR COMPUTER LITERACY COURSES Tsunenori MINE1 Daisuke NAGANO2 Kensuke BABA2 2 Takayoshi SHOUDAI Sachio HIROKAWA3 1,2
1
Graduate School of Information Science and Electrical Engineering, Kyushu University, Kasuga 816-8580, Japan. 3 Computer Center, Kyushu University, Fukuoka 812-8581, Japan 1
[email protected] 2 {shoudai,nagano,baba}@i.kyushu-u.ac.jp 3
[email protected]
INTRODUCTION
ers like their own stationeries. Most of these freshmen can master the techniques of using computers well.
One of the first questions which computer beginners ask their teachers may be, what on earth programs are, or how a program runs on their computers. In these days softwares are being larger and we can choose various functions and many options. It would be good news, but on the other hand, it might become one of the reasons why computer beginners could not easily understand how a software works on their computers. Most computer beginners must not know inner parts of such a black box. However we always hope that every university students can understand how their programs run, in other words, a mechanism of their computers, so as not only to write excellent programs but also to use their computers efficiently. Our main subjects of the computer literacy course in our university are the following: (1) Windows95 including word processing, (2) Programming in Pascal, and (3) Network (e-mail, WWW, telnet/ftp).
In the lectures we make use of Internet, especially the Web system, as an important tool for teaching our subjects. That is because, first, the Web system can be strong enough to replay the class in the students’ private hours. Second, since 2,300 freshmen take the same course every year, some kind of computer aided system is indispensable for reducing the burden of teachers. Our Web-aided lecture system(http://www.rc.kyushu-u.ac. jp/Literacy) includes the electronic version of the textbook [ Hirokawa et.al. 1997] , slides , and quiz [Hirokawa et.al. 1996] Furthermore, this on a Web page how a program runs[Sato et.al. 1997] and how CPU and Memory for a common purpose.
We developed the CPU emulator system on the Web, which is now helping our students to understand behaviors of conventional computers(from now on, call this just computer for short). Every year about 2,300 freshmen take The system is now accessible to the pubthis course in order to use their comput- lic through Internet. In this paper we 1
describe its meaning and functions and show how the system works.
2 2.1
CPU Emulator on a Web Its meaning and functions
Any computer executes an instruction in a program step by step. Following the program, at each step CPU might operate some registers in itself, or choose exactly one cell in the conventional memory so as to change its value. It would be impossible to learn programming in a short time without being convinced of the intuition about them. Recently researchers in the field of computer animations are studying an educational effect of program animations [Stasko et.al.], [Small et.al. 1994], [Suzaki], [Sekishita], [Brummund], and they have already served several techniques on their Web pages. We can easily access these pages to teach beginners how a program runs. We are also developing a simple on-Web visualizer which emulates programs which are written in a subset of Pascal language[Sato et.al. 1997]. By using this system students can directly watch how a program runs, e.g. the order of executing program codes, change of variables’ values. Our next target is a new Web-aided system which help students to take experiences of computers’ behaviors. We can not employ our real computers in order to teach its behaviors any more because our computers are too complicate and its basic operations are covered by a large operating system, which keeps novice computer users away from understanding the mechanism of computers. Several emulators of assembly language, which help us to see behaviors of a computer, have been developed so far(e.g. [Tanaka et.al., Arai]). Unfortunately, most of them have been built as
Figure 1: Overview of ∗M Y COM ∗, web-aided system helping to learn simple mechanisms of computers.
one of applications on a personal computer. That means that we must install it on each computer even when we make students try it just once or twice. Our new Web-aided system accordingly supplies a new function that simplifies behaviors of a stored program-type computer, and helps students understand more detailed mechanisms on how a computer interprets or executes programs stored in the memory. We call this system ∗M Y COM ∗, whose overview is shown in figure 1. 2.2
Virtual Machine ∗M Y COM ∗
Model
of
Considering a conventional-type computer’s behaviour on interpretation and execution of machine codes, the following steps are performed by a CPU: 1. Fetch a data from a main memory and store it to a register in the CPU. 2. Execute an operation using both data in a main memory and in a register, and store its result to the register. 3. Store a value of a register to a main memory. 2
These steps are regarded as a typical process that a CPU interprets and executs a command. Emulating these steps makes us see a behavior of a simplified computer. Consequently, we designed a virtual machine model(VMM) emulating these steps. The VMM performs a program stored in a memory with following three parts: a program counter(PC), a general purpose register and a status register. 2.3
∗M Y COM ∗ has a Graphic User interface(Fig. 2). The left side of the ∗M Y COM ∗’s window displays a virtual memory. There are 10 fields, each of which is a cell in a series of a memory. A label on the left-side out of the field stands for an address of a memory cell. A red and a blue field stand for an address pointed by a PC and a break point address, respectively. A user can directry write down a value in the fields to look for a difference of behaviors of the computer. The top right-hand side consists of windows and buttons. The formers are for displaying contents of virtual registers and the laters to control ∗M Y COM ∗. The bottom right-hand side is a filed to display outputs of ∗M Y COM ∗. ∗M Y COM ∗ has following bottuns to control ∗M Y COM ∗ itself:’Go’, ’ Step’, ’Stop’, ’Restart’, ’Input’; ’Go’ calls a method E cpu and gives it a value of PC as an argument. ’Step’ executes a function step by step as same as executed by pushing buttom ’Go’. ’Stop’ suspends an execution of E cpu. ’Restart’ resets a PC to an initial value and set both a universal and a status register to 0. ’Input’ is an input field for giving a value to E cpu. The status of this field is changed to ’editable’ only if ’IND’ instruction is executed. The end of an input is informed to E cpu by pushing a ’return’ key.
Design of Mnemonic Codes
Each command of the VMM is determined by two address sequences. The former address is a command number for a mnemonic code, and the later is a data, e.g. a target address of the command. The VMM has following 12 commands: LDR, STR, SUB, CMP, JPZ, JMI, JZE, JMP, IND, OTD and HLT. Each meaning of them is shown in table 1. In the table, r(a) and m(i) denote a register ’a’ and an i-th address in a memory. C(X) denote a function which returns a content of X, and accordingly, C(r(a)) and C(m(i)) stand for a content of r(a) and m(i), respectively.
3
Implementation ∗M Y COM ∗
of
The CPU emulator is implemented as a Java method, E cpu. The E cpu gets a PC as an argument and returns a byte code got through executions of an instruction, a command number. E cpu fetches a data from a memory implemented as a global variable and executes an instruction corresponding to the data. E cpu assumes an instruction set consists of two address sequences(2 bytes codes), an instruction and a data. E cpu usually adds 2 to PC except for the instructions that directly access a value of PC, such as ’ JMP’ or ’JZE’, and so forth.
This ∗M Y COM ∗ is now available on our Literacy Web page ( http: //www.rc.kyushu-u.ac.jp/Literacy).
4
CONCLUDING REMARKS
We discussed our new Web-aided system, a CPU emulator. Since our CPU emulator is a Web-based system and it is also based on a simplified virtual ma3
Table 1: Mnemonic Codes of VMM name Load Store ADD SUBtract CoMPare
code LDR STR ADD SUB CMP
Com. Num. 1 2 3 4 5
target address i i i i i
Jump on Plus or Zero Jump on MInus Jump on ZEro JuMP INput Data OuTput Data HaLT
JPZ JMI JZE JMP IND OTD HLT
6 7 8 9 10 11 0
i i i i i i 0
meaning of command load C(m(i)) to r(a) store C(r(a)) to m(i). add C(m(i)) to r(a) subtract C(m(i)) from r(a) compare C(r(a)) to C(m(i)) and then, if C(r(a)) > C(m(i)) then set s to 0 else if C(r(a)) = C(m(i)) then set s to 1 else set s to 2. if C(r(a)) ≥ C(m(i)) then set pc to i if C(r(a)) < C(m(i)) then set pc to i if C(r(a)) = C(m(i)) then set pc to i set pc to i input an integer and store it to m(i) display C(m(i)) halt
References [Brummund] Peter Brummund, “The Complete Collection of Algorithm Animations” http://www.cs.hope.edu/˜ alganim/ccaa/site.html [Suzaki] Kuniyasu Suzaki, http://www.etl.go.jp/etl/divisions/˜suzaki/ AlgorithmAnimation/index.html [Sekishita] Hiromasa Sekishita, “Algorithm Animation”, http://al.ei.tuat.ac.jp/˜sekisita/algoanim-e.html [Small et.al. 1994] Small, R.M., Price, I.S., and Baecker, B.A.,(1994). “A Principled Taxonomy of Software Visualization”, Journal of Visual Languages and Computing, 4(3),211–266. [Stasko et.al.] Stasko, J.T., Ford, L., and Brown, M.H., “Software Visualization Pointers”, http://sudo-www.ics.es.osakau.ac.jp/theme/V/svlinks.html. [Hirokawa et.al. 1996] Sachio Hirokawa, Tetsuhiro Miyahara, Tsunenori Mine, Takayoshi Shoudai, Masao Teaching 2300 students with www – practice and experience at kyushu university. In Proc. of ERI’96, pages 59 – 63, 1996.
Figure 2: ∗M Y COM ∗ Window
[Hirokawa et.al. 1997] Sachio Hirokawa, Tetsuhiro Miyahara, Tsunenori Mine, and Takayoshi Shoudai. 12 kai de manabu jouhou shori (12 Lessons of Computer Literacy). Gakujutsu Tosho Shuppan, 1997
chine model of computer, it works fine as an educational tool for novice users and helps them to take experiences of computers’ behaviors.
[Sato et.al. 1997] Hiroyuki Sato, Tsunenori Mine, Takayoshi Shoudai, Hiroki Arimura, and Sachio Hirokawa. On web visualizing how programs run for teaching 2300 students. In ICCE(International Conference on Computers in Education)97 in Malaysia, pages 952–954, December 1997.
This emulator has been developped in Java language is now available on our Computer Literacy Web page.
[Tanaka et.al.] Yoichiro Tanaka: A simulator of the assembly language ’CASL’ in Java. http://www.c5.ne.jp/˜yoichiro/casl/index.html
We hope this new system helps not only 2,300 freshmen at Kyushu University, but other peoples who want to learn behaviors of a computer.
[Arai] Masahiro
Arai
http://www.d.dendai.ac.jp/ai/˜arai/ccsimw.html
4