

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


The following two MARIE assembly language programs are based on a previous homework assignment, with the number of loop executions now being an input variable. Program 1 “WHILE” // Almost identical to the homework problem. Input Store Count // Set the loop count Clear Store X Store Y // Clear both X and Y L1, Load X // Get X back explicitly Subt Count // Is X < Count Skipcond 000 // Skip if AC < 0 Jump L2 // No, X Count. Go to end of loop. Load X // Yes (AC – Count) < 0. Get X back into AC Add One // Add 1 Store X // Update the value of X Add Y // AC now has (X + Y) Store Y // Update the value of Y Jump L1 // Go back to top of loop L2, Load Y Output Halt X, HEX 0000 Y, HEX 0000 Count, HEX 0000 One, HEX 0001 INSTRUCTIONS: Execute this program twice, once with Count = 4 and once with Count = 0. What values are output for each.
Program 2 “UNTIL” Input Store Count // Set the loop count Clear Store Y // Clear both X and Y L1, Add One // AC has value of X, so just add one Store X // Updated value for X Add Y // AC now has (X + Y) Store Y // Updated value of Y Load X // Get X back into AC Subt Count // AC has (X – Count) Skipcond 000 // Continue if X < Count or (X – Count) < 0 Jump L2 // Exit if X Count or NOT [ (X – Count) < 0 ] Load X // Get X back into the AC Jump L1 // Go back to the top of the loop L2, Load Y // Get Y back into the AC Output Halt X, HEX 0000 Y, HEX 0000 Count, HEX 0000 One HEX 0001 INSTRUCTIONS: Execute this program twice, once with Count = 4 and once with Count = 0. What values are output for each. Why is this different from the first output.