{"id":78885,"date":"2021-12-02T06:32:57","date_gmt":"2021-12-02T06:32:57","guid":{"rendered":"https:\/\/papersspot.com\/blog\/2021\/12\/02\/cs130-computer-architecture-project-9-pj-9-dr-lin-version-9-24-21-cs225\/"},"modified":"2021-12-02T06:32:57","modified_gmt":"2021-12-02T06:32:57","slug":"cs130-computer-architecture-project-9-pj-9-dr-lin-version-9-24-21-cs225","status":"publish","type":"post","link":"https:\/\/papersspot.com\/blog\/2021\/12\/02\/cs130-computer-architecture-project-9-pj-9-dr-lin-version-9-24-21-cs225\/","title":{"rendered":"CS130: Computer Architecture Project 9 (PJ 9) Dr. Lin Version 9\/24\/21 CS225"},"content":{"rendered":"<p>CS130: Computer Architecture Project 9 (PJ 9) Dr. Lin Version 9\/24\/21<\/p>\n<p> CS225 Fundamentals of Computer Science Course Syllabus Fall 2013<\/p>\n<p> Dr. Simon Lin Version: 09\/02\/2013<\/p>\n<p> PJ 9 \u2013 Array Game of Numbers <\/p>\n<p> Please follow the instructions to complete this project assignment. <\/p>\n<p> (1) Go to Internet: http:\/\/www.jblearning.com\/catalog\/9781284036121\/ <\/p>\n<p> (2) Click Sample Materials in the middle of the panel.<\/p>\n<p> (3) Click Visual Studio 2015 Files to download VS_2015_Introduction_files.zip into your Downloads folder.<\/p>\n<p> (4) Create a new folder Visual Studio Detmer in your USB drive.<\/p>\n<p> (5) Click to open VS_2015_Introduction_files.zip (in your Downloads folder) to see all the contents. Copy all those folders and files (under the zip folder) into your USB drive folder: Visual Studio Detmer.<\/p>\n<p> (6) Open your Visual Studio 2019. In Visual Studio, click File Open Project\/Solution, and open your USB drive folder: Visual Studio Detmer. Double-click its sub-folder Windows32, and click windows32.sln, and click Open button. Now, you are running this windows32 application.<\/p>\n<p> (7) Double-click the file example.asm (in Solution Explorer) to show its contents on the center panel.<\/p>\n<p> (8) Right-click the file example.asm, and rename it to PJ9.asm.<\/p>\n<p> (9) Modify PJ9.asm program as follows: <\/p>\n<p> [a] The top 3 lines must be block comments to show Author, Date, and Purpose. <\/p>\n<p> [b] Remove those blank lines from this program so that the complete program can be displayed on the<\/p>\n<p> center panel. It may have only 32 lines or less now. <\/p>\n<p> [c] This windows32 application will allow only one procedure with the name _MainProc. To run this <\/p>\n<p> program, you need to use the name _MainProc for PROC, and use different PROC names for any <\/p>\n<p> other assembly programs in this windows32 application. Please note that you may create many<\/p>\n<p> assembly programs here (for testing), but only one of them with PROC being _MainProc can run.<\/p>\n<p> Another way to solve this problem is to modify framework.c program so that this driver program<\/p>\n<p> will call your proc (such as MainProcPJ9, instead of MainProc) directly. <\/p>\n<p> Another way to solve this problem is to modify framework.c program so that this driver program<\/p>\n<p> will call your proc (such as PJ9, instead of MainProc) directly. <\/p>\n<p> (10) Write your PJ9.asm program as follows: <\/p>\n<p> [a] create or declare an array of 6 double-word integers with or without initial values; <\/p>\n<p> [b] prepare a loop to get 6 integers from the user, and store those 6 integers into the array accordingly;<\/p>\n<p> [c] get and show those 6 integers (entered by the user) by using 6 message boxes;<\/p>\n<p> [d] compute the average of those 6 integers, and show the average to the user using a message box; <\/p>\n<p> [e] show the user each number that is smaller than the average using a message box. You must not add 10 to each number that is smaller than the average.<\/p>\n<p> Note: The original example.asm program shows you how to prompt input from the user and how to display the result to the user using message boxes. <\/p>\n<p> (11) Fully test this program to make sure it runs successfully with no errors.<\/p>\n<p> (12) Copy and paste your complete PJ9.asm program into section (A) below. <\/p>\n<p> (13) Build Rebuild Windows32 application. Click Local Windows Debugger to run this program. <\/p>\n<p> (14) Make a screen print (by Ctrl+Alt+PrintScrn) and paste (Ctrl+V) it onto section (B) below. <\/p>\n<p> (15) Make a screen print for each number [being displayed to the user] onto section (C) below. <\/p>\n<p> ==========================================================================.<\/p>\n<p> Please reference the following 3 sample assembly code for this assignment. <\/p>\n<p> Sample assembly code(1) to process an array using indexed addressing: (reference page 159-161)<\/p>\n<p> ; Given an array of doubleword integers, (1) find the average of those integers, and <\/p>\n<p> ; (2) add 10 to each number that is smaller than the average [using indexed addressing]. <\/p>\n<p> ; But, you should not do this adding of 10 for this project assignment.<\/p>\n<p> .586 ; 32-bits instructions<\/p>\n<p> .MODEL FLAT ; Flat memory model for execution <\/p>\n<p> .STACK 4096 ; Allocate 4K bytes STACK<\/p>\n<p> .DATA ; Data declaration follows:<\/p>\n<p> nbrArray DWORD 0, 1, 2, 3, 4, 5, 6 DUP (?) ; \/\/ Total 12 (= 6+6) integers in array.<\/p>\n<p> ; \/\/ First 6 numbers (0,1,2,3,4,5) followed by 6 uninitialized numbers. Total: 12 elements.<\/p>\n<p> nbrElts DWORD 6 ; \/\/ 6 is the number of elements to be processed<\/p>\n<p> .CODE<\/p>\n<p> _MainProc PROC<\/p>\n<p> ; find sum and average<\/p>\n<p> mov eax,0 ; sum := 0<\/p>\n<p> mov ecx,0 ; index := 0 ; must start with 0, not 1<\/p>\n<p> for1: cmp ecx,nbrElts ; index &lt; nbrElts<\/p>\n<p> jnl endFor1 ; exit loop if not less than<\/p>\n<p> add eax,nbrArray[4*ecx] ; add number to sum in EAX ; times 4 since 4 bytes per number<\/p>\n<p> inc ecx ; increment index ecx by 1<\/p>\n<p> jmp for1 ; repeat for1 loop<\/p>\n<p> endFor1:<\/p>\n<p> cdq ; extend sum to quadword<\/p>\n<p> idiv nbrElts ; divide by nbrElts to calculate average of those numbers<\/p>\n<p> ; add 10 to each array element below average<\/p>\n<p> mov ecx,0 ; index := 0 to start with element 0<\/p>\n<p> for2: cmp ecx,nbrElts ; index &lt; nbrElts<\/p>\n<p> jnl endFor2 ; exit if not<\/p>\n<p> cmp nbrArray[4*ecx],eax ; number &lt; average ?<\/p>\n<p> jnl endIfSmall ; continue if not less<\/p>\n<p> add DWORD PTR nbrArray[4*ecx], 10 ; add 10 to number<\/p>\n<p> endIfSmall:<\/p>\n<p> inc ecx ; increment index<\/p>\n<p> jmp for2 ; repeat<\/p>\n<p> endFor2: <\/p>\n<p> quit: mov eax, 0 ; exit with return code 0<\/p>\n<p> ret<\/p>\n<p> _MainProc ENDP<\/p>\n<p> END<\/p>\n<p> ==========================================================================.<\/p>\n<p> Sample assembly code(2) to show that how this program should be written to avoid any damage to the sum value. EAX register cannot be used to store the sum since EAX is used for each atod conversion. Therefore, EDX register must be used to hold the sum. <\/p>\n<p> .DATA<\/p>\n<p> nbrArray DWORD 6 DUP (?) ; \/\/ Total 6 integers with no initial values<\/p>\n<p> nbrElts DWORD 6 ; 6 integers to prompt from user ; number of elements<\/p>\n<p> number1 DWORD ? ; number1 is double-word of 32 bits with no initial value<\/p>\n<p> prompt1 BYTE &#8220;Enter the next number&#8221;, 0 ; prompt1 is a string of 18 bytes<\/p>\n<p> string BYTE 40 DUP (?) ; string has 40 bytes with no initial value<\/p>\n<p> outLabel2 BYTE &#8220;The number &lt; average is&quot;, 0 ; a string of some bytes ended by 0. <\/p>\n<p> outLabel3 BYTE &#8220;The average is&#8221;, 0 ; a string of some bytes ended by 0. <\/p>\n<p> result BYTE 11 DUP (?), 0 ; a string of 11 bytes with no initial value<\/p>\n<p> .CODE<\/p>\n<p> _MainProc PROC<\/p>\n<p> ; find sum and average <\/p>\n<p> mov eax,0 ; used for atod conversion and idiv operation<\/p>\n<p> mov EDX,0 ; EDX to accumulate the sum, cannot use EAX <\/p>\n<p> mov ecx,0 ; index := 0 ; 32-bit count register<\/p>\n<p> for1: cmp ecx,nbrElts ; index &lt; nbrElts<\/p>\n<p> jnl endFor1 ; exit if not less <\/p>\n<p> input prompt1, string, 40 ; prompt a number and put it in string of 40 bytes<\/p>\n<p> atod string ; convert string to double-word integer, &amp; put it into EAX<\/p>\n<p> mov number1, EAX ; move EAX (containing a number) to number1 <\/p>\n<p> mov nbrArray[4*ecx], EAX ; move the number in EAX to the array at ecx postition<\/p>\n<p> ; times 4 because each integer takes 4 bytes in array <\/p>\n<p> add EDX ,nbrArray[4*ecx] ; add the number in array to the sum in EDX<\/p>\n<p> inc ecx ; increment index for next element<\/p>\n<p> jmp for1 ; repeat for1 loop<\/p>\n<p> endFor1: ; end of for1 loop<\/p>\n<p> ==========================================================================.<\/p>\n<p> Sample assembly code(3) to (a) compute the average, and (b) show each number that is less than the average. <\/p>\n<p> mov EAX, EDX ; move the sum in EDX to EAX <\/p>\n<p> cdq ; extend sum_EAX to quadword<\/p>\n<p> idiv nbrElts ; calculate average; divide EAX by nbrElts with quotient into EAX<\/p>\n<p> dtoa result, EAX ; convert EAX value to ASCII characters for display<\/p>\n<p> output outLabel3 , result ; output label and result which is the average<\/p>\n<p> ; show each element which is &lt; average that is in EAX<\/p>\n<p> mov ecx,0 ; index := 0 ; ecx is 32-bit count register.<\/p>\n<p> for2: cmp ecx,nbrElts ; index &lt; nbrElts<\/p>\n<p> jnl endFor2 ; exit if ecx &gt; nbrElts ; not less means &gt;<\/p>\n<p> cmp nbrArray[4*ecx],eax ; compare number &lt; average_in_eax ?<\/p>\n<p> jnl endIfSmall ; jump if number &gt;= average ; not less means &gt;=<\/p>\n<p> ; Now, the number is &lt; average, so output it <\/p>\n<p> dtoa result, nbrArray[4*ecx] ; convert this number to ASCII for output<\/p>\n<p> output outLabel2 , result ; output label and result<\/p>\n<p> endIfSmall:<\/p>\n<p> inc ecx ; increment index for next element<\/p>\n<p> jmp for2 ; repeat for2 loop<\/p>\n<p> endFor2: <\/p>\n<p> ==========================================================================.<\/p>\n<p> How to submit your PJ 9?<\/p>\n<p> You must copy\/paste (or Ctrl+Alt+PrintScrn\/paste) your programs\/screens to all the sections below.<\/p>\n<p> Submit this document (for example: CS130-PJ9.docx) through the Canvas system (https:\/\/ilearn.laccd.edu ). <\/p>\n<p> ==========================================================================.<\/p>\n<p> \/\/You must delete everything above &amp; including this line to make this your Word document to be submitted.<\/p>\n<p> CS130 PJ 9 Report My Name:____________________ <\/p>\n<p> (A) The following is my source program: PJ9.asm. You must copy\/paste your source code from your Visual Studio. As you may see, the font of the program in Visual Studio is Consolas, not Courier New or Times New Roman. You must not show screen prints here.<\/p>\n<p> (B) The following is the screen print of my Visual Studio Console after the program PJ9.asm has been run successfully with return code 0: (You must Ctrl+Alt+PrintScrn your Visual Studio Console, and then paste it to here.)<\/p>\n<p> (C) The following is the screen print of my output for each message box being displayed to the user. (You must Ctrl+Alt+PrintScrn your Visual Studio Console, and then paste it to here.) <\/p>\n<p> Sample Test for you to verify your program:<\/p>\n<p> Input 6 numbers: 1, 2, 3, 4, 5, 6<\/p>\n<p> Display average: 3<\/p>\n<p> Display all numbers below average: 1, 2<\/p>\n<p> [C1] Show to get the 1st number.<\/p>\n<p> [C2] Show to get the 2nd number.<\/p>\n<p> [C3] Show to get the 3rd number.<\/p>\n<p> [C4] Show to get the 4th number.<\/p>\n<p> [C5] Show to get the 5th number.<\/p>\n<p> [C6] Show to get the 6th number.<\/p>\n<p> [C7] Show the average of those 6 numbers.<\/p>\n<p> [C8] Show the 1st number that is smaller than the average.<\/p>\n<p> [C9] Show the 2nd number that is smaller than the average. <\/p>\n<p> [C10] Show the 3rd number that is smaller than the average. (if any)<\/p>\n<p> [C11] Show the 4th number that is smaller than the average. (if any)<\/p>\n<p> Page 2 of 5<\/p>\n<p> Page 1 of 2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CS130: Computer Architecture Project 9 (PJ 9) Dr. Lin Version 9\/24\/21 CS225 Fundamentals of Computer Science Course Syllabus Fall 2013 Dr. Simon Lin Version: 09\/02\/2013 PJ 9 \u2013 Array Game of Numbers Please follow the instructions to complete this project assignment. (1) Go to Internet: http:\/\/www.jblearning.com\/catalog\/9781284036121\/ (2) Click Sample Materials in the middle of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10],"class_list":["post-78885","post","type-post","status-publish","format-standard","hentry","category-research-paper-writing","tag-writing"],"_links":{"self":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/78885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/comments?post=78885"}],"version-history":[{"count":0,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/78885\/revisions"}],"wp:attachment":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/media?parent=78885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/categories?post=78885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/tags?post=78885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}