XML

CO5570 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for assign3

2023

Question 29 (2023):

Submission reference: IN3403

Not related to the assignment but when will we get any of our marks for the in class tests or A3?

Answer 29:

The A3 marks should be available within the next week. You will need to ask Mark about the ICTs.

Keywords: assign3


Question 20 (2023):

Submission reference: IN3360

When i translate instructions which include 3 parts(one opcode, one reg, one number), my reg translations occur at the end of the translation of the 8 bit string for some reason, while the padding is inbetween the opcode and reg. For example, JGT A,4 JLT D,39 translate to

>
01010001
00000100
01100010
00100111


code deleted

Answer 20:

You cannot assume that every instruction can be handled in the same way. Look at the encoding of each in the spec and group together the translations of those with similar structure.

The obvious conclusion is that you must be outputting the padding before the register encoding, which is clear from the order in which you do things in the method. So the solution is to print the register encoding before the padding for the instructions in which it is currently wrong.

Keywords: assign3


Question 18 (2023):

Submission reference: IN3357

Submission reference: IN3355 Im not entirely sure where to be moving/removing the output.println(). Ive tried removing them from

code deleted
and also adding output.println() to below this snippet like this.
code deleted
but neither works. Is it more than just moving the output.println(), or am i placing it in the wrong spots?

Answer 18:

It's about recognising that some instructions require two 8-bit outputs and so the 4-bits of opcode for the first of the pair need padding out with zeros to 8 bits. You have to do that for some instructions and not others. You can tell which you need to do it for from the assignment brief.

Keywords: assign3


Question 15 (2023):

Submission reference: IN3353

Apologies, here is the code:

code deleted
Could you tell me why the first line still produces a 16 character long line except for all other opcodes.

Answer 15:

It is simply that you have concatenated the binaryOpcode string and binaryOperand string together without a newline between them:

String binaryInstruction = binaryOpcode + binaryOperand;

Keywords: assign3


Question 14 (2023):

Submission reference: IN3352

When the program is ran, the translation of the first line is always 16 characters long but the other opcodes are translated in 8 characters, how can I fix the first line issue.

Answer 14:

Add some debugging information to your code. I have no way of knowing why this is without seeing your code, but you should be able to work the problem out by looking at what the first instruction is in the input file and then tracing how that is translated in your code.

Keywords: assign3


Question 13 (2023):

Submission reference: IN3351

my assembler can correctly translate numeric constants, but only if the constant is the fourth word in the instruction. How can I change my code so that it can also translate when the numeric constant is the second or third word in the instruction? For example, I can successfully translate instructions like ADD A D 5, and JLT D,A 39, but not LOADN 127 or JEQ A,125.

code deleted

Answer 13:

Don't try to translate all instructions in the same way. Have separate cases for the instructions that take either one or two operands.

Keywords: assign3


Question 11 (2023):

Submission reference: IN3349

Does the Main.java file need to be edited or is it just the Assembler.java. I'm not to sure if the Main.java has to call the Assembler.

Answer 11:

The Main class already calls the Assembler. You don't need to change anything in Main.

Keywords: assign3


Question 10 (2023):

Submission reference: IN3348

I have managed to get my assembler working for translating opcodes and regs, but I'm unsure of how to handle numeric constants for my code.

code deleted

Answer 10:

Try a Google search for 'java convert int to binary string with leading zeros'

Keywords: assign3

Referrers: Question 12 (2023)


Question 9 (2023):

Submission reference: IN3338

Do we need to add comments to explain our code?

Answer 9:

I will only mark you on functionality, so don't add comments for marking purposes.

Keywords: assign3


Question 8 (2023):

Submission reference: IN3337

Hello, I'm trying to get my method to work for translating just opcodes and regs at the moment. I tried testing it by passing a test.mal file with ADD D, A. It should translate to 00101001, but instead translates to null01, so im not sure what part of my code im doing wrong for this to happen.

code deleted

Answer 8:

You are not splitting on commas when there is more than one operand, so you never match one of the register names because it has a comma attached to it.

It would be worth putting some basic println debugging statements in for situations like this that you cannot understand. For instance:

System.err.println(Arrays.toString(segments));

Keywords: assign3


Question 7 (2023):

Submission reference: IN3335

Would you be able to create another tester so we can see if our output matches up with yours?

Answer 7:

I am not sure what another file would do that the current one doesn't. There is an example of every instruction in the current one, so you could create your own variations on that and check them against the spec.

Keywords: assign3


Question 6 (2023):

Submission reference: IN3334

for the test file you put out

LOADN 127
LOADA	34
ADD  D,  A
SUB A,D
JMP 16
JGT A,4
JLT D,39
JEQ A,125
COPY A , D
COPY D,A
STORE 1
when tested with my code my output was
0000000001111111
00011000000000
0010100100
0011011000
01001000000000
01010100000100
01101000100111
01110101111101
1000011000
1000100100
1001000000000001
is this correct?

Answer 6:

No, because all the lines should be exactly 8 bits long. I have provided the file of how the output should look.

Keywords: assign3


Question 5 (2023):

Submission reference: IN3333

As an example when I test my assembler with STORE 16 it should output 10010000 00010000 however my program outputs 100100010000 all on one line however its still the correct output is this allowed?

Answer 5:

No. The output must be broken over two lines. Just output the two parts separately rather than joining them together.

Keywords: assign3


Question 4 (2023):

Submission reference: IN3331

Are there any .mal files we can use for testing?

Answer 4:

I suggest that you create some of your own for now, but I will release some of mine shortly.

Keywords: assign3


Question 3 (2023):

Submission reference: IN3321

Hi, For submitting our solutions, should we create a .zip file containing ONLY the .java files? Not the .class files? In my case I've only 2 java files, "Main.java" and "Assembler.java"; what about cases where someone has other .java files? Will the "automatic testing harness" compile ALL .java files in the folder regardless of their names? Thank you.

Answer 3:

Yes, just your .java files. The testing harness will compile all submitted .java files that are need to build the full program.

Keywords: assign3


Question 2 (2023):

Submission reference: IN3291

The command for the assignment (A3) is not working (java.nio.file.NoSuchFileException: prog.mal)

Answer 2:

That means that you are either not passing prog.mal to the main method when you are running the program, or that the file does not exist in the working directory of the program when you are running the program.

If you are using an IDE to run the program then you will need to set up a program configuration that tells the IDE what program arguments to run the program with and where to run it (its working directory). It could be that you haven't done that.

Keywords: assign3 , to

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Tue Jan 23 16:52:10 2024
This document is maintained by David Barnes, to whom any comments and corrections should be addressed.