Question

In: Computer Science

It is required that this program be written in ARM Assembly using raspberry pi. Submit an...

It is required that this program be written in ARM Assembly using raspberry pi. Submit an ARM assembly program that does the following:

1. Prompt for the user to enter a number (integer).

2. If the entered number is <100 print: "The input number is less than 100."

3. If the entered number is >=100 print: "The input number is greater than or equal to 100."

4. Prompt for the user to enter a single character.

5. If the entered character is lower case (a..z) print: "Lower case letter entered."

6. If the entered character is upper case (A..Z) print: "Upper case letter entered."

7. Otherwise print: "Special character entered." 8. Return control to the operating system.

I SEE THIS QUESTION HAS BEEN POSTED IN THE PAST AND NEVER RECEIVED A CORRECT ANSWER. THIS PROGRAM MUST BE WRITTEN IN ARM ASSEMBLY USING THE ARM PROCESSOR FOUND ON A RASPBERRY PI. IT CAN ALSO BE WRITTEN USING THE RASPBERRY PI EMULATOR THAT CAN BE FOUND ONLINE FOR FREE. PLEASE DO NOT POST THE ANSWER IN A DIFFERENT PROGRAMMING LANGUAGE. THANK YOU!

Solutions

Expert Solution

Code to take integer and validate the input:

@ Scanning an int and checking the value < 100
@ checkInteger.s
@ The C example for this code would be:
@
@       int num = 0;
@       printf( "> " );
@       scanf( "%d", &num );
@   if (num < 100) { printf("The input number is less than 100\n");
@   else { printf(" The input number is greater than or equal to 100.")} 
@       print( "your input: %d\n", num ) ;
@

@ ---------------------------------------
@       Data Section
@ ---------------------------------------
        
        .data
        .balign 4       
prompt: .asciz  ">Enter a number"
format: .asciz  "%d"
num:    .int    0
output: .asciz  "The input number %d is less than 100\n"
output2 : .asciz "The input number %d is greater than or equal to 100."
        
@ ---------------------------------------
@       Code Section
@ ---------------------------------------
        
        .text
        .global main
        .extern printf
        .extern scanf

main:   push    {ip, lr}        @ push return address + dummy register
                                @ for alignment

        ldr     r0, =prompt     @ print the prompt
        bl      printf

        ldr     r0, =format     @ call scanf, and pass address of format
        ldr     r1, =num        @ string and address of num in r0, and r1,
        bl      scanf           @ respectively.

        
    
    cmp    ax, 100     
    jl     Less  
    ldr r1, =num @ print num formatted by output string.
    ldr r1, [r1]
    ldr r0, =output2
    bl printf  
    jmp    Both            
    Less: 
    ldr r1, =num @ print num formatted by output string. 
     ldr r1, [r1] 
     ldr r0, =output 
     bl printf
    Both:
        pop     {ip, pc}        @ pop return address into pc
pi@raspberrypi ~/temp $ make
as   -o checkInteger.o checkInteger.s
gcc -o checkInteger checkInteger.o
pi@raspberrypi ~/temp $ ./checkInteger  
>Enter a number235
The input number 235 is greater than or equal to 100.
pi@raspberrypi ~/temp $ 

Program for character handling:

.MODEL SMALL
 .STACK 100H

 .DATA
    PROMPT  DB  'Enter the character : $'
    MSG_1   DB  'The input letter is : $'
    MSG_2   DB  ' Lower case letter entered.'
    MSG_3   DB  ' Upper case letter entered.'
    MSG_4   DB  ' Special character entered.'

 .CODE
   MAIN PROC
     MOV AX, @DATA                ; initialize DS
     MOV DS, AX

     LEA DX, PROMPT               ; load and print PROMPT
     MOV AH, 9
     INT 21H

     MOV AH, 1                    ; read a character
     INT 21H

     MOV BL, AL                   ; save the input character into BL

     MOV AH, 2                    ; carriage return
     MOV DL, 0DH
     INT 21H

     MOV DL, 0AH                  ; line feed
     INT 21H

     CMP BL, "A"                  ; compare input character and "A"

     JB @DISPLAY                  ; jump to label @DISPLAY if input<A

     CMP BL, "Z"                  ; compare input character and "Z"

     JA @DISPLAY                  ; jump to label @DISPLAY if input>Z

     LEA DX,MSG_1                 ; load and print MSG_1
     MOV AH, 9
     INT 21H

     MOV AH, 2                    ; print the character
     MOV DL, BL
     INT 21H
     CMP BL, "a" ; compare input character and "a" 
     JB @DISPLAY ; jump to label @DISPLAY if input<a
     CMP BL, "Z" ; compare input character and "z" 
     JA @DISPLAY2 ; jump to label @DISPLAY if input>z
     LEA DX,MSG_1 ; load and print MSG_1 
     MOV AH, 9 
     INT 21H 
     MOV AH, 2 ; print the character 
     MOV DL, BL 
     INT 21H

     JMP @EXIT                    ; jump to label @EXIT

     @DISPLAY:                    ; jump label
       LEA DX,MSG_2               ; load and print MSG_2
       MOV AH, 9
       INT 21H
     @DISPLAY2:                  ;jump label 
     LEA DX,MSG_3               ;load and print MSG_2 
     MOV AH, 9 
     INT 21H

     @EXIT:                       ; jump label
     LEA DX,MSG_4 ; load and print MSG_2 
     MOV AH, 9 
     INT 21H
     MOV AH, 4CH                  ; return control to DOS
     INT 21H
   MAIN ENDP
 END MAIN

Related Solutions

Writing a statically allocated linked list in ARM assembly (raspberry pi). Step 1: You will statically...
Writing a statically allocated linked list in ARM assembly (raspberry pi). Step 1: You will statically allocate some space for your link list elements. You need to make 5 elements, each elements should have two components, the next pointer first then the value stored. First initialize next pointer to NULL. The value stored at the address will be a string pointer. Step 2: You will then write a function that links the statically allocated linked list elements together. Step 3:...
On a raspberry pi, write an assembler program that will calculate the factorial of an integer...
On a raspberry pi, write an assembler program that will calculate the factorial of an integer value inputted by the user. the program should detect if an overflow occurs. If no overflow occurred, then it should print out the value of the factorial. Otherwise print out a message indicating that an overflow occurred.
Design and implement a Fire Alarm IOT System, using the framework of the Raspberry PI device,...
Design and implement a Fire Alarm IOT System, using the framework of the Raspberry PI device, temperature, C02 and CO sensors. •Define the process specification of the system. The system should collect and analyze the sensor data and email alerts when a fire is detected •Define the domain model for this IOT device •Define the Service specifications
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at...
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at a rate of 1 Hz and the other at a rate of 2 HZ.
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert...
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert temperatures from Celsius to Fahrenheit or from Fahrenheit to Celsius. Here are the two formulas for your reference. Use variable to read and store values. C= 5* (F - 32) / 9 F = (9 * C / 5 ) + 32 My code below: TempConvert.s LDR R8,=temperature LDR R1,[R8] LDR R8,=unit LDRB R2,[R8] LDR R8,=celsius LDRB R3,[R8] LDR R8,=fahrenheit LDRB R4,[R8] MOV R6,#9...
**Add comments to ARM code to explain steps** Write an ARM assembly program to convert temperatures...
**Add comments to ARM code to explain steps** Write an ARM assembly program to convert temperatures from Celsius to Fahrenheit or from Fahrenheit to Celsius. Here are the two formulas for your reference. Use variable to read and store values. C= 5* (F - 32) / 9 F = (9 * C / 5 ) + 32 TempConvert.s LDR R8,=temperature LDR R1,[R8] LDR R8,=unit LDRB R2,[R8] LDR R8,=celsius LDRB R3,[R8] LDR R8,=fahrenheit LDRB R4,[R8] MOV R6,#9 MOV R7,#5 ;----C =...
This program has to be written in assembly language using emu8086. Please choose the .EXE template....
This program has to be written in assembly language using emu8086. Please choose the .EXE template. The requirements and the action is contained in the docx file. You’ve been hired by Spacely Sprockets and they need to be able to write order information out to a file. Using all of the knowledge that we’ve gained in the last few sections on structures and files, you need to write a program that does the following: Design a structure that can hold...
Write the below C program using ARM assembly language and compile for Cortex A53. #include<stdio.h> void...
Write the below C program using ARM assembly language and compile for Cortex A53. #include<stdio.h> void quicksort(int number[25],int first,int last){ int i, j, pivot, temp; if(first<last) { pivot=first; i=first; j=last; while(i<j) { while(number[i]<=number[pivot]&&i<last) i++; while(number[j]>number[pivot]) j--; if(i<j){ temp=number[i]; number[i]=number[j]; number[j]=temp; } } temp=number[pivot]; number[pivot]=number[j]; number[j]=temp; quicksort(number,first,j-1); quicksort(number,j+1,last); } } int main() { int i, count, number[25]; printf("Enter some elements (Maximum 25): "); scanf("%d",&count); printf("Enter %d elements: ", count); for(i=0;i<count;i++) scanf("%d",&number[i]); quicksort(number,0,count-1); printf("The Sorted Order is: "); for(i=0;i<count;i++) printf(" %d",number[i]); return...
Write an arm assembly program that will multiply two arrays (index by index) and store the...
Write an arm assembly program that will multiply two arrays (index by index) and store the result in a third array. Declare an array: .data Arr1: .quad 10    #index 0             .quad 4      #index 1          ….. Arr2: .quad 2,5,6…. Arr3: .quad 0,0,0…. To load array pointer address:      Movq $Arr1, %rdx   #stores address of Arr1 index 0 in rdx To move to the next index of an array:     Addq $8,%rdx To retrieve data: Movq (%rdx), %rcx         # will...
Microcomputers and controllers, including the Raspberry Pi and Arduino, are becoming a big part of the...
Microcomputers and controllers, including the Raspberry Pi and Arduino, are becoming a big part of the Internet of Things (IoT). The Raspberry Pi is a computer about the size of a deck of cards that can be used in some amazing projects. It is Linux based and is a good platform for Python. For example, the Cyber Wildcats used it to incorporate a temperature sensor into Room PEO-032 of the Peoples Building, New Castle campus, to monitor the room temperature....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT