Project 3
.docx
keyboard_arrow_up
School
Arizona State University *
*We aren’t endorsed by this school
Course
230
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
6
Uploaded by MateWorld4934
.org 0x10000000
# Initializations
# NOTE: You may add initializations after line 10, but please do not
# remove or change the initializations to $sp, $s0, $s1, or $s2
li $sp, 0x10fffffc
# Starting address of the empty stack
li $s0, 0xf0000000
# UART base address
li $s1, array_ptr
# Array head pointer
li $s2, array_ptr
# Array tail pointer
####################################################################
# Do not make changes to the jump to main, the allocation of
# memory for the array, or the main loop
####################################################################
j main
nop
array_ptr:
# Label pointing to the array
.space 100
# Reserve space for a 100-character array
main:
jal poll_UART
nop
jal period_check
nop
jal space_check
nop
jal case_check
nop
jal array_push
nop
j main
nop
# The "poll_UART" function should poll the status register of the UART.
# If the 2^1 bit position (ready bit) is set to 1, then it should copy
# the receive buffer's value into $v0 and send a clear status command (2^1)
# to the command register before returning.
poll_UART:
lw $t1, 4($s0)
# Load the status register
li $t2, 0b10
# Bit mask for the ready bit
and $t3, $t1, $t2
# Check if the ready bit is set
beq $t3, $0, poll_UART
# If not ready, continue polling
nop
lw $v0, 8($s0)
# Read the receive buffer
sw $t2, 0($s0)
# Send a clear status command to the command register
jr $ra
nop
# The "period_check" function should check if the current character ($v0)
# is a period ("."). If it is a period, then it should go to the label
# "palindrome_check". If the character is not a period, then it should use
# the included return.
period_check:
li $t0, 0x2E
# ASCII value of '.'
beq $v0, $t0, palindrome_check
# Check if the current character is a period
nop
jr $ra
nop
# The "space_check" function should check if the current character ($v0)
# is a space (" "). If it is, then it should jump to "main" to skip saving
# the space character. If not, it should use the included return.
space_check:
li $t4, 0x20
# ASCII value of space character
beq $t4, $v0, main
# Check if the current character is a space
nop
jr $ra
nop
# The "case_check" function should perform a single inequality check.
# If the current character ($v0) is greater than the ASCII value of 'Z',
# which indicates the current character is lowercase, then it should convert
# the value of $v0 to the uppercase equivalent and then return. If the
# current character ($v0) is already uppercase (meaning the inequality
# mentioned before was not true), then the function should return without
# performing a conversion.
case_check:
li $t5, 'a'
# Load 'a' into $t5
li $t6, 'z'
# Load 'z' into $t6
slt $t7, $v0, $t5
# Compare if input is less than 'a'
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
If this is needed to be programmed, please use c++ language thanks!
arrow_forward
Activity no. 23
Description:
This activity is to implement Stack in an array.
Required Materials:
1. Computer set or Laptop
Required Time:
Procedure:
Create a program that will do the following:
1. Push to stack numbers in an array.
2. Pop the last number you push to stack.
Required Output:
1. Source Code
2. Program Output
3. Draw the flow of data you created.
arrow_forward
SKELETON CODE IS PROVIDED ALONG WITH C AND H FILES.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "node.h"
#include "stack_functions.h"
#define NUM_VERTICES 10
/** This function takes a pointer to the
adjacency matrix of a Graph and the
size of this matrix as arguments and
prints the matrix
*/
void print_graph(int * graph, int size);
/** This function takes a pointer to the
adjacency matrix of a Graph, the size
of this matrix, the source and dest
node numbers along with the weight or
cost of the edge and fills the adjacency
matrix accordingly.
*/
void add_edge(int * graph, int size, int src, int dst, int cost);
/** This function takes a pointer to the adjacency matrix of
a graph, the size of this matrix, source and destination
vertex numbers as inputs and prints out the path from the
source vertex to the destination vertex. It also prints
the total cost of this…
arrow_forward
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
.code
INVOKE ExitProcess,0
main ENDP
END main
arrow_forward
When a stack is created, what are the initial values in the elements array?
arrow_forward
The program should be written in C language
arrow_forward
Subject-Object oriented programing
Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screen
In the same program, remove the element at the last index of the Array List. Print the resulting list tothe screen.
arrow_forward
Double pointers: Describe how this operation can be done in O(1) time if there are pointers in each node to both the previous and the next node.
arrow_forward
An array is a collection of similar data elements stored at contiguous memory locations. It is the
simplest data structure where each data element can be accessed directly by only using its index
number. The following is an array of unsorted numbers called NumArr.
NumArr:
24
56
78
79
34
75
2
23
arrow_forward
P3: this is data structure of algorithms subject and topic is all about Stack Applications
arrow_forward
given code lab4
#include <stdio.h>#include <stdlib.h>
/* typical C boolean set-up */#define TRUE 1#define FALSE 0
typedef struct StackStruct{int* darr; /* pointer to dynamic array */int size; /* amount of space allocated */int inUse; /* top of stack indicator - counts how many values are on the stack */} Stack;
void init (Stack* s){s->size = 2;s->darr = (int*) malloc ( sizeof (int) * s->size );s->inUse = 0;}
void push (Stack* s, int val){/* QUESTION 7 *//* check if enough space currently on stack and grow if needed */
/* add val onto stack */s->darr[s->inUse] = val;s->inUse = s->inUse + 1;}
int isEmpty (Stack* s){if ( s->inUse == 0)return TRUE;elsereturn FALSE;}
int top (Stack* s){return ( s->darr[s->inUse-1] );}
/* QUESTION 9.1 */void pop (Stack* s){if (isEmpty(s) == FALSE)s->inUse = s->inUse - 1;}
void reset (Stack* s){/* Question 10: how to make the stack empty? */
}
int main (int argc, char** argv){Stack st1;
init (&st1);…
arrow_forward
Subject-Object oriented programing
Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screenb) In the same program, insert an element in the above ArrayList at index 2. The resulting Array Listmust be one element larger. Print the resulting list to the screen.c) In the same program, replace the element in the ArrayList at index 2 by null. Print the resulting list tothe screen.d) In the same program, remove the element at the last index of the Array List. Print the resulting list tothe screen.e) In the same program, use a 'for' loop to print each element of the Array List to the screen.f) Create a class named ArrayListManager. Into this class, code a method which prints to the screenevery element of an Array List of strings placed at an odd index. Hint: use a modulus.
arrow_forward
#include <stdio.h>#include <stdlib.h>#include <string.h>
typedef struct LINKED_STACK_NODE_s *LINKED_STACK_NODE;
typedef struct LINKED_STACK_NODE_s{LINKED_STACK_NODE next;void *data;} LINKED_STACK_NODE_t[1];
typedef struct LINKED_STACK_s{LINKED_STACK_NODE head;int count;} LINKED_STACK_t[1], *LINKED_STACK;
typedef struct{int R;int C;} POS_t[1], *POS;
LINKED_STACK stack_init();void stack_free(LINKED_STACK stack);void stack_push(LINKED_STACK stack, void *data);void *stack_pop(LINKED_STACK stack);void *stack_top(LINKED_STACK stack);int is_empty(LINKED_STACK stack);
int is_empty(LINKED_STACK stack){return stack->head == NULL;}
LINKED_STACK stack_init(){LINKED_STACK stack = (LINKED_STACK)malloc(sizeof(LINKED_STACK_t));if (stack == NULL){printf("\nproblem with initializing stack\n\n");return NULL;}stack->head = NULL;stack->count = 0;return stack;}
void stack_free(LINKED_STACK stack){while (is_empty(stack) == 0){stack_pop(stack);}free(stack);}void…
arrow_forward
#include <stdio.h>#include <stdlib.h>#include <string.h>
typedef struct LINKED_STACK_NODE_s *LINKED_STACK_NODE;
typedef struct LINKED_STACK_NODE_s{LINKED_STACK_NODE next;void *data;} LINKED_STACK_NODE_t[1];
typedef struct LINKED_STACK_s{LINKED_STACK_NODE head;int count;} LINKED_STACK_t[1], *LINKED_STACK;
typedef struct{int R;int C;} POS_t[1], *POS;
LINKED_STACK stack_init();void stack_free(LINKED_STACK stack);void stack_push(LINKED_STACK stack, void *data);void *stack_pop(LINKED_STACK stack);void *stack_top(LINKED_STACK stack);int is_empty(LINKED_STACK stack);
int is_empty(LINKED_STACK stack){return stack->head == NULL;}
LINKED_STACK stack_init(){LINKED_STACK stack = (LINKED_STACK)malloc(sizeof(LINKED_STACK_t));if (stack == NULL){printf("\nproblem with initializing stack\n\n");return NULL;}stack->head = NULL;stack->count = 0;return stack;}
void stack_free(LINKED_STACK stack){while (is_empty(stack) == 0){stack_pop(stack);}free(stack);}void…
arrow_forward
Duplicate Count
Code in C Language
arrow_forward
Task4:
Array Based List using Pointers Task
Let's say you have a sorted array:
int array_list[6] = [2,4,5,6,7,8]
You are given a target value. You need to find two numbers whose addition is equal to target
value.
Example:
array_list = 2,4,5,6,7,8
target = 15
Output = 7, 8
NOTE: You have to use pointers only.
arrow_forward
Create two function using java for separate tasks:
>Delete the middle element of a stack
> Create a separate function that takes an arraylist of integers and put all the odds before the evens int he order they occur
arrow_forward
is a data structure that makes it easy to rearrange data without having to move data in memory:a. arrayb. stack arrayc. linked listd. queue array
arrow_forward
C++
arrow_forward
Python
arrow_forward
In the stack below, what will be the value of "TOP" pointer after the operations - POP(), POP().
7008
7007
7006
7005 N
TOP=7005
7004 E
7003 D
7002 P
7001|A
arrow_forward
Search and Rescue
Code in C language
arrow_forward
3. Create a Memory structure owns number of block, block size, and stack attributes. You can add more attributes if it eases your implemen- tations.
Stack attribute represents memory blocks. Number of block attribute rep- resents the length of the stack. Block size represents the maximum value that each element in the stack can get.
4. Write an allocate function that takes a size parameter. If the given size is bigger than block size of the Memory, the allocation will be distributed to the different blocks in the stack attribute.
For example, calling allocate(27) updates the stack as allocate(27) = [10, 10, 7, 0, 0]
for a Memory with number of block = 5, block size = 10. The remaining of the elements which don’t have maximum value can be sealed until the element is flushed. Therefore, the next allocation can start from next element position after 7 given above.
5. Write an deallocate function that flushes the last used block.
arrow_forward
P1: this is data structure of algorithms subject and topic is all about Stack Applications
arrow_forward
3. Complete the program Student Records that simulates a student records system. The
program reads a list of student ids, names, and GPAS from a file exam.txt, and stores the
information in parallel array lists ids, names, and gpas.
Sample input (exam.txt):
132 Woody 4.1
465 Buzz 3.1
443 Rex 2.8
124 Hamm 3.3
337 Jessie 4.2
Your program will display a GPA report.
You must include a method named reportByGPA (...) that accepts the required array lists
and minimum GPA and displays the list of students that meet the criteria.
Sample output:
Enter the minimum GPA:
4.0
Students with GPA of 4.0 or higher
132 Woody, GPA: 4.1
337 Jessie, GPA: 4.2
end of program
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class Student Records {
public static void main(String[] args) throws
FileNotFoundException (
Scanner f = new Scanner (new File ("exam.txt"));
Scanner kb = new Scanner (System.in);
ArrayList ids = new ArrayList ();…
arrow_forward
Programming language: Java
Topic: linked list
arrow_forward
c++ language
using addition, not get_sum function
with this pseudocode:
Function Main
Declare Integer Array ages [ ]
Declare integer total
assign numbers = [ ]
assign total = sum(ages)
output "Sum: " & total
end
fucntion sum(Integer Array array)
declare integer total
declare integer index
assign total = 0
for index = 0 to size(array) -1
assign total = total + array[ ]
end
return integer total
arrow_forward
CODE (EMU8086)
#START = THERMOMETER.EXE##START = LED_DISPLAY.EXE#.STACK 100H .MODEL SMALL
.DATA
MSG1 DB 10,13,' WELCOME ', DB 10,13,' CHOOSE TYPE OF FOOD ', DB 10,13,'1.) PIZZA 2.) BAKED MACARONI 3.) FRENCH FRIES', DB 10,13,'ENTER: $' MSG2 DB 10,13,'PLEASE SELECT WHAT WILL BE THE MAX TEMPERATURE', DB 10,13,'1.) 20 DEG', DB 10,13,'2.) 40 DEG', DB 10,13,'3.) 60 DEG', DB 10,13,'4.) 80 DEG', DB 10,13,'5.) 100 DEG', DB 10,13,'6.) 119 DEG', DB 10,13,'ENTER: $'
NUM1 DB 20 NUM2 DB 40NUM3 DB 60NUM4 DB 80NUM5 DB 100NUM6 DB 119
TIMEOP1 DB 10,13,'SET THE TIMER', DB 10,13,'ENTER 1: 00:00:50', DB 10,13,'ENTER 2: 00:01:40', DB 10,13,'ENTER 3: 00:02:30', DB 10,13,'ENTER 4: 00:03:20', DB 10,13,'ENTER 5: 00:04:10', DB 10,13,'ENTER: $'
A DB 0B DB 0C DB 0D DB 0
OPTIONERROR DB 10,13,'INVALID OPTION $'
DONE DB 'DONE','$'
RESTARTMENU1 DB 10,13,'PRESS 1 TO GO BACK TO…
arrow_forward
CODE(EMU8086)
#START = THERMOMETER.EXE##START = LED_DISPLAY.EXE#.STACK 100H .MODEL SMALL
.DATA
MSG1 DB 10,13,' WELCOME ', DB 10,13,' CHOOSE TYPE OF FOOD ', DB 10,13,'1.) PIZZA 2.) BAKED MACARONI 3.) FRENCH FRIES', DB 10,13,'ENTER: $' MSG2 DB 10,13,'PLEASE SELECT WHAT WILL BE THE MAX TEMPERATURE', DB 10,13,'1.) 20 DEG', DB 10,13,'2.) 40 DEG', DB 10,13,'3.) 60 DEG', DB 10,13,'4.) 80 DEG', DB 10,13,'5.) 100 DEG', DB 10,13,'6.) 119 DEG', DB 10,13,'ENTER: $'
NUM1 DB 20 NUM2 DB 40NUM3 DB 60NUM4 DB 80NUM5 DB 100NUM6 DB 119
TIMEOP1 DB 10,13,'SET THE TIMER', DB 10,13,'ENTER 1: 00:00:50', DB 10,13,'ENTER 2: 00:01:40', DB 10,13,'ENTER 3: 00:02:30', DB 10,13,'ENTER 4: 00:03:20', DB 10,13,'ENTER 5: 00:04:10', DB 10,13,'ENTER: $'
A DB 0B DB 0C DB 0D DB 0
OPTIONERROR DB 10,13,'INVALID OPTION $'
DONE DB 'DONE','$'
RESTARTMENU1 DB 10,13,'PRESS 1 TO GO BACK TO MAIN…
arrow_forward
MIPS assembly language program
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.
arrow_forward
C Program Pointer Arithmetic
Write a program that asks the user a length of an integer array as input. Ask for elements and assign them using a pointer ptr.
Print the array between "[ ]" and separate by a comma.
Input
1. One line containing an integer for the length of the array
2. The elements
Sample
1
2
3
4
5
Output
Enter length: 5
Enter element 1: 1
Enter element 2: 2
Enter element 3: 3
Enter element 4: 4
Enter element 5: 5
[1,2,3,4,5]
arrow_forward
1. Class
represents a dynamically resizable array-like data structure.
a. Stack
b. LinkedList
с. АrrayList
d. Array
2. A(n)
is a data structure with a fixed size and can be direct access its
elements.
a. Vector
b. ArrayList
c. LinkedList
d. Array
3. A(n)
is a data structure in which objects are inserted into and removed
from the same end.
a. LinkedList
b. ArrayList
c. Stack
d. Queue
4. A(n)
is a data structure in which objects are inserted into the end and
removed from the front.
a. LinkedList
b. ArrayList
c. Stack
d. Queue
arrow_forward
C Program / C Language
Make a C program of the array .
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Related Questions
- If this is needed to be programmed, please use c++ language thanks!arrow_forwardActivity no. 23 Description: This activity is to implement Stack in an array. Required Materials: 1. Computer set or Laptop Required Time: Procedure: Create a program that will do the following: 1. Push to stack numbers in an array. 2. Pop the last number you push to stack. Required Output: 1. Source Code 2. Program Output 3. Draw the flow of data you created.arrow_forwardSKELETON CODE IS PROVIDED ALONG WITH C AND H FILES. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include "node.h" #include "stack_functions.h" #define NUM_VERTICES 10 /** This function takes a pointer to the adjacency matrix of a Graph and the size of this matrix as arguments and prints the matrix */ void print_graph(int * graph, int size); /** This function takes a pointer to the adjacency matrix of a Graph, the size of this matrix, the source and dest node numbers along with the weight or cost of the edge and fills the adjacency matrix accordingly. */ void add_edge(int * graph, int size, int src, int dst, int cost); /** This function takes a pointer to the adjacency matrix of a graph, the size of this matrix, source and destination vertex numbers as inputs and prints out the path from the source vertex to the destination vertex. It also prints the total cost of this…arrow_forward
- Subject-Object oriented programing Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screen In the same program, remove the element at the last index of the Array List. Print the resulting list tothe screen.arrow_forwardDouble pointers: Describe how this operation can be done in O(1) time if there are pointers in each node to both the previous and the next node.arrow_forwardAn array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number. The following is an array of unsorted numbers called NumArr. NumArr: 24 56 78 79 34 75 2 23arrow_forward
- P3: this is data structure of algorithms subject and topic is all about Stack Applicationsarrow_forwardgiven code lab4 #include <stdio.h>#include <stdlib.h> /* typical C boolean set-up */#define TRUE 1#define FALSE 0 typedef struct StackStruct{int* darr; /* pointer to dynamic array */int size; /* amount of space allocated */int inUse; /* top of stack indicator - counts how many values are on the stack */} Stack; void init (Stack* s){s->size = 2;s->darr = (int*) malloc ( sizeof (int) * s->size );s->inUse = 0;} void push (Stack* s, int val){/* QUESTION 7 *//* check if enough space currently on stack and grow if needed */ /* add val onto stack */s->darr[s->inUse] = val;s->inUse = s->inUse + 1;} int isEmpty (Stack* s){if ( s->inUse == 0)return TRUE;elsereturn FALSE;} int top (Stack* s){return ( s->darr[s->inUse-1] );} /* QUESTION 9.1 */void pop (Stack* s){if (isEmpty(s) == FALSE)s->inUse = s->inUse - 1;} void reset (Stack* s){/* Question 10: how to make the stack empty? */ } int main (int argc, char** argv){Stack st1; init (&st1);…arrow_forwardSubject-Object oriented programing Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screenb) In the same program, insert an element in the above ArrayList at index 2. The resulting Array Listmust be one element larger. Print the resulting list to the screen.c) In the same program, replace the element in the ArrayList at index 2 by null. Print the resulting list tothe screen.d) In the same program, remove the element at the last index of the Array List. Print the resulting list tothe screen.e) In the same program, use a 'for' loop to print each element of the Array List to the screen.f) Create a class named ArrayListManager. Into this class, code a method which prints to the screenevery element of an Array List of strings placed at an odd index. Hint: use a modulus.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning