Question: CODE: /*Enumerated Type creates set of constants numbered 0 and upward*/ /* *p1 = rdi, *p2 = rsi, modetype = rdx */ typedef enum {ACASE,
CODE:
/*Enumerated Type creates set of constants numbered 0 and upward*/
/* *p1 = rdi, *p2 = rsi, modetype = rdx */
typedef enum {ACASE, BCASE, CCASE, DCASE, ECASE} modetype;
long switch4 (long *p1, long *p2, modetype action) {
long result =0; switch (action){
case ACASE:
case BCASE:
case CCASE:
case DCASE:
case ECASE:
default:
}
return result;
}
Assembly code:
switch4: .LFB0: .cfi_startproc movl $2, %eax cmpl $4, %edx ja .L2 movl %edx, %edx jmp *.L8(,%rdx,8) .section .rodata .align 8 .align 4 .L8: .quad .L3 .quad .L4 .quad .L5 .quad .L6 .quad .L7 .text .L7: movl $24, %eax ret .L3: movq (%rdi), %rax subq (%rsi), %rax movq %rax, (%rsi) ret .L4: movq $31, (%rdi) movq (%rsi), %rax ret .L5: movq (%rdi), %rax movq %rax, %rdx addq (%rsi), %rdx movq %rdx, (%rdi) ret .L6: movq (%rsi), %rax movq %rax, (%rdi) movl $24, %eax .L2: rep ret .cfi_endproc .LFE0: .size switch4, .-switch4 .ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3" .section .note.GNU-stack,"",@progbits
Use the assembly code to fill out the code for each cases above
if possible, please explain how you used assembly code to write out the cases
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
