Question
C code: int getNumOfDaysInMonth(int mon, int year) { if (mon == 2) if ( (year % 400 == 0) || ((year % 4 == 0)
C code:
int getNumOfDaysInMonth(int mon, int year) {
if (mon == 2) if ( (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) return 29; else return 28;
else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) return 30;
else if (mon == 1 || mon==3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12) return 31; return 0; }
x86 assembly
.global getNumOfDaysInMonth
.data #TODO: Put strings here
.text
getNumOfDaysInMonth: push %rbx # TODO: complete pop %rbx ret
Registers:
%rip Instruction pointer
%rsp Stack pointer
%rax Return value
%rdi 1st argument
%rsi 2nd argument
%rdx 3rd argument
%rcx 4th argument
%r8 5th argument
%r9 6th argument
%r10,%r11 Callee-owned
%rbx,%rbp,
%r12-%15 Caller-owned
Please follow the guidelines thoroughly and convert the C code into a x86 assembly language by following the #TODO. Please focus on the TODO and use the provided method, register and implementation. Please do not give me the .S file which is derived directly from the command line.Need help. Thanks,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started