
Write a program to draw this number triangl using MIPS assembly
language
The number of rows is inputted from keyboard.
NOTE :- I gave the reference C program which I programmed and took as reference for creating the MIPS program along with the output I generated for 10 rows and MIPS program is in BLOCK mode
C Program for reference :-
#include <stdio.h>
int main()
{
int i, space, rows, k=0;
char ch;
printf("Please enter no. of row for triangle: \n");
scanf("%d",&rows);
for(i=1; i<=rows; ++i, k=0)
{
for(space=1; space<=rows-i; ++space)
{
printf(" ");
}
while(k != 2*i-1)
{
if(k == 0)
printf("1");
else if(k == 2*i-2)
printf(" 1");
else if(i>1 && (k==((2*i)/2)-1))
printf(" |");
else if(i>2 && ((k==1) || (k == 2*i-3))){
ch = (k==1)? '<' : '>';
printf(" %c",ch);
}
else
printf(" -");
++k;
}
printf("\n");
}
return 0;
}
Mips Program :-
$LC0:
.ascii "Please enter no. of row for triangle: \000"
$LC1:
.ascii "%d\000"
$LC2:
.ascii " \000"
$LC3:
.ascii " 1\000"
$LC4:
.ascii " |\000"
$LC5:
.ascii " %c\000"
$LC6:
.ascii " -\000"
main:
addiu $sp,$sp,-56
sw $31,52($sp)
sw $fp,48($sp)
move $fp,$sp
sw $0,32($fp)
lui $2,%hi($LC0)
addiu $4,$2,%lo($LC0)
jal puts
nop
addiu $2,$fp,40
move $5,$2
lui $2,%hi($LC1)
addiu $4,$2,%lo($LC1)
jal scanf
nop
li $2,1 # 0x1
sw $2,24($fp)
$L14:
lw $2,40($fp)
lw $3,24($fp)
nop
slt $2,$2,$3
bne $2,$0,$L2
nop
li $2,1 # 0x1
sw $2,28($fp)
$L4:
lw $3,40($fp)
lw $2,24($fp)
nop
subu $3,$3,$2
lw $2,28($fp)
nop
slt $2,$3,$2
bne $2,$0,$L3
nop
lui $2,%hi($LC2)
addiu $4,$2,%lo($LC2)
jal printf
nop
lw $2,28($fp)
nop
addiu $2,$2,1
sw $2,28($fp)
b $L4
nop
$L3:
lw $2,24($fp)
nop
sll $2,$2,1
addiu $3,$2,-1
lw $2,32($fp)
nop
beq $3,$2,$L5
nop
lw $2,32($fp)
nop
bne $2,$0,$L6
nop
li $4,49 # 0x31
jal putchar
nop
b $L7
nop
$L6:
lw $2,24($fp)
nop
addiu $2,$2,-1
sll $3,$2,1
lw $2,32($fp)
nop
bne $3,$2,$L8
nop
lui $2,%hi($LC3)
addiu $4,$2,%lo($LC3)
jal printf
nop
b $L7
nop
$L8:
lw $2,24($fp)
nop
slt $2,$2,2
bne $2,$0,$L9
nop
lw $2,24($fp)
nop
sll $2,$2,1
srl $3,$2,31
addu $2,$3,$2
sra $2,$2,1
addiu $3,$2,-1
lw $2,32($fp)
nop
bne $3,$2,$L9
nop
lui $2,%hi($LC4)
addiu $4,$2,%lo($LC4)
jal printf
nop
b $L7
nop
$L9:
lw $2,24($fp)
nop
slt $2,$2,3
bne $2,$0,$L10
nop
lw $3,32($fp)
li $2,1 # 0x1
beq $3,$2,$L11
nop
lw $2,24($fp)
nop
sll $2,$2,1
addiu $3,$2,-3
lw $2,32($fp)
nop
bne $3,$2,$L10
nop
$L11:
lw $3,32($fp)
li $2,1 # 0x1
bne $3,$2,$L12
nop
li $2,60 # 0x3c
b $L13
nop
$L12:
li $2,62 # 0x3e
$L13:
sb $2,36($fp)
lb $2,36($fp)
nop
move $5,$2
lui $2,%hi($LC5)
addiu $4,$2,%lo($LC5)
jal printf
nop
b $L7
nop
$L10:
lui $2,%hi($LC6)
addiu $4,$2,%lo($LC6)
jal printf
nop
$L7:
lw $2,32($fp)
nop
addiu $2,$2,1
sw $2,32($fp)
b $L3
nop
$L5:
li $4,10 # 0xa
jal putchar
nop
lw $2,24($fp)
nop
addiu $2,$2,1
sw $2,24($fp)
sw $0,32($fp)
b $L14
nop
$L2:
move $2,$0
move $sp,$fp
lw $31,52($sp)
lw $fp,48($sp)
addiu $sp,$sp,56
j $31
nop
Output :-

Write a program to draw this number triangl using MIPS assembly language The number of rows is inputted from keyboard....
3. Write a program in assembly language that reads a number from the keyboard and displays it on the screen. 4. Write a program in assembly language to ask two digits from the user, store the digits in the EAX and EBX register, respectively, add the values, store the result in a memory location 'res' and finally display the result.
Write a program to print out a random number from 1..100. Use MIPS assembly language
Linear Search: Write a MIPS assembly language program that can search for a number that entered by user in an array with 20 integer numbers and prints the index of the number in the array if it is found and -1 if not found
Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write it out to the console.
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write it out to the console.
MIPS Assembly Language * Write a simple program to count the number of non overlapping repetitions of a character pattern in a character string. For example " the pattern "aa" appears twice in the in the string "aabbaaa". Provide a user interface to read the character pattern and the string.
CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code: 3. Write a MIPS program to find the sum of squares from 1 to n. Where n=10. For example, the sum of squares for 10 is as follows: 12+22+32+……+n2=385
Write a simple and short MIPS assembly language program that asks the user for 6 numbers, merge-sorts them, and then prints them out in ascending order comment each and every programme .(USING WINDOWS QtSpim) Note : This question is not giving desired solution may you please try it in a simple manner for six number inputed by the user.
Using Java language,
Write a program that read a string from the keyboard and counts the number of the letter A and the number of letter B and then prints the result