Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Y86 Simulator Use C to implement a simulator for the Sequeti Y86 architecture. Your input will be a text file that contains first the program

image text in transcribed

Y86 Simulator Use C to implement a simulator for the Sequeti Y86 architecture. Your input will be a text file that contains first the program counter followed by the memory. A front end is already written that will read this file into an array where each byte of memory is a char. Starting at the memory address given to you as the starting program counter, you will read in bytes and execute the program. This is very similar to what we did in class where we 'disassembled' the input and looked at what happens in the different stages for each type of nstruction For example, consider the partial input given in the box below. The first number (0x0) is the starting program counter PC Other values can be used if the program execution can start elsewhere. The rest of the input is the contents of memory starting at address 0x0. This is what you will be executing. You start by examining the first byte and then all needed additional bytes for that instruetion. After execution (which may modify the PC), you execute the imstruction at PC, Start by understanding what the below program should do if simulated 0x0 30F65704000000000000D06FE0EF6800 000000000000406E7000000000000000 EOEF7000000000000000500E68000000 00000000D00F6006D06F733600000000 0000002406D06F6168D08F2589D09F21 89D09F409E6800000000000000EOEF68 0000000000000000CAFEBABE00000000 341200000000 You will need to implement all of the given Y86 plus some additional instructions to allow you to dump the contents of registers and memory: printal Single byte instruction 0xC0 -prints out the values stored in all 15 registers printreg reg - Two byte instruction 0xDO, 0xrA:F print out the value of the register indicated by TA printmem disp(reg) 10 byte instruction 0xEO, OxrA F. 8 byte displacement- print out the 8 byte constant stored at address contents(rA) + displacement. Implement these first - they will There are examples of all three of these new instructions in the above code. help you debug to real Y86 instructions. Files .simulate.c - this is the file you will be editing simulate main.c-reads the input into the data structure you will be using. Makefile creates executable 'simulate Try running 'simulate testl.m Iniitally doesn't do Use the give tools .Two examples to initially try: testl.m and test2.m There is also a test2.Y. much but eventually will execute the Y86 program testl.Y. to create other test files Implementation Notes .You wil need to use 64-bit (long int) for your registers and other 64-bit values. To print a 64-bit value in hex, use %lx (rather than %x). .You must use char type (single byte) and bit-level operators to do your work. Use masks and shifting to get to the parts of the byte you need to use at a given time. Be careful about shifting bytes since arithmetie right shifts are used in C. Casting can also cause problems since sign extension is going to be used. .There are a couple of tools you can use to help create other test files. The tools were just written and any bug fixes or upgrades will be available to you this way. There is little or no error checking in these tools so you may get unexpected results from bad input. /home/Y86/assemble-an assembler for the version of Y86 described here. 'assemble test.Y" will create a text file like that shown above with starting PC 0. If you add an additional decimal parameter 'assemble test.Y 256' then the given number will be used as the starting program counter. The tool currently only produces to file 'out.m' but this may be changed in the near future to let you output to a file you specify home/Y86/disassemble this will reverse the first step and take you back to Y86 Notes: To be completely correct, you have to both generate the correct addresses and data AND get the information to do the generation from the cssorrect location. Y86 Simulator Use C to implement a simulator for the Sequeti Y86 architecture. Your input will be a text file that contains first the program counter followed by the memory. A front end is already written that will read this file into an array where each byte of memory is a char. Starting at the memory address given to you as the starting program counter, you will read in bytes and execute the program. This is very similar to what we did in class where we 'disassembled' the input and looked at what happens in the different stages for each type of nstruction For example, consider the partial input given in the box below. The first number (0x0) is the starting program counter PC Other values can be used if the program execution can start elsewhere. The rest of the input is the contents of memory starting at address 0x0. This is what you will be executing. You start by examining the first byte and then all needed additional bytes for that instruetion. After execution (which may modify the PC), you execute the imstruction at PC, Start by understanding what the below program should do if simulated 0x0 30F65704000000000000D06FE0EF6800 000000000000406E7000000000000000 EOEF7000000000000000500E68000000 00000000D00F6006D06F733600000000 0000002406D06F6168D08F2589D09F21 89D09F409E6800000000000000EOEF68 0000000000000000CAFEBABE00000000 341200000000 You will need to implement all of the given Y86 plus some additional instructions to allow you to dump the contents of registers and memory: printal Single byte instruction 0xC0 -prints out the values stored in all 15 registers printreg reg - Two byte instruction 0xDO, 0xrA:F print out the value of the register indicated by TA printmem disp(reg) 10 byte instruction 0xEO, OxrA F. 8 byte displacement- print out the 8 byte constant stored at address contents(rA) + displacement. Implement these first - they will There are examples of all three of these new instructions in the above code. help you debug to real Y86 instructions. Files .simulate.c - this is the file you will be editing simulate main.c-reads the input into the data structure you will be using. Makefile creates executable 'simulate Try running 'simulate testl.m Iniitally doesn't do Use the give tools .Two examples to initially try: testl.m and test2.m There is also a test2.Y. much but eventually will execute the Y86 program testl.Y. to create other test files Implementation Notes .You wil need to use 64-bit (long int) for your registers and other 64-bit values. To print a 64-bit value in hex, use %lx (rather than %x). .You must use char type (single byte) and bit-level operators to do your work. Use masks and shifting to get to the parts of the byte you need to use at a given time. Be careful about shifting bytes since arithmetie right shifts are used in C. Casting can also cause problems since sign extension is going to be used. .There are a couple of tools you can use to help create other test files. The tools were just written and any bug fixes or upgrades will be available to you this way. There is little or no error checking in these tools so you may get unexpected results from bad input. /home/Y86/assemble-an assembler for the version of Y86 described here. 'assemble test.Y" will create a text file like that shown above with starting PC 0. If you add an additional decimal parameter 'assemble test.Y 256' then the given number will be used as the starting program counter. The tool currently only produces to file 'out.m' but this may be changed in the near future to let you output to a file you specify home/Y86/disassemble this will reverse the first step and take you back to Y86 Notes: To be completely correct, you have to both generate the correct addresses and data AND get the information to do the generation from the cssorrect location

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions