This is using the assembly language MIPS and the MARS simulator. Help! Write a p
ID: 3665551 • Letter: T
Question
This is using the assembly language MIPS and the MARS simulator. Help!
Write a program that will ask you to enter an integer n (1<=n<=12) using a prompt "Enter the value of n here: " As you enter the integer n throught the keyboard, the program will print the nth month of the year in the following format: The month is: <the nth month will appear here>
Thus, if you enter n=5, the output will be The month is: May
If you enter a value of n outside the range, or a non integer, then it should output "?".
I some of this problem but the it is really confusing me this my second week learning assembly
Explanation / Answer
.Ltext0:
.section .rodata
.LC0:
0000 256400 .string "%d"
.LC1:
0003 54686973 .string "This is january"
20697320
6A616E75
61727900
.LC2:
0013 54686973 .string "This is february"
20697320
66656272
75617279
00
.LC3:
0024 54686973 .string "This is march"
20697320
6D617263
6800
.LC4:
0032 54686973 .string "This is April"
20697320
41707269
6C00
.LC5:
0040 54686973 .string "This is May"
20697320
4D617900
.LC6:
004c 54686973 .string "This is june"
20697320
6A756E65
00
.LC7:
0059 54686973 .string "This is july"
20697320
6A756C79
00
.LC8:
0066 54686973 .string "This is August"
20697320
41756775
737400
.LC9:
0075 54686973 .string "This is September"
20697320
53657074
656D6265
7200
.LC10:
0087 54686973 .string "This is October"
20697320
4F63746F
62657200
.LC11:
0097 54686973 .string "This is November"
20697320
4E6F7665
6D626572
00
.LC12:
00a8 54686973 .string "This is December"
20697320
44656365
6D626572
00
.LC13:
00b9 3F3F00 .string "??"
.text
.globl main
main:
.LFB0:
.cfi_startproc
0000 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
0001 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
0004 4883EC10 subq $16, %rsp
0008 488D45FC leaq -4(%rbp), %rax
000c 4889C6 movq %rax, %rsi
000f BF000000 movl $.LC0, %edi
00
0014 B8000000 movl $0, %eax
00
0019 E8000000 call __isoc99_scanf
00
001e 8B45FC movl -4(%rbp), %eax
0021 83F801 cmpl $1, %eax
0024 7514 jne .L2
0026 BF000000 movl $.LC1, %edi
00
002b B8000000 movl $0, %eax
00
0030 E8000000 call printf
00
0035 E9340100 jmp .L3
00
.L2:
003a 8B45FC movl -4(%rbp), %eax
003d 83F802 cmpl $2, %eax
0040 7514 jne .L4
0042 BF000000 movl $.LC2, %edi
00
0047 B8000000 movl $0, %eax
00
004c E8000000 call printf
00
0051 E9180100 jmp .L3
00
.L4:
0056 8B45FC movl -4(%rbp), %eax
0059 83F803 cmpl $3, %eax
005c 7514 jne .L5
005e BF000000 movl $.LC3, %edi
00
0063 B8000000 movl $0, %eax
00
0068 E8000000 call printf
00
006d E9FC0000 jmp .L3
00
.L5:
0072 8B45FC movl -4(%rbp), %eax
0075 83F804 cmpl $4, %eax
0078 7514 jne .L6
007a BF000000 movl $.LC4, %edi
00
007f B8000000 movl $0, %eax
00
0084 E8000000 call printf
00
0089 E9E00000 jmp .L3
00
.L6:
008e 8B45FC movl -4(%rbp), %eax
0091 83F805 cmpl $5, %eax
0094 7514 jne .L7
0096 BF000000 movl $.LC5, %edi
00
009b B8000000 movl $0, %eax
00
00a0 E8000000 call printf
00
00a5 E9C40000 jmp .L3
00
.L7:
00aa 8B45FC movl -4(%rbp), %eax
00ad 83F806 cmpl $6, %eax
00b0 7514 jne .L8
00b2 BF000000 movl $.LC6, %edi
00
00b7 B8000000 movl $0, %eax
00
00bc E8000000 call printf
00
00c1 E9A80000 jmp .L3
00
.L8:
00c6 8B45FC movl -4(%rbp), %eax
00c9 83F807 cmpl $7, %eax
00cc 7514 jne .L9
00ce BF000000 movl $.LC7, %edi
00
00d3 B8000000 movl $0, %eax
00
00d8 E8000000 call printf
00
00dd E98C0000 jmp .L3
00
.L9:
00e2 8B45FC movl -4(%rbp), %eax
00e5 83F808 cmpl $8, %eax
00e8 7511 jne .L10
00ea BF000000 movl $.LC8, %edi
00
00ef B8000000 movl $0, %eax
00
00f4 E8000000 call printf
00
00f9 EB73 jmp .L3
.L10:
00fb 8B45FC movl -4(%rbp), %eax
00fe 83F809 cmpl $9, %eax
0101 7511 jne .L11
0103 BF000000 movl $.LC9, %edi
00
0108 B8000000 movl $0, %eax
00
010d E8000000 call printf
00
0112 EB5A jmp .L3
.L11:
0114 8B45FC movl -4(%rbp), %eax
0117 83F80A cmpl $10, %eax
011a 7511 jne .L12
011c BF000000 movl $.LC10, %edi
00
0121 B8000000 movl $0, %eax
00
0126 E8000000 call printf
00
012b EB41 jmp .L3
.L12:
012d 8B45FC movl -4(%rbp), %eax
0130 83F80B cmpl $11, %eax
0133 7511 jne .L13
0135 BF000000 movl $.LC11, %edi
00
013a B8000000 movl $0, %eax
00
013f E8000000 call printf
00
0144 EB28 jmp .L3
.L13:
0146 8B45FC movl -4(%rbp), %eax
0149 83F80C cmpl $12, %eax
014c 7511 jne .L14
014e BF000000 movl $.LC12, %edi
00
0153 B8000000 movl $0, %eax
00
0158 E8000000 call printf
00
015d EB0F jmp .L3
.L14:
015f BF000000 movl $.LC13, %edi
00
0164 B8000000 movl $0, %eax
00
0169 E8000000 call printf
00
.L3:
016e B8000000 movl $0, %eax
00
0173 C9 leave
.cfi_def_cfa 7, 8
0174 C3 ret
.cfi_endproc
.LFE0:
.Letext0:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.