I need an answer for this lab work
Description: This exercise is mainly focused on tracing the execution of a real program. Students are supposed to do all the tasks specified in the section Tasks. All results (preferably in the form of screenshots) documenting your activity should be included into your final report. Learning Outcomes: Students will understand how processor processes a program and how the execution affects the processor's registers, memory and I/O devices. Student will also learn how to assemble and execute assembly programs in the Linux operating system. EXERCISES In order to make this lab doable yout need to wse your student Linux account or your CentOS virtual machine (one per group). In the latter case please read the Techniques/resources section at the bottom to get information how to make it work on your group Linux VM. To create the ASM source file or the do_asm script in Linax you may need to insaall nano program (yum y install nano) and then create the program (nano t.assi), save it (Ctrx ). Additionally, to make the do_asm script runnable you need to change its permissions (chmod 755 do_asm) and then execute as /do_asm asm file name). 1. Assembly / debugging Exercise 1. Login to your student Linux server (stulinux.cms.greac.uk of student.ms.gre.ac.tak) using putty program (through Host Access from Windows Start Menu): a. Create a file called program_name. asm (for example 1.amm ) using pico (or, if pico is not installed, use nano or vim editor instead) with the following content Lab_2-COMP1562 main: mov eax,4 mov ebx, 1 mov eex, hello mov edx, hellolen int 80h mov eax, 1 Please mind that the filename Musfo have *asm extension. b. Save the file. c. Create a script file called for example do_asm using any editor and make the file content to be: d. Save the file. e. Change the do_asm script rights to make it executable: chmod 755 do_asm f. Run the script to build the program: ./do_asm your_program_filename le.g. If your asm source file name was first.asm, you need to do: ./do_asm first 1 g. Run the program by typing: ./your_program_fllename h. Run the GNU debugger to debug the program: gdb your_program_filename i. Type the following sequence of commands in the command line of gdb program (for what to pay attention at just read man gdb): For your assembly program try to: breakpoint - display registers values after everefl nexti instruction backtrace of - watch progeram counter values (lelphes - watch program counter values (ElRregister) - watch flag register values (EFLAGS tugistee) quit - discuss/ comment on relevant results / sereenshots 2. Assembly / debugging Exercise 2 . Repeat exactly the same steps as in Exercise.I for the following assembly proggram. The program name can be for example 2. asm. mains mov ax, [NUMBER1] 3. Assembly / debugging Exercise 3. Based on Exercise, 2 gry to make changes to the code so that it would divide NUMBER2 by NUMBER1 instead of adding the two numbers together (you may need to use the documentation for nasm - sic tabice. Run the program in the debugger and check if the dinision operation result is correct. The modified program and sereenshots documenting its operation should be included into your upload document. TASKS 2.1. Based on the example programs and the information you found on the Internet try to write part of the program that calculates area of trapezoid of the following parameters: - shorter side a =3, - longer side b7. - height h=4. You are not required to write the whole code. All you need to do is to show how you would declare all variables that you would need to calculate the area of trapezoid (a,b,h). for example, if your task were to calculate area of a square which side r=3, you would define the following variables: I: dw 1 result: dw 1 and also you will need to write only the instructions that will do the requested calculations. For example, if your task were to calculate the mentioned area of square of side r-5, your implementation might look like: mov word[r],5 mov ax, [r] mov bx, [r] mul bx mov word[result], ax instruction should be moving ;the past ;calculation result to the result variable. You'll be able to enter separately the variables declaration part and the code part into the scriptcheck.cms.greac,uk system (using appropriate text areas provided) and the system will check if your solution is correct. The marking script will check whether your code contains all instructions required to implement the trapezoid area equation. This means that even if your program returns Lab_2-COMP1562 mov word[r],5 mov ax, [r] mov bx, [r] mul bx mov word[result], ax instruction should be moving ; the last ; calculation result to the result variable. You'll be able to enter separately the variables declaration part and the code part into the scriptcheck.cms.gre-ac.uk system (using appropriate text areas provided) and the system will check if your solution is correct. The marking script will check whether your code contains all instructions required to implement the trapezoid area equation. This means that even if your program returns the correct result (in the numerical meaning), your code structure still matters and you will not be axarded full narks for the code part unless you implement the equation appropriately using the appropriate range of assembly. instructions (mal, div, add, etc.). Please mind that to accomplish the lab work you will NOT need actually to have access to nasm program as scriptcheck provides everything you'll need to compile your bits of assembly code. You can use available registers and the variables you will declare yourself. All the information you may need can be found at: 2 Quite detullal descipoin of XKSM: Techniques/resources: Solution of all the above tasks will require using Linus operating system which is available on the university Intranet. Marking: The solutions will be marked in the range 0100%. Deadline: The solutions should be uploaded into Moodle within two week from the lab date (by Sunday midnight). Description: This exercise is mainly focused on tracing the execution of a real program. Students are supposed to do all the tasks specified in the section Tasks. All results (preferably in the form of screenshots) documenting your activity should be included into your final report. Learning Outcomes: Students will understand how processor processes a program and how the execution affects the processor's registers, memory and I/O devices. Student will also learn how to assemble and execute assembly programs in the Linux operating system. EXERCISES In order to make this lab doable yout need to wse your student Linux account or your CentOS virtual machine (one per group). In the latter case please read the Techniques/resources section at the bottom to get information how to make it work on your group Linux VM. To create the ASM source file or the do_asm script in Linax you may need to insaall nano program (yum y install nano) and then create the program (nano t.assi), save it (Ctrx ). Additionally, to make the do_asm script runnable you need to change its permissions (chmod 755 do_asm) and then execute as /do_asm asm file name). 1. Assembly / debugging Exercise 1. Login to your student Linux server (stulinux.cms.greac.uk of student.ms.gre.ac.tak) using putty program (through Host Access from Windows Start Menu): a. Create a file called program_name. asm (for example 1.amm ) using pico (or, if pico is not installed, use nano or vim editor instead) with the following content Lab_2-COMP1562 main: mov eax,4 mov ebx, 1 mov eex, hello mov edx, hellolen int 80h mov eax, 1 Please mind that the filename Musfo have *asm extension. b. Save the file. c. Create a script file called for example do_asm using any editor and make the file content to be: d. Save the file. e. Change the do_asm script rights to make it executable: chmod 755 do_asm f. Run the script to build the program: ./do_asm your_program_filename le.g. If your asm source file name was first.asm, you need to do: ./do_asm first 1 g. Run the program by typing: ./your_program_fllename h. Run the GNU debugger to debug the program: gdb your_program_filename i. Type the following sequence of commands in the command line of gdb program (for what to pay attention at just read man gdb): For your assembly program try to: breakpoint - display registers values after everefl nexti instruction backtrace of - watch progeram counter values (lelphes - watch program counter values (ElRregister) - watch flag register values (EFLAGS tugistee) quit - discuss/ comment on relevant results / sereenshots 2. Assembly / debugging Exercise 2 . Repeat exactly the same steps as in Exercise.I for the following assembly proggram. The program name can be for example 2. asm. mains mov ax, [NUMBER1] 3. Assembly / debugging Exercise 3. Based on Exercise, 2 gry to make changes to the code so that it would divide NUMBER2 by NUMBER1 instead of adding the two numbers together (you may need to use the documentation for nasm - sic tabice. Run the program in the debugger and check if the dinision operation result is correct. The modified program and sereenshots documenting its operation should be included into your upload document. TASKS 2.1. Based on the example programs and the information you found on the Internet try to write part of the program that calculates area of trapezoid of the following parameters: - shorter side a =3, - longer side b7. - height h=4. You are not required to write the whole code. All you need to do is to show how you would declare all variables that you would need to calculate the area of trapezoid (a,b,h). for example, if your task were to calculate area of a square which side r=3, you would define the following variables: I: dw 1 result: dw 1 and also you will need to write only the instructions that will do the requested calculations. For example, if your task were to calculate the mentioned area of square of side r-5, your implementation might look like: mov word[r],5 mov ax, [r] mov bx, [r] mul bx mov word[result], ax instruction should be moving ;the past ;calculation result to the result variable. You'll be able to enter separately the variables declaration part and the code part into the scriptcheck.cms.greac,uk system (using appropriate text areas provided) and the system will check if your solution is correct. The marking script will check whether your code contains all instructions required to implement the trapezoid area equation. This means that even if your program returns Lab_2-COMP1562 mov word[r],5 mov ax, [r] mov bx, [r] mul bx mov word[result], ax instruction should be moving ; the last ; calculation result to the result variable. You'll be able to enter separately the variables declaration part and the code part into the scriptcheck.cms.gre-ac.uk system (using appropriate text areas provided) and the system will check if your solution is correct. The marking script will check whether your code contains all instructions required to implement the trapezoid area equation. This means that even if your program returns the correct result (in the numerical meaning), your code structure still matters and you will not be axarded full narks for the code part unless you implement the equation appropriately using the appropriate range of assembly. instructions (mal, div, add, etc.). Please mind that to accomplish the lab work you will NOT need actually to have access to nasm program as scriptcheck provides everything you'll need to compile your bits of assembly code. You can use available registers and the variables you will declare yourself. All the information you may need can be found at: 2 Quite detullal descipoin of XKSM: Techniques/resources: Solution of all the above tasks will require using Linus operating system which is available on the university Intranet. Marking: The solutions will be marked in the range 0100%. Deadline: The solutions should be uploaded into Moodle within two week from the lab date (by Sunday midnight)