Hello there guys! I must implement a linked list in assembly (using MIPS). We're supposed to dynamically allocate memory for the nodes. This is what I am asked to do: Write a program in assembly (MIPS) that implements a link-list. The client can choose among the following options. So the program should include: 1. Insertion. Inserting new nodes at the correct spot keeping the list sorted in ascending order. 2. Deletion. Deleting a node, while still keeping the list in ascending order. 3. Printing in ascending order. Printing each node of the list from the first till the last one. …

Member Avatar
Member Avatar
+0 forum 3

Hello Evreryone, I am new here and would love some help with a project I have. I have to create a MIPS program where we implement different funcntions. I was able to do strcopy but Im having trouble finding how to code the strchr, strcmp, and memset functions. Unfortunately I am new to MIPS and do not know how the funcntions are written. Could anyone show me how to write the code or some code examples for the three library functions please? The functions will be called by a test file so no main is needed. Thanks for all the …

Member Avatar
Member Avatar
+0 forum 1

Basically title. Part of a larger program, but I can't figure out how to remove just the first letter (it's always not a number; A, B, C, X, etc.), and is always followed by numbers. So essentially, I'm trying to get "x234" to "234". I figured I could use lb $a0, 1($t0) to load the 2, then lb $a0, 2($t0) to load the 3, but I don't know how I could do that reliably for X character-long entries. I'm very new to MIPS (from a java background). Is there any fairly simple way to do this in mips?

Member Avatar
Member Avatar
+0 forum 5

i have a problem that i cant figure out how to solve it taht involves mips assembly. I need to ask the user for how many string they want to sort and then loop that many times and store all those strings in an array. I know how to ask for howmany strings they want to enter. I do not know how to store the data into the array and i do not know how to to print the data inside the array. Can anyone help me with this one?

Member Avatar
Member Avatar
-1 forum 1

One of the more common functions in any language is conversion of an integer to a string. This implementation, which demonstrates not only the common function activation record format but also a simple recursive function, was written in response to a recent question in which the OP posted an incomplete implementation; this should show how such a function could be written for the MIPS processor.

Member Avatar
Member Avatar
+0 forum 1

Hi. I need help to write one program in Assembly Mips. << read the characters typed by the user and store these characters a string. This string is later converted to an integer. If the user tries introducing non-valid characters (that is, other than the numerals 0 to 9) the program "complaining" and start all over. again.>> What's is wrong? .data text: .asciiz "\nEnter a number : " text2: .asciiz "\nThe value entered was: " text3: .asciiz "\nEntered an invalid character" val: .space 160 .text .globl main main: li $v0, 4 la $a0, text syscall main2: li $v0, 12 syscall …

Member Avatar
Member Avatar
+0 forum 1

Are these two instructions equivalent, i.e do they both do the exact same thing? `addi $s0,$s0,0` and `add $s0, $s0, $zero`

Member Avatar
Member Avatar
+0 forum 3

Hi Daniweb, I'm new to Assembly level programming and have been given an assignment in MIPS. Having started to plan the assignment, I have come to a rather open ended question that I want your opinion on: given that one has only so many registers to work with on Assembly level, how does one use these efficiently? For example, my assignment requires 4 registers to hold numbers, 4 more registers to hold addresses to arrays, and will probably need more later. And this is just my assignment, I'm sure many assembly programmers have faced a situation in which they have …

Member Avatar
Member Avatar
+0 forum 1

I have been working on a code that takes three strings, copies one string into another, takes the length of one of the strings, then concatenates the three strings, copies them, and get there length, but there is a problem. I need it to display 'The three strings combined are: I love assembly. When string 4 is copied into string 6, string 6 is: I love assembly. The length of string 6 is: 15. When string 3 is copied into string 5, string 5 is: assembly. The length of string 1 is: 2.' But instead of getting this, I am …

Member Avatar
Member Avatar
+0 forum 5

I am attempting to write a code with several different segment, such as combine two differents strings, compare two strings, find the length of a string. Right now, I am working on the part to get the string length, but when I run the code I have so far on Mars and QTSpim, instead of getting a length of 1, I am getting 0 to the first power displayed as the answer. What have I done wrong? .data S1: .asciiz "I " S2: .asciiz "love " S3: .asciiz "assembly" string: .asciiz "Our three strings are:\n" S4: .asciiz "\nThe three strings …

Member Avatar
Member Avatar
+0 forum 8

I'm really new to MIPS, so I'm having a hard time reading and understanding the code. For my homework, I was asked to identify and corrects errors in the folllowing code which computes the fibonacci number with given n passed in register $a0, and return it in $v0. I was most of the time lost in the middle, while trying to to follow the flow control ... Could you help me figure out the errors? Or just simply help me with the actual correct piece of code, so I can work on that and find the errors in this one. …

Member Avatar
Member Avatar
+0 forum 5

la $a1, answer li $v1, 4 syscall move $a0, $v0 # move value of recursion to print li $v0, 1 # print integer value syscall # executes print li $v0,10 # call to exit syscall # executes exit The uncommented section is the area giving me problems, answer is a string to say 'the answer is'. I cannot for the life of my figure out how print correctly. Currently it prints a small decimal. If I use $a0 and $v0 it prints 4 and if I use $a1 it is out of memory bounds.

Member Avatar
Member Avatar
+0 forum 1

Hey guys, I wrote a program that reads a file and then displays its 8, 16 and 32 bit checksum as well as the XOR values. I've managed to do it and it works fine under windows(using qtspim) but on centos(using mars) I get the following errors: Line 7 column five: "li": too many or incorrectly formatted operands. Expected li $t1, -100 Line 94 column 23: "$t0" : operand is of incorrect type Line 97 column 23: "0xfffffffc" : operand is of incorrect type Line 289 column 23: "$t1": operand is of incorrect type I need to get it working …

Member Avatar
Member Avatar
+0 forum 1

Hi I am fairly new at programming, I am working on a final project for my assembly language class where I am calculating college savings, this is the formula I believe I will end up using, fv= pv(1+(r/n))^nt, but I am in desperate need of help in writing that in to code in regards to the base * power. I have seen codes for other simulators but my professor requires us to use PCSpim. If anyone has any tips I would truly appreciate it.

Member Avatar
Member Avatar
+0 forum 1

pretty new to programming in assembly but my assignment is to write a GCD program but my program works sometimes and sometimes it doesn't work. if i put the smaller number first then the larger number i don't get the correct GCD but if i do the opposite i get the right answer example: if i enter 209 then 2585 it says the GCD is 209, which is incorrect but, if i enter 2585 then 209 it says the GCD is 11 which is correct looking for some guidance on to why my program is working one way and not …

Member Avatar
+0 forum 0

I'm about at my wits' end trying to figure this out. This is homework, so any hints would be appreciated. I was tasked with filling in a few blocks of code (these are denoted by comment lines with a number resting in the middle) involving function calls in MIPS. The program is supposed to read a specified number of integers (determined at run time by the first question), re-print them, then flip the order and print them again. It then asks if there is another case to enter, and exits following a negative response. Specifically, the error in question is …

Member Avatar
Member Avatar
+0 forum 5

Hello everyone,I'm new in MIPS programming, can anyone show me how to write code for these two programs. 1)Write a procedure called order that accepts two arguments. The first argument is the address of the array and the second argument is the index of an array element i. The procedure should perform the following data manipulation on the given array and return a value of 0 or 1 as appropriate: temp1 = a[i]; temp2 = a[i + 1]; if (temp1 > temp2) { a[i] = temp2; a[i + 1] = temp1; return 1 } else return 0 Devise a method …

Member Avatar
Member Avatar
+0 forum 2

Assume that the variables a, b, c and d are signed integers held in registers $s0 to $s3 respectively and put the result of the expression into register $t0. Also assume that the result of the multiplication will fit in 32 bits. (a + 2) * (b + c) * (d – c) Addi $s0, $s0, 2 # a + 2 Add $s1, $s1, $s2 # b + c Mul $t0, $s0, $s1 #(a+2) * (b+c) Sub $s2, $s3, $s2 # d – c Mul $t0, $t0, $s2 #(a+2) * (b+c) * (d –c ) Just wondering if im on …

Member Avatar
+0 forum 0

Hi there, I know this is probably a really stupid question, but I'm new to MIPS programming, and I was wondering, do you know if there's anything wrong with this code? This definitely isn't like high-level programming when the compiler shows you where the syntax error is. Not even sure if this is right or not :( Thanks for your help and sorry for the length! .data save: .word 1,2,4,2,5,6 size: .word 6 .text swap: sll $t1, $a1, 2 #shift bits by 2 add $t1, $a1, $t1 #set $t1 address to v[k] lw $t0, 0($t1) #load v[k] into t1 lw …

Member Avatar
Member Avatar
+0 forum 1

Figured I've been working on material for a while and would throw these up for everyone that needs them in the future to use. It's very simple implementation; if I get enough people asking me to, I will write the methods for each of the instructions so you don't have to do it yourselves. I know Jump and Link was hard enough for me. :) Welcome, Jamie

Member Avatar
Member Avatar
+0 forum 3

Hello, I'm trying to write a program using MIPS Assembly Language (I write the code in TextWrangler and run it in QTSpim) I was wondering how I would go about checking if a number is perfect or not. I know my first lines of code may be partially incorrect but when I figure out the loop or how to check if a number is perfect it will all be easier to solve. Does anyone have any suggestions? My code so far is below and I put a note where I would put the check to see if a number is …

Member Avatar
+0 forum 0

Hi I am testing this function itoa, but I got infinite loop. Could anyone help me to fix this? Here is my code Code blocks are created by indenting at least 4 spaces ... and can span multiple lines .data result_str: .asciiz " " #reserve 12 spaces prompt: .asciiz "Enter a string number: " answer: .asciiz "\nConverted string: " .text main: la $a0, prompt li $v0, 4 syscall li $v0, 5 syscall addi $t0, $zero, 10 #save 10 to $t0 move $t1, $v0 #move value in $v0 to $t0 loop: blt $t1, $zero, end divu $t1, $t0 #divide the number …

Member Avatar
+0 forum 0

I need to Compute 2x4 +7x3 -15x2 +3x+2 Using Horners Method. When I run this in QTSpim it doesn't give me any errors but I'm just wondering if everything is running completely right. For instance did I call "x" correctly? I'm trying to load the value for x from memory by using an lw instruction. Set up a base register to use with the instruction. After the polynomial was calculated I stored it in memory with an sw instruction (using the same base register). I just want to be sure I'm doing this right. Thank you for your assistance. [CODE] …

Member Avatar
+0 forum 0

Hey everyone, I am trying to create a random number generator with MIPS assembly. I have most of the code written, I just need to change my set number for a guessing game to a random number. I also want to ask the user if they'd like to play again. The formula I am using is r=(r*3+1)%10. User must enter a seed. How do I write this? Here is my code: [CODE] .data guessString: .asciiz "\nGuess a number: " tooHigh: .asciiz "Your guess is too high. Guess lower." tooLow: .asciiz "Your guess is too low. Guess higher." correctGuess: .asciiz "Your …

Member Avatar
+0 forum 0

I need help creating a two dimensional array in mips assembly. I am new to this kind of programming and i do not know how to approach the problem. i have to create an array max size 20 by 20 and then fill it up with data entered by the keyboard.

Member Avatar
Member Avatar
+0 forum 3

Hi, Need some help with MIPS I need to write a MIPS code that reads 10 characters string and then only print out value of 3rd, 5th and 7th character (remembering that first character is character 0) OUTPUT (should be somewhat like this): Enter 10 character string : i love you The 3rd character : l The 5th character : v The 7th character : I'm relatively new to this MIPS and need some help. Would greatly appreciate it!

Member Avatar
Member Avatar
+0 forum 1

Hi everyone. I am doing my homework for my computer organization class and I'm running into a small problem. Before I explain what I've done, what I expect to happen and what is happening, I want to assure everyone that I am not looking for an answer to my homework, but a solution to the problem I am having. First, I am to write a simple arithmetic code for: D = A^4 + B^6 / 3C - 2B The code I have written is as follow: [CODE] main: #start of main program and load initial values to temporary registers li …

Member Avatar
Member Avatar
+0 forum 4

Hello, I would like to know how can I put a binary number such as 110 in a register in MIPS? Thanks,

Member Avatar
+0 forum 0

I am writting a program in PCSPIM and I need help with taking user input and adding it to an existing string in my data declaration. I only need this little tidbit. Thanks :)

Member Avatar
Member Avatar
+0 forum 1

I am a beginner in MIPS and we're given this assignment to write a programs in MIPS to convert binary string to decimal i do some research and I found some helpful information: TO convert a binary number to decimal Let X be a binary number, n digits in length, composed of bits Xn-1 ... Xo Let D be a decimal number Let i be a counter 1. Let D = 0 2. Let i = 0 3. While i < n do: If Xi == 1 (i.e if bit i in X is 1), then set D = (D …

Member Avatar
+0 forum 0

The End.