MUST BE WRITTEN IN MIPS ASSEMBLY LANGUAGE Write an assembly

MUST BE WRITTEN IN MIPS ASSEMBLY LANGUAGE

Write an assembly program that reads a line of input from the user and counts the total number of characters, and the number of spaces (ASCII character 32). Prompt the user for the line of input and label the outputs. It can be safely assumed that the line of input from the user will contain at most 255 characters. Note that the system call that reads the string includes the newline character in the returned string. That should be included as one of the characters to count.

**OUTPUT SHOULD BE**

Enter a String: This is a test of my program.

Number of characters: 30

Number of spaces: 6

Solution

.file 1 \"\" .section .mdebug.abi32 .previous .gnu_attribute 4, 1 .abicalls .rdata .align 2 $LC0: .ascii \"Enter a string: \\000\" .align 2 $LC1: .ascii \"%d spaces\\012\\000\" .align 2 $LC2: .ascii \"\\012Digits: %d \\012Alphabets: %d \\012Spaces: %d \\012Spec\" .ascii \"ial Characters: %d\\000\" .text .align 2 .globl main $LFB0 = . .set nomips16 .ent main .type main, @function main: .frame $fp,168,$31 # vars= 128, regs= 2/0, args= 24, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-168 $LCFI0: sw $31,164($sp) $LCFI1: sw $fp,160($sp) movz $31,$31,$0 $LCFI2: move $fp,$sp $LCFI3: .cprestore 24 sw $0,36($fp) lw $2,36($fp) nop sw $2,40($fp) lw $2,40($fp) nop sw $2,44($fp) lw $2,44($fp) nop sw $2,48($fp) lw $2,%got($LC0)($28) nop addiu $4,$2,%lo($LC0) lw $2,%call16(printf)($28) nop move $25,$2 jalr $25 nop lw $28,24($fp) addiu $2,$fp,60 move $4,$2 lw $2,%call16(gets)($28) nop move $25,$2 jalr $25 nop lw $28,24($fp) addiu $2,$fp,60 sw $2,56($fp) sw $0,52($fp) b $L2 nop $L5: lb $3,60($fp) li $2,32 # 0x20 bne $3,$2,$L15 nop $L3: lw $2,52($fp) nop addiu $2,$2,1 sw $2,52($fp) b $L4 nop $L15: nop $L4: lw $2,56($fp) nop addiu $2,$2,1 sw $2,56($fp) $L2: lw $2,56($fp) nop lb $2,0($2) nop sltu $2,$0,$2 andi $2,$2,0x00ff bne $2,$0,$L5 nop lw $2,%got($LC1)($28) nop addiu $4,$2,%lo($LC1) lw $5,52($fp) lw $2,%call16(printf)($28) nop move $25,$2 jalr $25 nop lw $28,24($fp) sw $0,32($fp) b $L6 nop $L13: lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,48 bne $2,$0,$L7 nop lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,58 beq $2,$0,$L7 nop lw $2,48($fp) nop addiu $2,$2,1 sw $2,48($fp) b $L8 nop $L7: lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,65 bne $2,$0,$L9 nop lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,91 bne $2,$0,$L10 nop $L9: lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,97 bne $2,$0,$L11 nop lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop slt $2,$2,123 beq $2,$0,$L11 nop $L10: lw $2,44($fp) nop addiu $2,$2,1 sw $2,44($fp) b $L8 nop $L11: lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $3,28($2) li $2,32 # 0x20 bne $3,$2,$L12 nop lw $2,36($fp) nop addiu $2,$2,1 sw $2,36($fp) b $L8 nop $L12: lw $2,40($fp) nop addiu $2,$2,1 sw $2,40($fp) $L8: lw $2,32($fp) nop addiu $2,$2,1 sw $2,32($fp) $L6: lw $2,32($fp) addiu $3,$fp,32 addu $2,$3,$2 lb $2,28($2) nop sltu $2,$0,$2 andi $2,$2,0x00ff bne $2,$0,$L13 nop lw $2,40($fp) nop sw $2,16($sp) lw $2,%got($LC2)($28) nop addiu $4,$2,%lo($LC2) lw $5,48($fp) lw $6,44($fp) lw $7,36($fp) lw $2,%call16(printf)($28) nop move $25,$2 jalr $25 nop lw $28,24($fp) move $2,$0 move $sp,$fp lw $31,164($sp) lw $fp,160($sp) addiu $sp,$sp,168 j $31 nop .set macro .set reorder .end main $LFE0: .size main, .-main .section .eh_frame,\"aw\",@progbits $Lframe1: .4byte $LECIE1-$LSCIE1 $LSCIE1: .4byte 0x0 .byte 0x1 .globl __gxx_personality_v0 .ascii \"zP\\000\" .uleb128 0x1 .sleb128 -4 .byte 0x1f .uleb128 0x5 .byte 0x0 .4byte __gxx_personality_v0 .byte 0xc .uleb128 0x1d .uleb128 0x0 .align 2 $LECIE1: $LSFDE1: .4byte $LEFDE1-$LASFDE1 $LASFDE1: .4byte $LASFDE1-$Lframe1 .4byte $LFB0 .4byte $LFE0-$LFB0 .uleb128 0x0 .byte 0x4 .4byte $LCFI0-$LFB0 .byte 0xe .uleb128 0xa8 .byte 0x4 .4byte $LCFI2-$LCFI0 .byte 0x11 .uleb128 0x1e .sleb128 2 .byte 0x11 .uleb128 0x1f .sleb128 1 .byte 0x4 .4byte $LCFI3-$LCFI2 .byte 0xd .uleb128 0x1e .align 2 $LEFDE1:
MUST BE WRITTEN IN MIPS ASSEMBLY LANGUAGE Write an assembly program that reads a line of input from the user and counts the total number of characters, and the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site