Assignment 7

Do the first four problems by hand.

  1. List the hexadecimal code for the following program (hand assemble it).
    Label 	Hex Address 	Instruction
    	100	 	Load A 
    	101		Add One 
    	102		Jump Sl 
    S2,	103		Add One 
    	104		Store A 
    	105		Halt 
    S1,	106		Add A 
    	107		Jump S2 
    A,	108		HEX 0023 
    One, 	109		HEX 0001

  2. What are the contents of the symbol table for the preceding program?

  3. Decipher the following MARIE machine language instructions (write the assembly language equivalent):
    1. 0010000000000111
    2. 1001000000001011
    3. 0011000000001001

  4. What are the potential problems (perhaps more than one) with the following assembly language code fragment (implementing a subroutine) written to run on MARIE? The subroutine assumes the parameter to be passed is in the AC and should double this value. The Main part of the program includes a sample call to the subroutine. You can assume this fragment is part of a larger program.
    Main,	Load X 
    	Jump Subl 
    Sret,	Store X 
    Subl,	 Add X 
    	Jump Sret

    Use the Marie simulator for these next problems. Show screen shots of the simulator after loading your code. Include source code listings. (.mas files).

  5. Write the following code segment in MARIE's assembly language:
    if X > 1 then 
      Y := X + X; 
      X := 0; 

  6. Write the following code segment in MARIE assembly language:
    X := 1; 
    while X < 10 do
      X := X+l;

  7. Write the following code segment in MARIE assembly language:
    Sum := 0; 
    for X := 1 to 10 do
      Sum := Sum + X;

  8. Write a MARIE program using a loop that multiplies two positive numbers by using repeated addition. For example, to multiply 3 * 6, the program would add 3 six times, or 3 + 3 + 3 + 3 + 3 + 3.

  9. Write a MARIE subroutine to subtract two numbers.

  10. Write a MARIE program to evaluate the expression A * B + C * D. (Hint: Use the results of previous problems).

Maintained by John Loomis, last updated 9 Feb 2005