(c) Imagine that a new type of loop, called a mid-check loop, is to be added to the Jack language. The following is a ps

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

(c) Imagine that a new type of loop, called a mid-check loop, is to be added to the Jack language. The following is a ps

Post by answerhappygod »

C Imagine That A New Type Of Loop Called A Mid Check Loop Is To Be Added To The Jack Language The Following Is A Ps 1
C Imagine That A New Type Of Loop Called A Mid Check Loop Is To Be Added To The Jack Language The Following Is A Ps 1 (120.74 KiB) Viewed 13 times
(c) Imagine that a new type of loop, called a mid-check loop, is to be added to the Jack language. The following is a pseudo-code example: loop stml; exitif ( expr ) stm2; endloop The parts in bold are new keywords to be added to the language, stml and stm2 are pseudocode for Jack statements, and expr is pseudocode for a Jack expression. Zero or more statements may be written before the exit-check (exitif) and zero or more statements may be written after the parenthesised exit-check expression. The mid-check loop has the following execution characteristics: • The statements (if any) before the exit-check are executed. • The expression in the exit-check is evaluated. If the expression evaluates to true then the loop exits and control continues with whatever follows the loop body. If the expression evaluates to false then the statements (if any) following the exit-check are executed. • Once any statements following the exit-check have been executed, control returns to the statements (if any) preceding the exit check. In other words, the iteration repeats. The following pseudo-code example is to be translated to VM code: loop stml; exitif ( expr ) stm2; endloop The VM instruction set provides three instructions to manage flow-of- control: label, goto and if-goto. Assuming that in the translation to VM code of the example loop the translations of the two statements and the one expression appear in same order in the VM code as in the source code. complete the following outline
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply