How to use PEP/6 in Unix
-- For CISC 221, Fall 2001
1. What is PEP/6?
The PEP/6 program is a simulator which allows you to assemble source code and to load and run object code files. You can edit your source code using any text editor.
2. Where is PEP/6?
PEP/6 in Unix environment is installed in CASLAB (Goodwin 233 and 235). When you use those NT machines in room 248, you can access PEP/6 through x-Win32.
3. Create a PEP/6 source file
Create a file name "sample" which has the following contents. (You may omit the comments, which start with ";".)
;This is a simple sample program in Pep/6
;This program output Hi
charo c#/H/, i ;Output 'H'
charo c#/i/, i ;Output 'i'
stop
.end
4. Assemble the sample program
Assembly code programs must be assembled before being loaded and run. To assemble the sample program, do the following:
1). Type "asem" at a unix prompt. You will be asked to enter a source file.
2). Type "sample". You should see several lines of output.
3). Chose 'y' for "Screen listing? (y or n): ". You should see a neat list of source code. At the end of the output, you will be asked to choose 'y' or 'n' for "File listing? (y or n): ".
4). Type "y".
Finally, two files (sample.l and sample.o) are generated. If the assembly is unsuccessful, error messages will be shown up. You can try it out by modifying the sample source code.
5. Run an object program
To run the program, do following:
1). Type "pep6" at a unix prompt. You should see a line of command options.
2). Type "l", then you will be asked to enter the object file name without .o which is "sample" in this case.
3). Type "x" to execute the program. If you want to exit, then type "q".
6. Another example
This program reads an integer n and calculates 2*n.
br main
n: .block d#2 ;2 bytes storage for one integer (int n)
answer: .block d#2
main: charo c#/n/, i ;cout << 'n: '
charo c#/:/, i
charo c#/ /, i
deci n, d ;cin >> n
loada n, d ;answer = 2*n
asla
storea answer, d
charo c#/2/, i ;cout << '2*n = ' << answer
charo c#/*/, i
charo c#/n/, i
charo c#/ /, i
charo c#/=/, i
charo c#/ /, I
deco answer, d
stop
.end
7. Write your own program
Write a pep/6 program which reads an integer n and calculates n/2. Then modify your program, let it calculate (2*n + n/2).