A program with a subroutine. Two new instructions are introduced: JnS - jumps to a subroutine, first storing the return

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: 899604
Joined: Mon Aug 02, 2021 8:13 am

A program with a subroutine. Two new instructions are introduced: JnS - jumps to a subroutine, first storing the return

Post by answerhappygod »

A Program With A Subroutine Two New Instructions Are Introduced Jns Jumps To A Subroutine First Storing The Return 1
A Program With A Subroutine Two New Instructions Are Introduced Jns Jumps To A Subroutine First Storing The Return 1 (43.96 KiB) Viewed 40 times
A program with a subroutine. Two new instructions are introduced: JnS - jumps to a subroutine, first storing the return address in the first location in the subroutine. Jump I jump immediate, uses the value in the stored location, as an address. Used here to return back / example of creating, calling, and returning from a function 7 using variables to pass parameters, / to return values, and as local variables input get user input, store in var FooParam wwwwwwwwwwwwww store FooParam JnS Foo / call Foo, start running with instruction AFTER foo load FooReturn / retrieve and print whatever is returned output halt Foo, hex 000 / stores address to use when returning from foo FooParam/ get and print passed param load output add FooLocal / return FooParam + FooLocal store FooReturn Jump I Foo return from foo (to the address we stored when foo was called) FooParam, dec 0 / use to a param to foo FooLocal, dec 20 / use as "local" variable for foo /use to return a value from foo FooReturn, dec 0 Use this idea, to write a subroutine to double the value passed in through a shared memory location. The program will call the subroutine twice, in order to quadruple a value. Write MARIE assembly to do this program. You will use two data values, one called NUM1, initialized to 4. The second call NUM2 initialize to 20. And one called TEMP, initialized to zero, used to pass data between the subroutine and the main program. The quadrupled data items should be stored back into NUM1 and NUM2. Below is a kind of pseudocode that describes the program's function. Translate this to Marie assembly. "Play Computer" to execute your program virtually (logically on paper) to see that your program works correctly. Upload to D2L your assembly program.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply