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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!