Question
Mips instructions to assembly using java MIPS simulator front-end assembler/parser Hi everyone, I am looking for help in my computer architecture class. We have to
Mips instructions to assembly using java
MIPS simulator front-end assembler/parser
Hi everyone, I am looking for help in my computer architecture class. We have to build a java program that translates mips instructions into assembly language ... I haven't touched java in ages and Im going crazy trying to figure this out, can anyone PLZZZ help me
The instructions are as follows:
Below is test1.asm
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# This is test program 1. This program does nothing useful. add $s0, $0, $zero addi $t0, $t0, 100#test comment addi $a0, $a0,100 test: add $s0, $s0, $a0 # this is a comment addi $a0, $a0, -1 bne $a0, $0, test # this is another comment addi $a0, $a0, 100 test1: #test comment lw $a0, 8($a1) sw $a0,4($a1) j test1 jr $ra jal test1 slt$t0,$a0,$a1 beq$t0,$t1,test sub $t3, $t1, $t1 sll $a0, $a1, 2
--------------------------------------------------------------------------------------------------------------------------------------------------------
Below this is test1.output(that it should look like)
--------------------------------------------------------------------------------------------------------------------------------------------------------
000000 00000 00000 10000 00000 100000 001000 01000 01000 0000000001100100 001000 00100 00100 0000000001100100 000000 10000 00100 10000 00000 100000 001000 00100 00100 1111111111111111 000101 00100 00000 1111111111111101 001000 00100 00100 0000000001100100 100011 00101 00100 0000000000001000 101011 00101 00100 0000000000000100 000010 00000000000000000000000111 000000 11111 000000000000000 001000 000011 00000000000000000000000111 000000 00100 00101 01000 00000 101010 000100 01000 01001 1111111111110101 000000 01001 01001 01011 00000 100010 000000 00000 00101 00100 00010 000000
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Below is test2.asm
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# This is a test program 2. This program does nothing useful. add $t0, $t1, $t2 # more comments add $t3,$t4,$t5 # more comments add $t6, $t7, $t8 sub $t9, $s7, $s6 sub $s5, $s5, $s4 sub $s3, $s2, $s1 bne $sp, $ra, test2 test2: add $ra, $ra, $a1 # comment on label beq $a0, $a1, test2
--------------------------------------------------------------------------------------------------------------------------------------------------------
Below this is test2.output(that it should look like)
--------------------------------------------------------------------------------------------------------------------------------------------------------
000000 01001 01010 01000 00000 100000 000000 01100 01101 01011 00000 100000 000000 01111 11000 01110 00000 100000 000000 10111 10110 11001 00000 100010 000000 10101 10100 10101 00000 100010 000000 10010 10001 10011 00000 100010 000101 11101 11111 0000000000000000 000000 11111 00101 11111 00000 100000 000100 00100 00101 1111111111111110Description: For this lab, you will write a 2-pass assembler in Java. This assembler will load in MIPS assembly files and output the corresponding machine code (to the screen). The input to your assembler will be MIPS assembly files with comments, labels, and whitespace (spaces and tabs). Assume the following regarding the input: 1. Comments - Comments start with'#. A comment will start at the beginning of a line or may appear after an instruction Con the same line). If a comment appears after an instruction, there may be whitespace before the '#' symbol. 2. Labels - Labels will only contain alphanumeric characters (0-9, a-z, and A-Z). There will be no other symbols in the labels. A colon : will appear after a label. There may be whitespace before a label and the label may be followed by an instruction. A label may appear on a line without an instruction. 3. Blank lines may contain a mixture of whitespace characters 4. There may be some whitespace between operands. 5. Immediate values may be negative 6. Your assembler must support the following instructions: and, or, add, addi, sll, sub, slt, beq. bne, lw,sw.j.jr, and jal. 7. You do NOT need to support the following registers: Sat, Sk0, Sk1, Sgp. Sfp. 8. On the same line, whitespace may appear between a label and an instruction. There will always be whitespace between j/jal instructions and the target label 9. Your program should error check for invalid instructions. This assembler will be used in future lab assignments, so you may wish to create data structures to store the instructions. Implementation: This assembler is called a 2-pass assembler because it takes 2 passes through the file in order to generate the machine code. The first pass should run through all the lines of the file to compute the address of each label. During the second pass, all the instructions are converted to machine code For this lab, your assembler will output machine code to the screen. In future labs, the machine code will be stored in data structures Here are some sample files which you can use as test input: testl asm test2 asm test3 asm test4.asm The corresponding output: testLoutput test2.output test3.output test4.output Description: For this lab, you will write a 2-pass assembler in Java. This assembler will load in MIPS assembly files and output the corresponding machine code (to the screen). The input to your assembler will be MIPS assembly files with comments, labels, and whitespace (spaces and tabs). Assume the following regarding the input: 1. Comments - Comments start with'#. A comment will start at the beginning of a line or may appear after an instruction Con the same line). If a comment appears after an instruction, there may be whitespace before the '#' symbol. 2. Labels - Labels will only contain alphanumeric characters (0-9, a-z, and A-Z). There will be no other symbols in the labels. A colon : will appear after a label. There may be whitespace before a label and the label may be followed by an instruction. A label may appear on a line without an instruction. 3. Blank lines may contain a mixture of whitespace characters 4. There may be some whitespace between operands. 5. Immediate values may be negative 6. Your assembler must support the following instructions: and, or, add, addi, sll, sub, slt, beq. bne, lw,sw.j.jr, and jal. 7. You do NOT need to support the following registers: Sat, Sk0, Sk1, Sgp. Sfp. 8. On the same line, whitespace may appear between a label and an instruction. There will always be whitespace between j/jal instructions and the target label 9. Your program should error check for invalid instructions. This assembler will be used in future lab assignments, so you may wish to create data structures to store the instructions. Implementation: This assembler is called a 2-pass assembler because it takes 2 passes through the file in order to generate the machine code. The first pass should run through all the lines of the file to compute the address of each label. During the second pass, all the instructions are converted to machine code For this lab, your assembler will output machine code to the screen. In future labs, the machine code will be stored in data structures Here are some sample files which you can use as test input: testl asm test2 asm test3 asm test4.asm The corresponding output: testLoutput test2.output test3.output test4.output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started