Skip to content
Snippets Groups Projects
Commit 433c74e2 authored by Jeongseob Ahn's avatar Jeongseob Ahn
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing with 812 additions and 0 deletions
Makefile 0 → 100644
cse561sim: cse561.c util.c parse.c run.c
gcc -g -O2 $^ -o $@
.PHONY: clean
clean:
rm -rf *~ cse561sim
help:
@echo "The following options are provided with Make\n\t-make:\t\tbuild simulator\n\t-make clean:\tclean the build\n\t-make test:\ttest your simulator"
test: cse561sim test_1 test_2 test_3 test_4 test_5 test_leaf test_beq test_double_loop test_jal test_various_inst
test_1:
@echo "Testing example01"; \
./cse561sim -p sample_input/example01.o | diff -Naur sample_output/example01 - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_2:
@echo "Testing example02"; \
./cse561sim -p sample_input/example02.o | diff -Naur sample_output/example02 - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_3:
@echo "Testing example03"; \
./cse561sim -p sample_input/example03.o | diff -Naur sample_output/example03 - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_4:
@echo "Testing example04"; \
./cse561sim -p sample_input/example04.o | diff -Naur sample_output/example04 - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_5:
@echo "Testing example05"; \
./cse561sim -p sample_input/example05.o | diff -Naur sample_output/example05 - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_leaf:
@echo "Testing leaf_example"; \
./cse561sim -p sample_input/leaf_example.o | diff -Naur sample_output/leaf_example - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_beq:
@echo "Testing beq_test"; \
./cse561sim -p sample_input/beq_test.o | diff -Naur sample_output/beq_test - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_double_loop:
@echo "Testing double_loop"; \
./cse561sim -p sample_input/double_loop.o | diff -Naur sample_output/double_loop - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_jal:
@echo "Testing jal_test"; \
./cse561sim -p sample_input/jal_test.o | diff -Naur sample_output/jal_test - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
test_various_inst:
@echo "Testing various_inst"; \
./cse561sim -p sample_input/various_inst.o | diff -Naur sample_output/various_inst - ;\
if [ $$? -eq 0 ]; then echo "\tTest seems correct\n"; else echo "\tResults not identical, check the diff output\n"; fi
# Project 3. MIPS Pipelined Simulator
Skeleton developed by CMU and KAIST,
modified for Ajou Univeristy CSE561.
## Instructions
There are three files you may modify: `util.h`, `run.h`, and `run.c`.
### 1. util.h
We have setup the basic CPU\_State that is sufficient to implement the project.
However, you may decide to add more variables, and modify/remove any misleading variables.
### 2. run.h
You may add any additional functions that will be called by your implementation of `process_instruction()`.
In fact, we encourage you to split your implementation of `process_instruction()` into many other helping functions.
You may decide to have functions for each stages of the pipeline.
Function(s) to handle flushes (adding bubbles into the pipeline), etc.
### 3. run.c
**Implement** the following function:
void process_instruction()
The `process_instruction()` function is used by the `cycle()` function to simulate a `cycle` of the pipelined simulator.
Each `cycle()` the pipeline will advance to the next instruction (if there are no stalls/hazards, etc.).
Your internal register, memory, and pipeline register state should be updated according to the instruction
that is being executed at each stage.
cse561.c 0 → 100644
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* cse561.c */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* DO NOT MODIFY THIS FILE! */
/* You should only modify the run.c, run.h and util.h file! */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "util.h"
#include "parse.h"
#include "run.h"
/**************************************************************/
/* */
/* Procedure : load_program */
/* */
/* Purpose : Load program and service routines into mem. */
/* */
/**************************************************************/
void load_program(char *program_filename) {
FILE *prog;
int ii, word;
char buffer[33];
//to notifying data & text segment size
int flag = 0;
int text_index = 0;
int data_index = 0;
/* Open program file. */
prog = fopen(program_filename, "r");
if (prog == NULL) {
printf("Error: Can't open program file %s\n", program_filename);
exit(-1);
}
/* Read in the program. */
ii = 0;
//read 32bits + '\0' = 33
while (fgets(buffer,33,prog) != NULL)
{
if(flag == 0)
{
//check text segment size
text_size = fromBinary(buffer);
NUM_INST = text_size/4;
//initial memory allocation of text segment
INST_INFO = malloc(sizeof(instruction)*NUM_INST);
init_inst_info(NUM_INST);
}
else if(flag == 1)
{
//check data segment size
data_size = fromBinary(buffer);
}
else
{
if(ii < text_size){
INST_INFO[text_index++] = parsing_instr(buffer, ii);
}
else if(ii < text_size + data_size){
parsing_data(buffer, ii-text_size);
}
else
{
//Do not enter this case
//assert(0);
//However, there is a newline in the input file
}
ii += 4;
}
flag++;
}
CURRENT_STATE.PC = MEM_TEXT_START;
//printf("Read %d words from program into memory.\n\n", ii/4);
}
/************************************************************/
/* */
/* Procedure : initialize */
/* */
/* Purpose : Load machine language program */
/* and set up initial state of the machine. */
/* */
/************************************************************/
void initialize(char *program_filename) {
int i;
init_memory();
load_program(program_filename);
INSTRUCTION_COUNT = 0;
CYCLE_COUNT = 0;
BR_BIT = TRUE;
FORWARDING_BIT = TRUE;
for (i = 0; i < PIPE_STAGE; i++){
CURRENT_STATE.PIPE[i] = 0;
CURRENT_STATE.PIPE_STALL[i] = FALSE;
}
CURRENT_STATE.IF_ID_INST = 0;
CURRENT_STATE.IF_ID_NPC = 0;
CURRENT_STATE.ID_EX_NPC = 0;
CURRENT_STATE.ID_EX_REG1 = 0;
CURRENT_STATE.ID_EX_REG2 = 0;
CURRENT_STATE.ID_EX_IMM = 0;
CURRENT_STATE.EX_MEM_ALU_OUT = 0;
CURRENT_STATE.EX_MEM_BR_TARGET = 0;
CURRENT_STATE.MEM_WB_ALU_OUT = 0;
RUN_BIT = TRUE;
FETCH_BIT = TRUE;
}
/***************************************************************/
/* */
/* Procedure : main */
/* */
/***************************************************************/
int main(int argc, char *argv[]) {
char** tokens;
int count = 1;
int addr1 = 0;
int addr2 = 0;
int num_inst = 0;
int i = 100; //for loop
int mem_dump_set = 0;
int debug_set = 0;
int num_inst_set = 0;
int pipe_dump_set = 0;
/* Error Checking */
if (argc < 2)
{
printf("Usage: %s [-nobp] [-nof] [-m addr1:addr2] [-d] [-p] [-n num_instr] inputBinary\n", argv[0]);
exit(1);
}
initialize(argv[argc-1]);
//for checking parse result
while(count != argc-1){
if(strcmp(argv[count], "-m") == 0){
tokens = str_split(argv[++count],':');
addr1 = (int)strtol(*(tokens), NULL, 16);
addr2 = (int)strtol(*(tokens+1), NULL, 16);
mem_dump_set = 1;
}
else if(strcmp(argv[count], "-d") == 0)
debug_set = 1;
else if(strcmp(argv[count], "-n") == 0){
num_inst = (int)strtol(argv[++count], NULL, 10);
num_inst_set = 1;
}
else if(strcmp(argv[count], "-p") == 0)
pipe_dump_set = 1;
else if(strcmp(argv[count], "-nobp") == 0)
BR_BIT = FALSE;
else if(strcmp(argv[count], "-nof") == 0)
FORWARDING_BIT = FALSE;
else {
printf("Usage: %s [-m addr1:addr2] [-d] [-p] [-n num_instr] inputBinary\n", argv[0]);
exit(1);
}
count++;
}
if(num_inst_set) MAX_INSTRUCTION_NUM = num_inst;
else MAX_INSTRUCTION_NUM = i;
if(num_inst_set && num_inst <= 0){
printf("Error: The number of instructions should be positive integer\n");
return -1;
}
if(debug_set || pipe_dump_set){
printf("Simulating for %lu instructions...\n\n", MAX_INSTRUCTION_NUM);
while(RUN_BIT){
cycle();
if(pipe_dump_set) pdump();
if(debug_set) rdump();
}
if(!debug_set) rdump();
if(mem_dump_set) mdump(addr1, addr2);
printf("Simulator halted after %lu cycles\n\n", CYCLE_COUNT);
}
else{
run();
rdump();
if(mem_dump_set) mdump(addr1, addr2);
}
return 0;
}
parse.c 0 → 100644
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* parse.c */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* DO NOT MODIFY THIS FILE! */
/* You should only modify the run.c, run.h and util.h file! */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
#include <stdio.h>
#include "util.h"
#include "parse.h"
int text_size;
int data_size;
instruction parsing_instr(const char *buffer, const int index)
{
instruction instr;
char opcode[7],rs[6],rt[6],rd[6],shamt[6],imm[17],target[27],func_code[7] = {0};
int word;
word = fromBinary(buffer);
mem_write_32(MEM_TEXT_START + index, word);
sscanf(buffer, "%6s", opcode);
instr.value = word;
instr.opcode = (short)fromBinary(opcode);
switch(instr.opcode)
{
//Type I
case 0x9: //(0x001001)ADDIU
case 0xc: //(0x001100)ANDI
case 0xf: //(0x001111)LUI
case 0xd: //(0x001101)ORI
case 0xb: //(0x001011)SLTIU
case 0x23: //(0x100011)LW
case 0x2b: //(0x101011)SW
case 0x4: //(0x000100)BEQ
case 0x5: //(0x000101)BNE
sscanf(buffer,"%6s%5s%5s%16s",opcode,rs,rt,imm);
instr.r_t.r_i.rs = (unsigned char)fromBinary(rs);
instr.r_t.r_i.rt = (unsigned char)fromBinary(rt);
instr.r_t.r_i.r_i.imm = (short)fromBinary(imm);
break;
//TYPE R
case 0x0: //(0x000000)ADDU, AND, NOR, OR, SLTU, SLL, SRL, SUBU if JR
sscanf(buffer,"%6s%5s%5s%5s%5s%6s",opcode,rs,rt,rd,shamt,func_code);
instr.func_code = (short)fromBinary(func_code);
//JR exception
if(instr.func_code == 0x8)
instr.r_t.r_i.rs = (unsigned char)fromBinary(rs);
else
{
instr.r_t.r_i.rs = (unsigned char)fromBinary(rs);
instr.r_t.r_i.rt = (unsigned char)fromBinary(rt);
instr.r_t.r_i.r_i.r.rd = (unsigned char)fromBinary(rd);
instr.r_t.r_i.r_i.r.shamt = (unsigned char)fromBinary(shamt);
}
break;
//TYPE J
case 0x2: //(0x000010)J
case 0x3: //(0x000011)JAL
sscanf(buffer,"%6s%26s",opcode,target);
instr.r_t.target = fromBinary(target);
break;
default:
printf("Not available instruction\n");
assert(0);
}
return instr;
}
void parsing_data(const char *buffer, const int index)
{
uint32_t word;
word = fromBinary(buffer);
mem_write_32(MEM_DATA_START + index, word);
}
void print_parse_result()
{
int i;
printf("Instruction Information\n");
for(i = 0; i < text_size/4; i++)
{
printf("INST_INFO[%d].value : %x\n",i, INST_INFO[i].value);
printf("INST_INFO[%d].opcode : %d\n",i, INST_INFO[i].opcode);
switch(INST_INFO[i].opcode)
{
//Type I
case 0x9: //(0x001001)ADDIU
case 0xc: //(0x001100)ANDI
case 0xf: //(0x001111)LUI
case 0xd: //(0x001101)ORI
case 0xb: //(0x001011)SLTIU
case 0x23: //(0x100011)LW
case 0x2b: //(0x101011)SW
case 0x4: //(0x000100)BEQ
case 0x5: //(0x000101)BNE
printf("INST_INFO[%d].rs : %d\n",i, INST_INFO[i].r_t.r_i.rs);
printf("INST_INFO[%d].rt : %d\n",i, INST_INFO[i].r_t.r_i.rt);
printf("INST_INFO[%d].imm : %d\n",i, INST_INFO[i].r_t.r_i.r_i.imm);
break;
//TYPE R
case 0x0: //(0x000000)ADDU, AND, NOR, OR, SLTU, SLL, SRL, SUBU if JR
printf("INST_INFO[%d].func_code : %d\n",i, INST_INFO[i].func_code);
printf("INST_INFO[%d].rs : %d\n",i, INST_INFO[i].r_t.r_i.rs);
printf("INST_INFO[%d].rt : %d\n",i, INST_INFO[i].r_t.r_i.rt);
printf("INST_INFO[%d].rd : %d\n",i, INST_INFO[i].r_t.r_i.r_i.r.rd);
printf("INST_INFO[%d].shamt : %d\n",i, INST_INFO[i].r_t.r_i.r_i.r.shamt);
break;
//TYPE J
case 0x2: //(0x000010)J
case 0x3: //(0x000011)JAL
printf("INST_INFO[%d].target : %d\n",i, INST_INFO[i].r_t.target);
break;
default:
printf("Not available instruction\n");
assert(0);
}
}
printf("Memory Dump - Text Segment\n");
for(i = 0; i < text_size; i+=4)
printf("text_seg[%d] : %x\n", i, mem_read_32(MEM_TEXT_START + i));
for(i = 0; i < data_size; i+=4)
printf("data_seg[%d] : %x\n", i, mem_read_32(MEM_DATA_START + i));
printf("Current PC: %x\n", CURRENT_STATE.PC);
}
parse.h 0 → 100644
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* parse.h */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* DO NOT MODIFY THIS FILE! */
/* You should only modify the run.c, run.h and util.h file! */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
#ifndef _PARSE_H_
#define _PARSE_H_
#include <stdio.h>
#include "util.h"
extern int text_size;
extern int data_size;
/* functions */
instruction parsing_instr(const char *buffer, const int index);
void parsing_data(const char *buffer, const int index);
void print_parse_result();
#endif
run.c 0 → 100644
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* run.c */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
#include <stdio.h>
#include "util.h"
#include "run.h"
/***************************************************************/
/* */
/* Procedure: get_inst_info */
/* */
/* Purpose: Read insturction information */
/* */
/***************************************************************/
instruction* get_inst_info(uint32_t pc) {
return &INST_INFO[(pc - MEM_TEXT_START) >> 2];
}
/***************************************************************/
/* */
/* Procedure: process_instruction */
/* */
/* Purpose: Process one instrction */
/* */
/***************************************************************/
void process_instruction(){
/** Your implementation here */
}
run.h 0 → 100644
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* run.h */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
#ifndef _RUN_H_
#define _RUN_H_
#include <stdio.h>
#include "util.h"
#define OPCODE(INST) (INST)->opcode
#define SET_OPCODE(INST, VAL) (INST)->opcode = (short)(VAL)
#define FUNC(INST) (INST)->func_code
#define SET_FUNC(INST, VAL) (INST)->func_code = (short)(VAL)
#define RS(INST) (INST)->r_t.r_i.rs
#define SET_RS(INST, VAL) (INST)->r_t.r_i.rs = (unsigned char)(VAL)
#define RT(INST) (INST)->r_t.r_i.rt
#define SET_RT(INST, VAL) (INST)->r_t.r_i.rt = (unsigned char)(VAL)
#define RD(INST) (INST)->r_t.r_i.r_i.r.rd
#define SET_RD(INST, VAL) (INST)->r_t.r_i.r_i.r.rd = (unsigned char)(VAL)
#define FS(INST) RD(INST)
#define SET_FS(INST, VAL) SET_RD(INST, VAL)
#define FT(INST) RT(INST)
#define SET_FT(INST, VAL) SET_RT(INST, VAL)
#define FD(INST) SHAMT(INST)
#define SET_FD(INST, VAL) SET_SHAMT(INST, VAL)
#define SHAMT(INST) (INST)->r_t.r_i.r_i.r.shamt
#define SET_SHAMT(INST, VAL) (INST)->r_t.r_i.r_i.r.shamt = (unsigned char)(VAL)
#define IMM(INST) (INST)->r_t.r_i.r_i.imm
#define SET_IMM(INST, VAL) (INST)->r_t.r_i.r_i.imm = (short)(VAL)
#define BASE(INST) RS(INST)
#define SET_BASE(INST, VAL) SET_RS(INST, VAL)
#define IOFFSET(INST) IMM(INST)
#define SET_IOFFSET(INST, VAL) SET_IMM(INST, VAL)
#define IDISP(INST) (SIGN_EX (IOFFSET (INST) << 2))
#define COND(INST) RS(INST)
#define SET_COND(INST, VAL) SET_RS(INST, VAL)
#define CC(INST) (RT(INST) >> 2)
#define ND(INST) ((RT(INST) & 0x2) >> 1)
#define TF(INST) (RT(INST) & 0x1)
#define TARGET(INST) (INST)->r_t.target
#define SET_TARGET(INST, VAL) (INST)->r_t.target = (mem_addr)(VAL)
#define ENCODING(INST) (INST)->encoding
#define SET_ENCODING(INST, VAL) (INST)->encoding = (int32)(VAL)
#define EXPR(INST) (INST)->expr
#define SET_EXPR(INST, VAL) (INST)->expr = (imm_expr*)(VAL)
#define SOURCE(INST) (INST)->source_line
#define SET_SOURCE(INST, VAL) (INST)->source_line = (char *)(VAL)
/* Sign Extension */
#define SIGN_EX(X) (((X) & 0x8000) ? ((X) | 0xffff0000) : (X))
#define COND_UN 0x1
#define COND_EQ 0x2
#define COND_LT 0x4
#define COND_IN 0x8
/* Minimum and maximum values that fit in instruction's imm field */
#define IMM_MIN 0xffff8000
#define IMM_MAX 0x00007fff
#define UIMM_MIN (unsigned)0
#define UIMM_MAX ((unsigned)((1<<16)-1))
#define BRANCH_INST(TEST, TARGET, NULLIFY) \
{ \
if (TEST) \
{ \
uint32_t target = (TARGET); \
JUMP_INST(target) \
} \
}
#define JUMP_INST(TARGET) \
{ \
CURRENT_STATE.PC = (TARGET); \
}
#define LOAD_INST(DEST_A, LD, MASK) \
{ \
LOAD_INST_BASE (DEST_A, (LD & (MASK))) \
}
#define LOAD_INST_BASE(DEST_A, VALUE) \
{ \
*(DEST_A) = (VALUE); \
}
/* functions */
instruction* get_inst_info(uint32_t pc);
void process_instruction();
/* Add any functions declarations that you require */
/* Suggestions for some possible functions */
//void IF_Stage();
//void ID_Stage();
//void EX_Stage();
//void MEM_Stage();
//void WB_Stage();
#endif
000000000000000000000000001010000000000000000000000000000000000000100101000010000000000000000000001001010010100100000000000000000000000100101000010010000010000100100101000010000000000000000001001011010000011100000000000011110001010011100000111111111111110000100101010010100000000000000000001001010110101100000000000000000010010110001100000000000000000000100101101011010000000000000000
.data
.text
main:
addiu $8, $8, 0
addiu $9, $9, 0
loop:
addu $9, $9, $8
addiu $8, $8, 1
sltiu $7, $8, 15
bne $7, $0, loop
addiu $10, $10, 0
addiu $11, $11, 0
addiu $12, $12, 0
addiu $13, $13, 0
00000000000000000000000001111000000000000000000000000000000010000011110000011000000100000000000000111100000110010001000000000000001101110011100100000000000001001000111100001000000000000000000010001111001010010000000000000000001001000001010100000000000000010010010010000100000000000000000100000001010010000101000000100001000000010100100001011000001001000011000101001100111100001111000000101100100101100000000000001010000100101100000000000000000000010000100000010000000000000000011000100100101001010000000000000001000000011010100101101000001001110000000110101001011100000010010100000000000011010111100010000000000000000000110110000000010000100000000010101001101110000010101100010110111101010000000000000010000011000001000000000000000011010000000000000000000000000010000100000000101001001000100000100011101011110010101000000000000001001010111100101011000000000000100010101111001011000000000000001100101011110010110100000000000100001010111100101110000000000001010010101111001011110000000000011000101011110011000000000000000111000000000000000000000000000000101000000000000000000000000000010100
\ No newline at end of file
.data
data1: .word 10
data2: .word 20
.text
main:
la $24, data1
la $25, data2
lw $8, 0($24)
lw $9, 0($25)
addiu $21, $0, 1
loop1:
addiu $4, $4, 1
addu $10, $10, $8
and $11, $10, $8
andi $12, $10, 0xf0f0
sltiu $22, $4, 10
beq $22, $0, loop2
j loop1
loop2:
addiu $5, $5, 1
nor $13, $13, $9
or $14, $13, $9
sll $15, $13, 2
srl $16, $13, 1
sltu $23, $5, $9
bne $23, $21, tail
jal loop2
addu $0, $0, $0
tail:
subu $17, $5, $4
sw $10, 4($25)
sw $11, 8($25)
sw $12, 12($25)
sw $13, 16($25)
sw $14, 20($25)
sw $15, 24($25)
sw $16, 28($25)
000000000000000000000000010110000000000000000000000000000000110000000010001000001000100000100100000000100100000010010000001001000011110000001000000100000000000000111100000010010001000000000000001101010010100100000000000001000000000101000000010100000010010000000001011000000101100000100100001001100011000100000000000000010010010101101011000000000000000100000001001000000100100000100101000101010110100011111111111111000010011001010010000000000000001000100101011010110000000000000001000000000001000110010000010000000000000000010010100010000100001000000010001100101001100000100100000101010110100111111111111110100000000010111111001010000010000100000010001100101000000000100111000100010100100000000000000000010000100000010000000000000000011000110110000100001111000011110000000000000000000000000000011001000000000000000000000000001100100000010010001101000101011001111000
\ No newline at end of file
.data
data1: .word 100
data2: .word 200
data3: .word 0x12345678
.text
main:
and $17, $17, $0
and $18, $18, $0
la $8, data1
la $9, data2
and $10, $10, $0
lab1:
and $11, $11, $0
lab2:
addiu $17, $17, 0x1
addiu $11, $11, 0x1
or $9, $9, $0
bne $11, $8, lab2
lab3:
addiu $18, $18, 0x2
addiu $11, $11, 1
sll $18, $17, 1
srl $17, $18, 1
and $19, $17, $18
bne $11, $9, lab3
lab4:
addu $5, $5, $31
nor $16, $17, $18
beq $10, $8, lab5
j lab1
lab5:
ori $16, $16, 0xf0f0
000000000000000000000000001111000000000000000000000000000001000000100100000000100000010000000000000000000100001000011000001000010000000001100010001000000010010100000000000001010011010000000000001001001100011100100111000011110000000011100010010000000010001100000000100000110100100000100111001101000100101000000000111111110000000000000110010110010100001000111100000001000001000000000000001101001000010000000000000011000000000101100101011010000010010000110000100011100000000001100100001111000001000100000000011001000010010000000010000000000000101000000000000000000000000000000011000000000000000000000000011110110000000000000000000100001111101000010001000100010001000100010001
\ No newline at end of file
.data
array: .word 3
.word 123
.word 4346
array2: .word 0x11111111
.text
main:
addiu $2, $0, 1024 //00
addu $3, $2, $2 //04
or $4, $3, $2 //08
sll $6, $5, 16 //0c
addiu $7, $6, 9999 //10
subu $8, $7, $2 //14
nor $9, $4, $3 //18
ori $10, $2, 255 //1c
srl $11, $6, 5 //20
la $4, array2 //24: lui $4, $4, 0x1000 / 28: ori $4, $4, 0x000c
and $13, $11, $5 //2c
andi $14, $4, 100 //30
lui $17, 100 //34
addiu $2, $0, 0xa //38
000000000000000000000000001111000000000000000000000000000001000000111100000000110001000000000000100011000110010100000000000000001000110001101000000000000000010010001100011010010000000000001000100011000110101000000000000011000010010010100101000000000001100000100100000001100000000001111100000000001010011000111000001000011010110001100101000000000001000010101100011001100000000000010100101011000110011100000000000110000010010001100011000000000000110010001100011011001111111111111100100011000110110111111111111110001000110001101110111111111111010000000000000000000000000001100100000000000000000000000000110010000001001000110100010101100111100000000000000000010010001101000001
\ No newline at end of file
.data
data1: .word 100
data2: .word 200
data3: .word 0x12345678
.word 0x12341
.text
main:
lui $3, 0x1000 //00
lw $5, 0($3) //04
lw $8, 4($3) //08
lw $9, 8($3) //0c
lw $10, 12($3) //10
addiu $5, $5, 24 //14
addiu $6, $0, 124 //18
addu $7, $5, $6 //1c
sw $5, 16($3) //20
sw $6, 20($3) //24
sw $7, 24($3) //28
addiu $3, $3, 12 //2c
lw $12, -4($3) //30
lw $13, -8($3) //34
lw $14, -12($3) //38
00000000000000000000000001000100000000000000000000000000000000000000000010000101000100000010000100000000110001110001000000100001000000000110001001001000001000110000000101100000010110000010010000100101010010100000000000000001000000001100000000110000001001010000110000010000000000000000100000000000000000000000000000100001000000000000011000111000100000000000000000000100001010001000001000101101010010010000000001100100000100010010000000000000000000010000001111100000000000000000100000000000010000110010000000101011000101001000000000000000000000010000100000010000000000000000001100110110000100001111000011110000
\ No newline at end of file
.data
.text
main:
addu $2, $4, $5
addu $2, $6, $7
subu $9, $3, $2
lab1:
and $11, $11, $0
addiu $10, $10, 0x1
or $6, $6, $0
jal lab3
addu $0, $0, $0
lab3:
sll $7, $6, 2
srl $5, $4, 2
sltiu $9, $10, 100
beq $9, $0, lab4
jr $31
lab4:
sltu $4, $2, $3
bne $4, $0, lab5
j lab1
lab5:
ori $16, $16, 0xf0f0
00000000000000000000000001101100000000000000000000000000000101000011110000001111000100000000000000110101111011110000000000001100001001011000110011111111100111000010010111001110111111111111111100100101101011011111111111111111000000001000010100010000001000010000000011000111000100000010000100000000011000100100100000100011000000010110000001011000001001000010010101001010000000000000000100000000110000000011000000100101000011000001000000000000000011010000000000000000000000000010000110001101111001100000000000000100000000000000011000111000100000001010110111100111000000000000100000000000000001000010100010000010000000001010000000101000001001110010110101001001111111111111110000010001001000000000000000000001000000111110000000000000000010000011110000010001000100000000000010001110001100100000000000010101000000000100001100100000001010110001010010000000000000000000000100001000000100000000000000001000001101100001000011110000111100000000000000000000000000000000001100000000000000000001000000000000000000000000111101001100001010100111111111111111111111111111111001111111111111111111111111111111
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment