Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C
Problem The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C are simply a way to introduce a set of names having associated integer values By default, the values assigned to the names go from zero upward. In our code, the actions associated with the different case labels have been omitted. Enunerated type creates sat of constants nusbered 0 and uprazd. typedef 2 enun {MOOLA, KODE-B, MODES, 190DE-D, MODE-E} node-t ; 4 long avitch3(long .pl, Long p2, modet action) long result- o switch (action) case HODE A 10 case MODE C 12 13 case MODED 15 16 default return result; The part of the generated assembly code implementing the different actions is shown in Figure 3.52. The annotations indicate the argument locations, the register values, and the case labels for the different jump destinations Fill in the missing parts of the C code. It contained one case that fell through to another - try to reconstruct this. pi in %rdi, p2 in %rsi, action in %edx 1.L8 MODE E $27, novl ret %eax L3 : movq movq movq ret (%rsi), %rax (%rdi), %rax %rdx, (Xrsi) L5: MODE B 10 11 12 novq addq movq ret (%rdi), %rax (%rsi), %rax %rax, (%rdi) L6 : 59, (%rsi), (%rdi) 15 16 novq novg ret %rax 18 "L7: 19 novq rsi), hrax NODE D movq nov! ret %rax ,(%rdi) $27,%eax L9 : default movl ret $12, %eax Problem The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C are simply a way to introduce a set of names having associated integer values By default, the values assigned to the names go from zero upward. In our code, the actions associated with the different case labels have been omitted. Enunerated type creates sat of constants nusbered 0 and uprazd. typedef 2 enun {MOOLA, KODE-B, MODES, 190DE-D, MODE-E} node-t ; 4 long avitch3(long .pl, Long p2, modet action) long result- o switch (action) case HODE A 10 case MODE C 12 13 case MODED 15 16 default return result; The part of the generated assembly code implementing the different actions is shown in Figure 3.52. The annotations indicate the argument locations, the register values, and the case labels for the different jump destinations Fill in the missing parts of the C code. It contained one case that fell through to another - try to reconstruct this. pi in %rdi, p2 in %rsi, action in %edx 1.L8 MODE E $27, novl ret %eax L3 : movq movq movq ret (%rsi), %rax (%rdi), %rax %rdx, (Xrsi) L5: MODE B 10 11 12 novq addq movq ret (%rdi), %rax (%rsi), %rax %rax, (%rdi) L6 : 59, (%rsi), (%rdi) 15 16 novq novg ret %rax 18 "L7: 19 novq rsi), hrax NODE D movq nov! ret %rax ,(%rdi) $27,%eax L9 : default movl ret $12, %eax
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