SlideShare a Scribd company logo
1 of 12
Download to read offline
Write a program in MIPS that reads in a Roman form number from the user, then output the
number in decimal form.
Write a program in MIPS that reads in a Roman form number from the user, then output the
number in decimal form.
Solution
Answer:
MIPS Assembly Language Program:
.zero 1
RomanNumber::RomanNumber(std::__cxx11::basic_string, std::allocator >):
push rbp
mov rbp, rsp
push rbx
sub rsp, 24
mov QWORD PTR [rbp-24], rdi
mov QWORD PTR [rbp-32], rsi
mov rax, QWORD PTR [rbp-24]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::basic_string()
mov rax, QWORD PTR [rbp-24]
mov rdx, QWORD PTR [rbp-32]
mov rsi, rdx
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::operator=(std::__cxx11::basic_string,
std::allocator > const&)
jmp .L4
mov rbx, rax
mov rax, QWORD PTR [rbp-24]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
mov rax, rbx
mov rdi, rax
call _Unwind_Resume
.L4:
add rsp, 24
pop rbx
pop rbp
ret
.LC0:
.string " is not a Roman Numeral!"
RomanNumber::convert():
push rbp
mov rbp, rsp
sub rsp, 32
mov QWORD PTR [rbp-24], rdi
mov rax, QWORD PTR [rbp-24]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::length() const
mov DWORD PTR [rbp-16], eax
mov DWORD PTR [rbp-4], 0
mov BYTE PTR [rbp-5], 0
mov DWORD PTR [rbp-12], 0
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], 0
.L24:
cmp BYTE PTR [rbp-5], 0
jne .L6
mov eax, DWORD PTR [rbp-12]
cmp eax, DWORD PTR [rbp-16]
jge .L6
mov eax, DWORD PTR [rbp-12]
movsx rdx, eax
mov rax, QWORD PTR [rbp-24]
mov rsi, rdx
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::operator[](unsigned long)
movzx eax, BYTE PTR [rax]
movsx eax, al
sub eax, 67
cmp eax, 21
ja .L7
mov eax, eax
mov rax, QWORD PTR .L9[0+rax*8]
jmp rax
.L9:
.quad .L8
.quad .L10
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L11
.quad .L7
.quad .L7
.quad .L12
.quad .L13
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L7
.quad .L14
.quad .L7
.quad .L15
.L13:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+1000]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 999
jg .L16
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L16:
mov DWORD PTR [rbp-4], 1000
jmp .L17
.L10:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+500]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 499
jg .L18
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L18:
mov DWORD PTR [rbp-4], 500
jmp .L17
.L8:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+100]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 99
jg .L19
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L19:
mov DWORD PTR [rbp-4], 100
jmp .L17
.L12:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+50]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 49
jg .L20
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L20:
mov DWORD PTR [rbp-4], 50
jmp .L17
.L15:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+10]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 9
jg .L21
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L21:
mov DWORD PTR [rbp-4], 10
jmp .L17
.L14:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+5]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 4
jg .L22
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L22:
mov DWORD PTR [rbp-4], 5
jmp .L17
.L11:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
lea edx, [rax+1]
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
cmp DWORD PTR [rbp-4], 0
jg .L23
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
mov edx, DWORD PTR [rbp-4]
add edx, edx
sub eax, edx
mov edx, eax
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], edx
.L23:
mov DWORD PTR [rbp-4], 1
jmp .L17
.L7:
mov eax, DWORD PTR [rbp-12]
movsx rdx, eax
mov rax, QWORD PTR [rbp-24]
mov rsi, rdx
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::operator[](unsigned long)
movzx eax, BYTE PTR [rax]
movsx eax, al
mov esi, eax
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char)
mov esi, OFFSET FLAT:.LC0
mov rdi, rax
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&)
mov rdi, rax
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
mov BYTE PTR [rbp-5], 1
mov rax, QWORD PTR [rbp-24]
mov DWORD PTR [rax+32], 0
.L17:
add DWORD PTR [rbp-12], 1
jmp .L24
.L6:
mov rax, QWORD PTR [rbp-24]
mov eax, DWORD PTR [rax+32]
leave
ret
RomanNumber::~RomanNumber():
push rbp
mov rbp, rsp
sub rsp, 16
mov QWORD PTR [rbp-8], rdi
mov rax, QWORD PTR [rbp-8]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
nop
leave
ret
.LC1:
.string "color 1F"
.LC2:
.string "  tt....ROMAN NUMBER TO DECIMAL CONVERTER....  "
.LC3:
.string "  tEnter your input in Roman Number(Plz Keep Caps Lock On): "
.LC4:
.string "  ttRoman Number "
.LC5:
.string " is equals to Decimal "
.LC6:
.string "pause"
main:
push rbp
mov rbp, rsp
push rbx
sub rsp, 136
mov edi, OFFSET FLAT:.LC1
call system
lea rax, [rbp-96]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::basic_string()
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov esi, OFFSET FLAT:.LC3
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
lea rax, [rbp-96]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream >& std::operator>>, std::allocator >(std::basic_istream >&,
std::__cxx11::basic_string, std::allocator >&)
lea rdx, [rbp-96]
lea rax, [rbp-64]
mov rsi, rdx
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string,
std::allocator > const&)
lea rdx, [rbp-64]
lea rax, [rbp-144]
mov rsi, rdx
mov rdi, rax
call RomanNumber::RomanNumber(std::__cxx11::basic_string, std::allocator >)
lea rax, [rbp-64]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
lea rax, [rbp-144]
mov rdi, rax
call RomanNumber::convert()
mov DWORD PTR [rbp-20], eax
mov esi, OFFSET FLAT:.LC4
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov rdx, rax
lea rax, [rbp-96]
mov rsi, rax
mov rdi, rdx
call std::basic_ostream >& std::operator<< , std::allocator >(std::basic_ostream >&,
std::__cxx11::basic_string, std::allocator > const&)
mov esi, OFFSET FLAT:.LC5
mov rdi, rax
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-20]
mov esi, eax
mov rdi, rdx
call std::basic_ostream >::operator<<(int)
mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&)
mov rdi, rax
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&)
mov rdi, rax
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
mov edi, OFFSET FLAT:.LC6
call system
mov ebx, 0
lea rax, [rbp-144]
mov rdi, rax
call RomanNumber::~RomanNumber()
lea rax, [rbp-96]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
mov eax, ebx
jmp .L35
mov rbx, rax
lea rax, [rbp-64]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
jmp .L30
mov rbx, rax
lea rax, [rbp-144]
mov rdi, rax
call RomanNumber::~RomanNumber()
jmp .L30
mov rbx, rax
.L30:
lea rax, [rbp-96]
mov rdi, rax
call std::__cxx11::basic_string, std::allocator >::~basic_string()
mov rax, rbx
mov rdi, rax
call _Unwind_Resume
.L35:
add rsp, 136
pop rbx
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L38
cmp DWORD PTR [rbp-8], 65535
jne .L38
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L38:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret

More Related Content

Similar to Write a program in MIPS that reads in a Roman form number from th.pdf

Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdf
rushabhshah600
 
Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N  .LC1 .st.pdfAnswer1).LC0 .string Enter the value of N  .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
annaiwatertreatment
 
Fix assembly Code new peoblem on call printf gt .pdf
Fix assembly Code new peoblem on call printf gt  .pdfFix assembly Code new peoblem on call printf gt  .pdf
Fix assembly Code new peoblem on call printf gt .pdf
rchopra4
 
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdfConvert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
arpitcomputronics
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!
mickey24
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
Romain Francois
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
FFRI, Inc.
 

Similar to Write a program in MIPS that reads in a Roman form number from th.pdf (20)

Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja Editorial
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
R/C++ talk at earl 2014
R/C++ talk at earl 2014R/C++ talk at earl 2014
R/C++ talk at earl 2014
 
Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdf
 
Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
 
Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N  .LC1 .st.pdfAnswer1).LC0 .string Enter the value of N  .LC1 .st.pdf
Answer1).LC0 .string Enter the value of N .LC1 .st.pdf
 
Fix assembly Code new peoblem on call printf gt .pdf
Fix assembly Code new peoblem on call printf gt  .pdfFix assembly Code new peoblem on call printf gt  .pdf
Fix assembly Code new peoblem on call printf gt .pdf
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdfConvert the for loop Into MIPS Instructions. Use the sit instruction .pdf
Convert the for loop Into MIPS Instructions. Use the sit instruction .pdf
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
PBL1-v1-004j.pptx
PBL1-v1-004j.pptxPBL1-v1-004j.pptx
PBL1-v1-004j.pptx
 
HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
R and C++
R and C++R and C++
R and C++
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 

More from santanadenisesarin13

Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdfThomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
santanadenisesarin13
 
Q1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdfQ1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdf
santanadenisesarin13
 
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdfQuestion 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
santanadenisesarin13
 
please help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdfplease help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdf
santanadenisesarin13
 
Need help writing Conways Game of Life. These are the instructions.pdf
Need help writing Conways Game of Life. These are the instructions.pdfNeed help writing Conways Game of Life. These are the instructions.pdf
Need help writing Conways Game of Life. These are the instructions.pdf
santanadenisesarin13
 
JAVA Write a class called F.pdf
JAVA  Write a class called F.pdfJAVA  Write a class called F.pdf
JAVA Write a class called F.pdf
santanadenisesarin13
 
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdfI need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
santanadenisesarin13
 

More from santanadenisesarin13 (20)

What does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdfWhat does it mean by mRNA coded for by the Operon What does it.pdf
What does it mean by mRNA coded for by the Operon What does it.pdf
 
Variability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdfVariability of a sample can he measured use the following statistic(s.pdf
Variability of a sample can he measured use the following statistic(s.pdf
 
What are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdfWhat are the advantages of using a compiled language over an interpr.pdf
What are the advantages of using a compiled language over an interpr.pdf
 
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
Unbiased estimators  Let theta be an estimator of a parameter theta..pdfUnbiased estimators  Let theta be an estimator of a parameter theta..pdf
Unbiased estimators Let theta be an estimator of a parameter theta..pdf
 
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdfThomas Lewis said “the capacity to blunder slightly is the real marv.pdf
Thomas Lewis said “the capacity to blunder slightly is the real marv.pdf
 
The strongest attractive forces between molecules of H_2O are ionic.pdf
The strongest attractive forces between molecules of H_2O are  ionic.pdfThe strongest attractive forces between molecules of H_2O are  ionic.pdf
The strongest attractive forces between molecules of H_2O are ionic.pdf
 
Q1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdfQ1. An individual who accepts the risks and opportunities entailed b.pdf
Q1. An individual who accepts the risks and opportunities entailed b.pdf
 
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdfQuestion 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
Question 3 (24 markS) Westcock Shipbuilding Ltd. has a December 31 y.pdf
 
Place the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdfPlace the following formulas in their proper order A. ALE, residu.pdf
Place the following formulas in their proper order A. ALE, residu.pdf
 
please help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdfplease help i have 40 minsItem 1In the case below, the original .pdf
please help i have 40 minsItem 1In the case below, the original .pdf
 
Need help writing Conways Game of Life. These are the instructions.pdf
Need help writing Conways Game of Life. These are the instructions.pdfNeed help writing Conways Game of Life. These are the instructions.pdf
Need help writing Conways Game of Life. These are the instructions.pdf
 
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdfNon-Euclidean GeometryWhat statement, if any, can be made about th.pdf
Non-Euclidean GeometryWhat statement, if any, can be made about th.pdf
 
Java ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdfJava ProgrammingA Swing button can have more than one action liste.pdf
Java ProgrammingA Swing button can have more than one action liste.pdf
 
JAVA Write a class called F.pdf
JAVA  Write a class called F.pdfJAVA  Write a class called F.pdf
JAVA Write a class called F.pdf
 
In the adult, red bone marrow would normally be found in the sternu.pdf
In the adult, red bone marrow would normally be found in the  sternu.pdfIn the adult, red bone marrow would normally be found in the  sternu.pdf
In the adult, red bone marrow would normally be found in the sternu.pdf
 
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdfI need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
I need help with these two questions 4.12 and 4.13 dealing with MATL.pdf
 
I dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdfI dont understand the min and max Find the smallest positive value.pdf
I dont understand the min and max Find the smallest positive value.pdf
 
How can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdfHow can the activation of effector molecules within cells be restric.pdf
How can the activation of effector molecules within cells be restric.pdf
 
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdfExplain how the skin of reptiles adaptive for terrestial existence. .pdf
Explain how the skin of reptiles adaptive for terrestial existence. .pdf
 
Distinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdfDistinguish the roles of the four economic actors in economicsSo.pdf
Distinguish the roles of the four economic actors in economicsSo.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 

Write a program in MIPS that reads in a Roman form number from th.pdf

  • 1. Write a program in MIPS that reads in a Roman form number from the user, then output the number in decimal form. Write a program in MIPS that reads in a Roman form number from the user, then output the number in decimal form. Solution Answer: MIPS Assembly Language Program: .zero 1 RomanNumber::RomanNumber(std::__cxx11::basic_string, std::allocator >): push rbp mov rbp, rsp push rbx sub rsp, 24 mov QWORD PTR [rbp-24], rdi mov QWORD PTR [rbp-32], rsi mov rax, QWORD PTR [rbp-24] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::basic_string() mov rax, QWORD PTR [rbp-24] mov rdx, QWORD PTR [rbp-32] mov rsi, rdx mov rdi, rax call std::__cxx11::basic_string, std::allocator >::operator=(std::__cxx11::basic_string, std::allocator > const&) jmp .L4 mov rbx, rax mov rax, QWORD PTR [rbp-24] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() mov rax, rbx mov rdi, rax call _Unwind_Resume
  • 2. .L4: add rsp, 24 pop rbx pop rbp ret .LC0: .string " is not a Roman Numeral!" RomanNumber::convert(): push rbp mov rbp, rsp sub rsp, 32 mov QWORD PTR [rbp-24], rdi mov rax, QWORD PTR [rbp-24] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::length() const mov DWORD PTR [rbp-16], eax mov DWORD PTR [rbp-4], 0 mov BYTE PTR [rbp-5], 0 mov DWORD PTR [rbp-12], 0 mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], 0 .L24: cmp BYTE PTR [rbp-5], 0 jne .L6 mov eax, DWORD PTR [rbp-12] cmp eax, DWORD PTR [rbp-16] jge .L6 mov eax, DWORD PTR [rbp-12] movsx rdx, eax mov rax, QWORD PTR [rbp-24] mov rsi, rdx mov rdi, rax call std::__cxx11::basic_string, std::allocator >::operator[](unsigned long) movzx eax, BYTE PTR [rax] movsx eax, al sub eax, 67
  • 3. cmp eax, 21 ja .L7 mov eax, eax mov rax, QWORD PTR .L9[0+rax*8] jmp rax .L9: .quad .L8 .quad .L10 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L11 .quad .L7 .quad .L7 .quad .L12 .quad .L13 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L7 .quad .L14 .quad .L7 .quad .L15 .L13: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+1000] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 999 jg .L16
  • 4. mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L16: mov DWORD PTR [rbp-4], 1000 jmp .L17 .L10: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+500] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 499 jg .L18 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L18: mov DWORD PTR [rbp-4], 500 jmp .L17 .L8: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+100] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx
  • 5. cmp DWORD PTR [rbp-4], 99 jg .L19 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L19: mov DWORD PTR [rbp-4], 100 jmp .L17 .L12: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+50] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 49 jg .L20 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L20: mov DWORD PTR [rbp-4], 50 jmp .L17 .L15: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+10]
  • 6. mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 9 jg .L21 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L21: mov DWORD PTR [rbp-4], 10 jmp .L17 .L14: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] lea edx, [rax+5] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 4 jg .L22 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L22: mov DWORD PTR [rbp-4], 5 jmp .L17 .L11: mov rax, QWORD PTR [rbp-24]
  • 7. mov eax, DWORD PTR [rax+32] lea edx, [rax+1] mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx cmp DWORD PTR [rbp-4], 0 jg .L23 mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] mov edx, DWORD PTR [rbp-4] add edx, edx sub eax, edx mov edx, eax mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], edx .L23: mov DWORD PTR [rbp-4], 1 jmp .L17 .L7: mov eax, DWORD PTR [rbp-12] movsx rdx, eax mov rax, QWORD PTR [rbp-24] mov rsi, rdx mov rdi, rax call std::__cxx11::basic_string, std::allocator >::operator[](unsigned long) movzx eax, BYTE PTR [rax] movsx eax, al mov esi, eax mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char) mov esi, OFFSET FLAT:.LC0 mov rdi, rax call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&) mov rdi, rax call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) mov BYTE PTR [rbp-5], 1
  • 8. mov rax, QWORD PTR [rbp-24] mov DWORD PTR [rax+32], 0 .L17: add DWORD PTR [rbp-12], 1 jmp .L24 .L6: mov rax, QWORD PTR [rbp-24] mov eax, DWORD PTR [rax+32] leave ret RomanNumber::~RomanNumber(): push rbp mov rbp, rsp sub rsp, 16 mov QWORD PTR [rbp-8], rdi mov rax, QWORD PTR [rbp-8] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() nop leave ret .LC1: .string "color 1F" .LC2: .string " tt....ROMAN NUMBER TO DECIMAL CONVERTER.... " .LC3: .string " tEnter your input in Roman Number(Plz Keep Caps Lock On): " .LC4: .string " ttRoman Number " .LC5: .string " is equals to Decimal " .LC6: .string "pause" main: push rbp mov rbp, rsp
  • 9. push rbx sub rsp, 136 mov edi, OFFSET FLAT:.LC1 call system lea rax, [rbp-96] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::basic_string() mov esi, OFFSET FLAT:.LC2 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov esi, OFFSET FLAT:.LC3 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) lea rax, [rbp-96] mov rsi, rax mov edi, OFFSET FLAT:std::cin call std::basic_istream >& std::operator>>, std::allocator >(std::basic_istream >&, std::__cxx11::basic_string, std::allocator >&) lea rdx, [rbp-96] lea rax, [rbp-64] mov rsi, rdx mov rdi, rax call std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator > const&) lea rdx, [rbp-64] lea rax, [rbp-144] mov rsi, rdx mov rdi, rax call RomanNumber::RomanNumber(std::__cxx11::basic_string, std::allocator >) lea rax, [rbp-64] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() lea rax, [rbp-144] mov rdi, rax call RomanNumber::convert() mov DWORD PTR [rbp-20], eax
  • 10. mov esi, OFFSET FLAT:.LC4 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov rdx, rax lea rax, [rbp-96] mov rsi, rax mov rdi, rdx call std::basic_ostream >& std::operator<< , std::allocator >(std::basic_ostream >&, std::__cxx11::basic_string, std::allocator > const&) mov esi, OFFSET FLAT:.LC5 mov rdi, rax call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov rdx, rax mov eax, DWORD PTR [rbp-20] mov esi, eax mov rdi, rdx call std::basic_ostream >::operator<<(int) mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&) mov rdi, rax call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) mov esi, OFFSET FLAT:std::basic_ostream >& std::endl >(std::basic_ostream >&) mov rdi, rax call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) mov edi, OFFSET FLAT:.LC6 call system mov ebx, 0 lea rax, [rbp-144] mov rdi, rax call RomanNumber::~RomanNumber() lea rax, [rbp-96] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() mov eax, ebx jmp .L35 mov rbx, rax lea rax, [rbp-64]
  • 11. mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() jmp .L30 mov rbx, rax lea rax, [rbp-144] mov rdi, rax call RomanNumber::~RomanNumber() jmp .L30 mov rbx, rax .L30: lea rax, [rbp-96] mov rdi, rax call std::__cxx11::basic_string, std::allocator >::~basic_string() mov rax, rbx mov rdi, rax call _Unwind_Resume .L35: add rsp, 136 pop rbx pop rbp ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L38 cmp DWORD PTR [rbp-8], 65535 jne .L38 mov edi, OFFSET FLAT:std::__ioinit call std::ios_base::Init::Init() mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:std::__ioinit mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
  • 12. call __cxa_atexit .L38: nop leave ret push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp ret