Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need the answer for this lab work Learning Outcemes: Students will understand how processor processes a program and how the execution affects the processor's

i need the answer for this lab work
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Learning Outcemes: Students will understand how processor processes a program and how the execution affects the processor's registers, memory and 1/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 your need to use your student Linux ascount or your CentOS virtual machine (one per group). In the latter case please read the Techniques/resources section at the bottom to get intormation how to make it work on your group Linux VM. To create the ASM source file or the do_asm seript in Linux you may need to install nano program (yum - y install nano) and then create the program (nano t.asm), save it (Ctrl' x ). Additionally, to make the de_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. putty program (through Host Access from Windows Start Menu). a. Create a file called program_name. asm (for example 1.asm ) using pico (or, if pico is not installed, use nano or vin editor instead) with the following content Lab_2-COMP1562 mov eax, 4 mov ebx, 1 mov eex, hello mov edx, helloLen int 80h mov eax, 1 Please mind that the filename MUS Rh 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_asan your_program_filename (e.g. If your asm source file name was first.asm, you noed to do: . /do_asm first 1 g. Run the program by typing: -/your_program_Eilename 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 asscmbly program try to: breakpoint - display registers values after everyt nexti instruction backtrace of - instruction o stack - watch program counter values (ElR register) - watch flag register values (EFLAGS htegister) qu it - discuss/ comment on relevant results / screenshots 2. Assembly / debugging Evercise 2. Repeat exactly the same steps as in Exercise.1 for the following assembly program. The program name can be for example 2 . asm main: mov axr [NUMBER1] adid ax, 3. Assembly / debuggiag Exercise 3. Based on Exercise 1 \& 2 try to make changes to the code [NUMBER1] add ax, 3. Assembly / debugging Exercise 3. Based on Exercise 1 \& 2 try to make changes to the code so that it would divde NUMBER2 by NUMBERI instead of adding the two numbers together (ygu may need to use the documentation for nasm-sed hablec. Run the program in the debugger and check if the difsion operation result is correct. The modified program and screenshots documenting its operation should be included into your upload document. TASKS 2.1. Based on the example prograns 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 b=7, - 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 r3, you would define the following variables: r; 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 ; the last instruction should be moving ; palculation 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 traperoid 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 awarded full asarks for the code part unless you implenent the equation appropriately using the appropriate range of assembly instructions (mul, div, add, etc.). 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 ealculate 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 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 awarded full marks for the code part unless you implement the equation appropriately using the appropriate range of assembly. instructions (mul, div, add, efc, ). 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. Quile detailod decription of NissM. Techniques/resources: Solution of all the above tasks will require using Linas 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). Learning Outcemes: Students will understand how processor processes a program and how the execution affects the processor's registers, memory and 1/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 your need to use your student Linux ascount or your CentOS virtual machine (one per group). In the latter case please read the Techniques/resources section at the bottom to get intormation how to make it work on your group Linux VM. To create the ASM source file or the do_asm seript in Linux you may need to install nano program (yum - y install nano) and then create the program (nano t.asm), save it (Ctrl' x ). Additionally, to make the de_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. putty program (through Host Access from Windows Start Menu). a. Create a file called program_name. asm (for example 1.asm ) using pico (or, if pico is not installed, use nano or vin editor instead) with the following content Lab_2-COMP1562 mov eax, 4 mov ebx, 1 mov eex, hello mov edx, helloLen int 80h mov eax, 1 Please mind that the filename MUS Rh 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_asan your_program_filename (e.g. If your asm source file name was first.asm, you noed to do: . /do_asm first 1 g. Run the program by typing: -/your_program_Eilename 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 asscmbly program try to: breakpoint - display registers values after everyt nexti instruction backtrace of - instruction o stack - watch program counter values (ElR register) - watch flag register values (EFLAGS htegister) qu it - discuss/ comment on relevant results / screenshots 2. Assembly / debugging Evercise 2. Repeat exactly the same steps as in Exercise.1 for the following assembly program. The program name can be for example 2 . asm main: mov axr [NUMBER1] adid ax, 3. Assembly / debuggiag Exercise 3. Based on Exercise 1 \& 2 try to make changes to the code [NUMBER1] add ax, 3. Assembly / debugging Exercise 3. Based on Exercise 1 \& 2 try to make changes to the code so that it would divde NUMBER2 by NUMBERI instead of adding the two numbers together (ygu may need to use the documentation for nasm-sed hablec. Run the program in the debugger and check if the difsion operation result is correct. The modified program and screenshots documenting its operation should be included into your upload document. TASKS 2.1. Based on the example prograns 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 b=7, - 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 r3, you would define the following variables: r; 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 ; the last instruction should be moving ; palculation 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 traperoid 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 awarded full asarks for the code part unless you implenent the equation appropriately using the appropriate range of assembly instructions (mul, div, add, etc.). 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 ealculate 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 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 awarded full marks for the code part unless you implement the equation appropriately using the appropriate range of assembly. instructions (mul, div, add, efc, ). 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. Quile detailod decription of NissM. Techniques/resources: Solution of all the above tasks will require using Linas 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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions