Marie Examples PDF

Title Marie Examples
Course Computer Architecture
Institution Purdue University Fort Wayne
Pages 2
File Size 69.2 KB
File Type PDF
Total Downloads 59
Total Views 153

Summary

examples marie...


Description

Example 1: ORG 100 Load Addr Store Next Load Num Subt One Store Ctr Loop, Load Sum AddI Next Store Sum Load Next Add One Store Next Load Ctr Subt One Store Ctr Skipcond 000 Jump Loop Halt Addr, Hex 117 Next, Hex 0 Num, Dec 5 Sum, Dec 0 Ctr, Hex 0 One, Dec 1 Dec 10 Dec 15 Dec 20 Dec 25 Dec 30 Example 2: ORG 100 If, Load X Subt Y Skipcond 400 Jump Else Then, Load X Add X Store X Jump Endif Else, Load Y Subt X Store Y Endif, Halt X, Dec 12 Y, Dec 20 END Example 3: ORG

100

/ Example 4.1 /Load address of first number to be added /Store this address is our Next pointer /Load the number of items to be added /Decrement /Store this value in Ctr to control looping /Load the Sum into AC /Add the value pointed to by location Next /Store this sum /Load Next /Increment by one to point to next address /Store in our pointer Next /Load the loop control variable /Subtract one from the loop control variable /Store this new value in loop control variable /If control variable < 0, skip next instruction /Otherwise, go to Loop /Terminate program /Numbers to be summed start at location 118 /A pointer to the next number to add /The number of values to add /The sum /The loop control variable /Used to increment and decrement by 1 /The values to be added together

/Load the first value /Subtract the value of Y, store result in AC /If AC=0, skip the next instruction /Jump to Else part if AC is not equal to 0 /Reload X so it can be doubled /Double X /Store the new value /Skip over the false, or else, part to end of if /Start the else part by loading Y /Subtract X from Y /Store Y-X in Y /Terminate program (it doesn't do much!) /Load the loop control variable /Subtract one from the loop control variable

Load X / Load the first number to be doubled. Store Temp / Use Temp as a parameter to pass value to Subr. JnS Subr / Store the return address, and jump to the procedure. Store X / Store the first number, doubled Load Y / Load the second number to be doubled. Store Temp JnS Subr / Store the return address and jump to the procedure. Loop, Store Y / Store the second number doubled. Halt / End program. X, DEC 20 Y, DEC 48 Temp, DEC 0 Subr, HEX 0 / Store return address here. Load Temp / Actual subroutine to double numbers. Add Temp / AC now holds double the value of Temp. JumpI Subr / Return to calling code. END Example 4 / This program traverses a string and outputs each / character. The string is terminated with a null. / Note: By changing the output window control setting / to "no linefeeds" the text will print in a single / line, rather than in a column of single characters. ORG 100 Getch, LoadI Chptr / Load the character found at address chptr. Skipcond 400 / If the character is a null, we are done. Jump Outp / Otherwise, proceed with operation. Halt Outp, Output / Output the character. Load Chptr / Move pointer to next character. Add One Store Chptr Jump Getch One, Hex 0001 Chptr, Hex 10B String, Dec 072 / H Dec 101 / e Dec 108 / l Dec 108 / l Dec 111 / o Dec 032 / [space] Dec 119 / w Dec 111 / o Dec 114 / r Dec 108 / l Dec 100 / d Dec 033 / ! Dec 000 / [null] END...


Similar Free PDFs