代写C++代码 代做C++程序 C++辅导 C++教学

C++网络家教 远程写代码 在线Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

代写C++ The square laser maze

The square laser maze
Consider a sample laser maze shown on the left below:
In maze 1, the orange laser beam starts from coordinates (1,2) with laser going along the
East direction. The laser first hits a single‐sided mirror at (2,2), and then travels North, hits a
double‐sided mirror at (2,4), and then goes East, hits another double‐sized mirror at (5,4),
and direction changes to South. Finally, arriving the destination at (5,3). The green laser
beam starts from (0,3) with laser going along the East direction. If you follow the path of the
laser beam, you will notice the laser hits a few mirrors and finally arriving the destination at
(4,1).
In maze 1, both laser beams arrive at a destination. On the other hand, all beams in maze 2
cannot reach a destination. The orange laser beam goes off the boundary, the green laser
beam is blocked at (2,5) and cannot go further, and the red laser beam is blocked at (3,0) as
well.
A typical laser maze contains these items:
At least 1 and at most 5 laser beam sources. Laser beam source will point to one of
these directions: North, East, South, West.
At least 1 and at most 5 destinations. Number of destinations can be different from
the number of sources.
Zero or more single‐sided mirrors. There are 4 kinds of single‐sided mirror, facing
NW, SE, SW, or NE.
Zero or more double‐sided mirrors. There are 2 kinds of double‐sided mirror.
Zero or more laser blocks. This is the cross shown in maze 2 above. A laser block will
stop any laser beam at the space that it is located.
Note that in a laser maze, there will be at most 20 items, and no two items share the same
coordinates. Smallest possible laser maze is 2x2.
x
y
0 1 2 3 4 5 6
6
5
4
3
2
1
0
Maze 1 Maze 2

ENGG1111 A1 2016/17
‐2‐
Converting the graphical maze into words
Somehow the laser maze needs to be entered into the program. We will give each item in
the laser maze a name. Below is the conversion table:

代写汇编Assembly MIPS LC3 Computer System

Listing 1: “Hello World!” in LC-3.
The above listing is a typical hello world program written in LC-3 assembly language. The program
outputs “Hello World!” to the console and quits. We will now look at the composition of this
program.
Lines 1 and 2 of the program are comments. LC-3 uses the semi-colon to denote the beginning
of a comment, the same way C++ uses “//” to start a comment on a line. As you probably already
know, comments are very helpful in programming in high-level languages such as C++ or Java. You
will find that they are even more necessary when writing assembly programs. For example in C++,
the subtraction of two numbers would only take one statement, while in LC-3 subtraction usually
takes three instructions, creating a need for further clarity through commenting.
Line 3 contains the .ORIG pseudo-op. A pseudo-op is an instruction that you can use when
writing LC-3 assembly programs, but there is no corresponding instruction in LC-3’s instruction
set. All pseudo-ops start with a period. The best way to think of pseudo-ops are the same way you
would think of preprocessing directives in C++. In C++, the #include statement is really not a C++
statement, but it is a directive that helps a C++ complier do its job. The .ORIG pseudo-op, with its
numeric parameter, tells the assembler where to place the code in memory.
Memory in LC-3 can be thought of as one large 16-bit array. This array can hold LC-3 instructions or it can hold data values that those instructions will manipulate. The standard place for code
to begin at is memory location x3000. Note that the “x” in front of the number indicates it is in
hexadecimal. This means that the “.ORIG x3000” statement will put “LEA R0, HW” in memory
location x3000, “PUTS” will go into memory location x3001, “HALT” into memory location x3002,
and so on until the entire program has been placed into memory. All LC-3 programs begin with the
.ORIG pseudo-op.
Lines 4 and 5 are LC-3 instructions. The first instruction, loads the address of the “Hello World!”
Revision: 1.17, January 20, 2007 viiProgramming in LC-3
string and the next instruction prints the string to the console. It is not important to know how these
instructions actually work right now, as they will be covered in the labs.
Line 6 is the HALT instruction. This instruction tells the LC-3 simulator to stop running the
program. You should put this in the spot where you want to end your program.
Line 7 is another pseudo-op .STRINGZ. After the main program code section, that was ended
by HALT, you can use the pseudo-ops, .STRINGZ, .FILL, and .BLKW to save space for data that
you would like to manipulate in the program. This is a similar idea to declaring variables in C++.
The .STRINGZ pseudo-op in this program saves space in memory for the “Hello World!” string.
Line 8 contains the .END pseudo-op. This tells the assembler that there is no more code to assemble. This should be the very last instruction in your assembly code file. .END can be sometimes
confused with the HALT instruction. HALT tells the simulator to stop a program that is running.
.END indicates where the assembler should stop assembling your code into a program.
Syntax of an LC-3 Instruction
Each LC-3 instruction appears on line of its own and can have up to four parts. These parts in order
are the label, the opcode, the operands, and the comment.
Each instruction can start with a label, which can be used for a variety of reasons. One reason
is that it makes it easier to reference a data variable. In the hello world example, line 7 contains
the label “HW.” The program uses this label to reference the “Hello World!” string. Labels are also
used for branching, which are similar to labels and goto’s in C++. Labels are optional and if an
instruction does not have a label, usually empty space is left where one would be.
The second part of an instruction is the opcode. This indicates to the assembler what kind of
instruction it will be. For example in line 4, LEA indicates that the instruction is a load effective
address instruction. Another example would be ADD, to indicate that the instruction is an addition
instruction. The opcode is mandatory for any instruction.
Operands are required by most instructions. These operands indicate what data the instruction
will be manipulating. The operands are usually registers, labels, or immediate values. Some instructions like HALT do not require operands. If an instruction uses more than one operand like LEA in
the example program, then they are separated by commas.
Lastly an instruction can also have a comment attached to it, which is optional. The operand
section of an instruction is separated from the comment section by a semicolon.
LC-3 Memory
LC-3 memory consists of 216 locations, each b

CS 2360 Programming Assignment 5

 

CS 2360 Programming Assignment 5

 

lab 10

 

Week 10 Laboratory

A comment about exercise 5 below:

Lab 8

We have created some scripts that can automatically run your program against some tests. To run these tests you can execute the dry run program with an argument that corresponds to the lab and week, i.e. lab08 for this week. It expects to find all the programs to be submitted as part of this lab in the current directory. You can use dry run as follows:

Laboratory7

 

We have created some scripts that can automatically run your program against some tests. To run these tests you can execute the dry run program with an argument that corresponds to the lab and week, i.e. lab07 for this week. It expects to find all the programs to be submitted as part of this lab in the current directory. You can use dry run as follows:

CITS1001 2048 Game

2048 is a recent online computer game. Play takes place on a 4x4 board of squares on which a
sequence of tiles appears, each holding a number. Players move tiles around by sliding rows and
columns, with the aim of combining identical tiles to make higher numbers. The player's score is
determined largely by the tiles on the final board.
You can play 2048 online to get familiar with the game. In this project you will construct a computer
player for a simplified version of 浏览:837

LC3 ASM

This assignment aims to give you some experience with C programming and to help you gain
better understanding of the addressing mode of LC-3.
Important Notes
? There are subtle differences between various C compilers. We will use the GNU compiler gcc
on login.cs.auckland.ac.nz for marking. Therefore, you MUST ensure that your submissions
compile and run on login.cs.auckland.ac.nz. Submissions that fail to compile or run on
login.cs.auckland.ac.nz will attract NO marks.
? Markers will compile your program using command “gcc –o name name.c” where name.c is
the name of the source code of your program, e.g. part1.c. That is, the markers will NOT use
any compiler switches to supress the warning messages.
? Markers will use machine code that is different from the examples given in the
specifications when testing your programs.
? The outputs of your programs will be checked by a program. Thus, your program’s outputs
MUST be in the same format as shown in the example given in each part. You must make
sure that the registers appear in the same order as shown in the example and there are no
extra lines.
In this assignment, you are required to write C programs to implement a LC-3 simulator. That is,
the programs will execute the binary code generated by LC-3 assembler.
Part 1 (28 marks)
LC3Edit is used to write LC-3 assembly programs. After a program is written, we use the LC-3
assembler (i.e. the “Translate ? Assemble” function in LC3Edit) to convert the assembly
program into binary executable. The binary executable being generated by LC3Edit is named
“file.obj” where “file” is the name of the assembly program (excluding the “.asm” suffix). In this
specification, a “word” refers to a word in LC-3. That is, a word consists of two bytes. The
structure of the “file.obj” is as below:
? The first word (i.e. the first two bytes) is the starting address of the program.
? The subsequent words correspond to the instructions in the assembly program and the
memory locations reserved for the program using various LC-3 directives.
? In LC-3, data are stored in Big-endian format (refer to
https://en.wikipedia.org/wiki/Endianness to learn more about Big-endian format). For
2
example, if byte 0x12 in word 0x1234 is stored at address 0x3000, byte 0x34 is stored at
address 0x3001. This means, when you read a sequence of bytes from the executable of
an LC-3 assembly program from a file, the most significant bit of each word is read first.
In this part of the assignment, you are required to write a C program to display each word in the
“.obj” file of a program in hexadecimal form.
? Name the C program as “part1.c”.
? The name of the “.obj” file (the name of the file INCLUDES the “.obj” suffix) must be
given as a command line argument.
? In the output, each line shows the contents of one word.
? The value of each word must have a “0x” prefix.
? The letter digits “a” to “f” must be shown as lowercase letters.
Here is an example of the execution of the program. In this example, the LC-3 assembly program
is as below. The name of the executable of the assembly program is “p1.obj” (markers will
probably use a file with a different name and different contents).
.ORIG X4500
LD R0, A
LEA R1, B
LDI R2, C
AND R3, R0, R1
AND R3, R1, #0
NOT R4, R3
ADD R4, R4, #1
BRp F
ADD R3, R3, #1
F HALT
A .FILL X560A
B .FILL X4507
C .FILL X4501
.END
The execution of the program is shown below. The command line argument is marked in red.
$ ./part1 p1.obj
0x4500
0x2009
0xe209
0xa409
0x5601
0x5660
0x98ff
0x1921
0x0201
0x16e1
0xf025
0x560a
0x4507
3
0x4501
Part 2 (46 marks)
In this part, you are required to write a C program to implement a LC-3 simulator that is capable
of executing instruction “LD”.
? Name the C program as “part2.c”.
? The name of the “.obj” file (the name of the file INCLUDES the “.obj” suffix) must be
given as a command line argument.
? The state of the simulator consists of the contents of the 8 general purpose registers (i.e.
R0 to R7), the value of the program counter (i.e. PC), the contents of the instruction
register (i.e. IR), and the value of the condition code (i.e. CC).
? The values in R0 to R7, PC and IR should be shown as hexadecimal value. The value of CC
is either N, Z or P.
? Before the simulator starts executing a program, it should first display the initial state of
the LC-3 machine. In the initial state, R0 to R7 and IR should all be 0; PC should be the
starting address of the program to be executed; and CC should be set to Z.
? When displaying the value of R0 to R7, PC, IR and CC, a tab character (denoted as “\t” in

pencil game

Part A: MinMax Search and Alpha-Beta Pruning (10 points) [Must be handed in individually]

These are problems to work out on paper and hand it as a document HW10.txt. When you are asked to insert values into the tree, you may draw a diagram using "ASCII Art", or you may simply list the values in a breadth-first (level by level) transversal of the nodes in the diagram.

vector computation engine

In this assignment we will implement a vector computation engine that is able to construct vectors
and perform vector computations in the Java programming language. Your task is to implement the
incomplete functions in the provided scaffold code based on the included examples and documentation.
You are encouraged to ask questions on Ed using the assignments category. As with any assignment,
make sure that your work is your own, and you do not share your code or solutions with other students.
Working on your assignment
You can work on this assignment on your own computer or the lab machines. Students can also take
advantage of the online code editor on Ed. Simply navigate to the assignment page and you are able to
run, edit and submit code from within your browser. We recommend that you use Safari or Chrome.
It is important that you continually back up your assignment files onto your own machine, flash drives,
external hard drives and cloud storage providers. You are encouraged to submit your assignment while
you are in the process of completing it. By submitting you will obtain some feedback of your progress. 浏览:815

分页: 首页 12345678 尾页