extracreditLAB9

# extracreditLAB9 - which means it would have an infinite...

This preview shows pages 1–2. Sign up to view the full content.

* Extra Credit 1 (30%) Execute the short program below. What does it do? Explain as many of the different commands involved as you can discern. You may use the ? < command > option to access the Mathematica Book. * Print [ ToString [#0] [] ] & [] - The function Print [ToString[#0] [] ] has zero arguments, and #0 represents the function itself, so the argument of Print [ToString [#0] [] ], ToString [#0] [] is printed. The result of this evaluation is null because it is a Print statement. ToString comes into play in two ways, first since the quotes are not printed in Standard Form, a String looks the same as the corresponding symbol. Secondly, without the ToString, the result of the evaluation of the pure function Print [#0 [] ] would be Print [#0[] ], which would be evaluated and so on,

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: which means it would have an infinite recursion. * Extra Credit 2 90 % : Can you code a program in the LC-3 machine language, that performs the same task? * .ORIG X3000; start at location X3000 LD R1, NUMBER; load the value into R1 LOOP; AND R1, R1, #-1; take the two’s complement, first multiply by negative one ADD R1, R1, #1; take the two’s complement, second by add one Brn, LOOP; If value is negative, proceed, otherwise LOOP HALT; halt the system .END; end of program This simulates a program that will take the two’s complement, and since the two’s complement will never be negative, an applied loop will make this process never ending and therefore self-replicating....
View Full Document

## This note was uploaded on 01/12/2010 for the course BME 14345 taught by Professor Orlyalter during the Fall '09 term at University of Texas.

### Page1 / 2

extracreditLAB9 - which means it would have an infinite...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online