Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me with this problem in python and using Regex expresiob , the question is Task 4 and the other things are the

can someone help me with this problem in python and using Regex expresiob , the question is Task 4 and the other things are the description , the file in assambly code and the start of the problem
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Lab 03 - ISA Assembler Design (Part 1) In this lab, you will be desgning an assembler to pre-process an assembly code. TODO - Pre-process assembly code ('example.asm') by completing Tasks 1 - 8 - Save the pre-processed code to a 'txt' file (Task 9) Some portions of the code have already been implemented for you such as reading the assembly code file, converting the register names to their equivalent values and printing the processed instructions and labels. Also, assume that inputs for a task are outputs from the previous task. Fa FoR TESTING: Function to print the instructions def print_asa_inst(inst_ asm): ". 'prints list of instructions" ". print("Assembly Instructions:") if len(inst_asm) w. e: print(None): else: for line in inst_asm: print(1ine) 6. W FOR TESTING: Function to print the labels def. print_ass_labels(1abels): ".prints list of labels".. print("Assembly Labels:") if len(labels) =o e: print (None) else: nax-len = max(5,max({ len ( label ) for label in labels ])) print(f"f "LAEEL" : c\{max_len }} i f VALuE': 325}) for label, val in labels.itens(): print (f"\{labeltc (max len }) | {val:>5}) inst ias ast=[] \# List to store instructions labels =[] list to stare Labels \#W reads asseably code and stores it in Gist of lists 'inst_asm' where axis a (rais) corresponds nir to each bine in the file and axis i (colums) corresponds to each arguant in that instruction filenate = "exasple, asn" inst, asn = read(filename) print_asn_inst(inst_asm) \# Implement a RISC-V program to multiply two numbers using loop adder main: Iw t3, 0(sl) addi a0, zero, 550 \# load first operand addi al, zero, 20 \# load second operand addi to, zero, 0 beq a0, zero, done \# if the first operand is equal to 0 , then goto done beq al, zero, done \# if the second operand is equal to 0 , then goto done loop: add to, a0, to addi al, al, 1 bne al, zero loop done: add a0, to, zero sw a0,0(s1) Implement a function to reoder arguments for load/save instructionss. Take a screenshot of the output and include it in your report. Load and save follow different instruction formats. Therefore, their arguments need to be re-ordered: Example: For load instructions - [instruction, rd, imm, rs1] - [instruction, rd, rs1,imm] Example: For store instructions - [instruction, rs1, imm, rd] [instruction, rd, rs1, imm] def loadsave_arg_reorder(inst_asm): \#.. enter your code here \# . end your code here \#N .. check your output by uncommenting the lines below .. \#H \# inst_asm = Loadsave_arg reorder(inst_asm) * print_asm_inst (inst_asm)

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

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago