首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
解析mp1留学生、解析C/C++编程、C/C++语言辅导、讲解C/C++设计 辅导R语言程序|讲解数据库SQL
mp1: Understanding Tutor, a stand-alone monitor program
Assigned: 13 September 2018 Due: 2 October 2018 class time
I. OBJECTIVES:
The purpose of this assignment is to gain some experience with our UNIX system, the Stand-Alone PCs (SAPCs), and makefiles. At the same time, you will learn how to understand and modify existing C code.
1.Read, compile, run, understand, and modify a C program that runs a monitor program "tutor". We call it tutor because it mimics the Tutor monitor/debugger that we have installed on the SAPCs. You will build a UNIX version as well as a version that runs on SAPC VM.
2.Use your monitor program to explore memory locations on the PC – including the locations in which your program resides.
II. INTRODUCTION:
You should work on this assignment alone and turn in your own individual report and source code including test results. The UNIX dates on your files will determine whether the work was completed on time or not.
You should already have a cs341 logical link in your UNIX home directory. Type in command: cd cs341 to go into your homework directory. Use that subdirectory for all your work in this class. It has the right protection setup so that other students cannot access your files but instructors and graders can via group cs341-1G.
Copy files from /courses/cs341/f18/cheungr/mp1 / to yours using:
cp –r /courses/cs341/f18/cheungr/mp1/ .
cd mp1
ls
You should see all the files I supplied for this project. I'll call mp1 your project directory in what follows. Use your project directory for all work for this assignment. All files referred to below are in that project directory unless otherwise specified.
*NOTE*: YOU MUST USE THE DIRECTORIES AND FILE NAMES SPECIFIED SO THAT THE GRADERS AND I CAN FIND YOUR FILES AND TEST YOUR HOMEWORK, IF NEEDED. IF YOU DO NOT DO SO, YOU WILL BE PENALIZED AND YOUR OVERALL PROJECT GRADE WILL BE LESS.
III. DESCRIPTION:
You will write your own "tutor" program, which mimics Tutor. It's a tiny single user terminal monitor system, which we will compile and run both on the SAPC and on the UNIX system. In later assignments you'll add to its capabilities. For now it should accept the commands:
md
(SAPC and UNIX) Memory Display
Display contents (in hex) of 16 bytes at the specified address.
(Present in the same format as the “real” Tutor program – 16 pairs of hex characters followed by 16 characters interpreting each byte as a printable character for ASCII codes 0x20 through 0x7e or a fixed ‘.’ for all other (non-printable) ASCII codes values.)
ms
(SAPC and UNIX) Memory Set
Stores byte new_val (two hex characters) at specified address.
h
(SAPC and UNIX) Help
Help on the specified command, for ex., "h ps", or all commands if no argument.
s
(SAPC and UNIX) Stop
Stop running your tutor and return to the regular SAPC TUTOR (or back to the shell if running on UNIX).
The files you need to build tutor are found in my directory /courses/cs341/f18/cheungr/mp1/. Most of the program has been written for you for two reasons. First, by reading the code provided, you can learn how a standard "table-driven" command processor design works. Second, providing you with a framework allows you to concentrate on the part of the programming that's important in this course.
The main program for tutor is in tutor.c. That driver calls a lexical analyzer (parser) called slex.c. The parser finds the command on the command line and calls the appropriate procedure by consulting the command table. File cmds.c contains that table and the code that implements the various commands. The file makefile builds them into an executable file.
Start by copying all files to your project directory. The makefile will build the executable files from your local directory. Read the makefile and learn how it does that.
a)Build and run the UNIX version:
ulab% make tutor # creates an executable tutor to run on UNIX
ulab% ./tutor # runs the program locally under UNIX
ulab%
b)Build the SAPC version:
ulab% make # creates a tutor.lnx to download to the SAPC
Use the Virtualized SAPC environment to debug the SAPC version. Log in into the tutor-vserver VM using the provided credentials. Transfer the SAPC version to tutor-vserver VM using:
vserver$ scp username@users.cs.umb.edu:cs341/mp1/tutor.* .
vserver$ mtip -f tutor.lnx # always use board #1
click on the “Send Cntl-Alt-Del” button at the tutor VM to reset the SAPC VM. Hit
at the tutor-vserver VM to get the tutor prompt. Then download the tutor program to the SAPC VM and run it:
Tutor> ~d # download tutor.lnx
Tutor> go 100100 # start your program on SAPC VM
IV. MODIFY PROGRAM:
Read tutor.c, slex.h, slex.c, cmds.c, and the makefile in order to understand the structure of the tutor program. (We will be going over that structure in lecture.) When you're ready,
A. edit cmds.c to implement the required new commands (md, ms and h)
Use sscanf to convert the argument passed md or ms from a character string of hex digits to an integer. Use the return value from sscanf to check if it really worked. Study the makefile -- be sure you understand how it works. Study the output of make as it runs -- what are the program-building steps?
Sample Output
blade57(2)% tutor
command help message
md Memory display: MD
ms Memory set: MS
h Help: H
s Stop
UNIX-tutor> md 10000
00010000 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 .ELF............
UNIX-tutor>
B. play with the tutor programs that you've built
This is a central part of the assignment. If your code is elegant and perfect but you do not test it, exercise it, and think about the results it generates you will have learned less than half of what you should - so will get less than half the credit.
You must create a file discussion.txt. Write clear, grammatical English. Consider showing drafts to your friends (or your English teacher) to find out if your writing is clear. Run discussion.txt through the UNIX spell utility.
V. DISCUSSIONS:
In your discussion.txt file, answer all of the following questions:
(1) Describe how you tested your code. Try the following experiments. Write several sentences about what you found or learned working on each, and on any other similar kinds of questions that occur to you.
(2) What happens if you call md for an address that does not correspond to a physical memory address? What if you write to an address that's part of your tutor code or an address in ROM area of memory? Do these questions have the same answers on UNIX and the SAPC?
(3) Read the makefile to see where it puts the symbol table (nm output) for your tutor code. Use that symbol table to figure out:
(a) the address for test global variable xyz, which has value 6. Use tutor with that address to verify the value in memory.
(b) the address of the pointer variable pxyz. This address should be close to the one you determined in a, but not equal to it, since pxyz is the next variable in memory after xyz. Find the value of pxyz in memory. This should be equal to the address you found in (a) because of the initialization of this variable to &xyz. Note that you need to get 4 bytes of data for the value here. See IMPORTANT NOTE just below.
(c) the address of the cmds array. Use this address to determine the very first pointer in the array, the string pointer to "md". Then find the 'm' and 'd' and terminating null of this string.
(d) change the stop command from 's' to 'x' while the tutor program is running. Can you change the tutor prompt the same way?
IMPORTANT NOTE: When you try to access a 32-bit value (a pointer for example) in SAPC memory via Tutor, you need to reverse the displayed byte order, because of the little-endian representation of numbers in the Intel architecture.
Example: Suppose a pointer (or any 32-bit numeric quantity) is at address 0x100200with value 0x00100abc. It would show up as:
Tutor> md 100200
100200 bc 0a 10 00
because of "little-endian" storage of numbers in memory in the Intel architecture. See the lecture notes.
To help with displays, there is an "mdd" command (memory-display-doubleword) in the “real” Tutor monitor. This command reorders the bytes for you and displays four bytes at a time as a doubleword value:
Tutor> mdd 100200 (for same memory contents as with md command above)
100200 00100abc ...
(4) Read the nm output to determine where in memory the code resides, on SAPC and UNIX. Hint: code symbols are marked t or T. Similarly determine where the data (set of variables) resides.
(5) Try to change the code itself so that tutor crashes (any random change that actually takes effect should do this). What happens on SAPC? on UNIX?
(6) You can't find the program stack using the nm output, but you can find it by looking at the stack pointer, called ESP on the SAPC and sp on the SPARC (ulab's CPU). Record your observations. Use "i reg" (info on registers) to see sp in gdb and "rd" to see registers in Tutor.
(7) What other interesting things have you tried?
(8) (optional) More questions you should consider answering. What did you learn from this project? Was it worth the time it took? What parts were the hardest, what parts the easiest, what parts most surprising, most interesting?
What idiosyncrasies of C or UNIX or the SAPC or our installation slowed you down or helped you out? How might the assignment be improved?
VI. TURN-IN FOR GRADING:
You should turn in a hard copy of the typescript file at the beginning of the class when it is due. (Use this procedure for all future mp assignments.)
To generate a typescript file, execute the UNIX command “script”. This will start recording all terminal commands and responses into a file “typescript”. At a minimum, you must show all of the following in your typescript file:
ls –al to show your user name
cat your discussion.txt file
cat the sources of all of your .c files
execution of make clean
execution of make to create all program executable files
a sample run of each test case that is required in the assignment
Leave your discussion.txt file, typescript file, .c files, and a working version of tutor and tutor.lnx in your mp1 directory. Do not modify any of these files after printing the typescript file that you turn in. Please remember to put your name on the first page. The graders or I may login to this directory to check the UNIX dates on these files and to run them or test them ourselves. We may also recompile your cmds.c with another main program as an extra test case. Please remember to close your typescript file by issuing the command “exit”.
A rubric sheet for grading mp1 is included. In the event that you are unable to correctly complete the entire assignment by the due date, do not remove the work you were able to accomplish. Submit what you have completed - partial credit is always better than none.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 comm2000 creating socia...
2026-01-08
讲解 isen1000 – introductio...
2026-01-08
讲解 cme213 radix sort讲解 c...
2026-01-08
辅导 csc370 database讲解 迭代
2026-01-08
讲解 ca2401 a list of colleg...
2026-01-08
讲解 nfe2140 midi scale play...
2026-01-08
讲解 ca2401 the universal li...
2026-01-08
辅导 engg7302 advanced compu...
2026-01-08
辅导 comp331/557 – class te...
2026-01-08
讲解 soft2412 comp9412 exam辅...
2026-01-08
讲解 scenario # 1 honesty讲解...
2026-01-08
讲解 002499 accounting infor...
2026-01-08
讲解 comp9313 2021t3 project...
2026-01-08
讲解 stat1201 analysis of sc...
2026-01-08
辅导 stat5611: statistical m...
2026-01-08
辅导 mth2010-mth2015 - multi...
2026-01-08
辅导 eeet2387 switched mode ...
2026-01-08
讲解 an online payment servi...
2026-01-08
讲解 textfilter辅导 r语言
2026-01-08
讲解 rutgers ece 434 linux o...
2026-01-08
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!