CS100 - Assignment 6 (Assembly Language)

(Section 001, Fall 2007)

The questions carry equal weight.

  1. Download and install the PEP/7 simulator from: ftp://ftp.pepperdine.edu/pub/compsci/pep7/.

  2. Write an assembly language program for PEP/7 that prints your name.

  3. Write an assembly language program for PEP/7 that gets two numbers from the user, computes the difference between them, and prints the result.

  4. The instruction COMPA 008b,d compares the number in the 'A' register to the number in memory location 008b. The instruction BRLT xxx will cause the processor to jump to label 'xxx' if the result of the previous comparison was that the value in 'A' is smaller than the number in memory location 008b. Write pseudo code that corresponds to the following program:
             BR      Main
    counter: .BLOCK  d#2
    limit:   .BLOCK  d#2
    ;
    Main:    LOADA   d#0,i     
             STOREA  counter,d
             LOADA   d#40,i     
             STOREA  limit,d
    Do:      CHARO   C#/H/,i   
             LOADA   counter,d  
             ADDA    d#1,i
             STOREA  counter,d
    While:   LOADA   counter,d 
             COMPA   limit,d
             BRLT    Do
             DECO    counter,d 
             STOP
             .END
    

  5. The following program produces errors with certain input values. Correct the program so that the problem is resolved.
          BR  Main     
    sum:  .WORD d#0	   
    num1: .BLOCK d#1   
    num2: .BLOCK d#1   
    num3: .BLOCK d#1   
    Main: LOADA sum,d  
          DECI num1,d  
          DECI num2,d  
          DECI num3,d  
          ADDA num1,d  
          ADDA num2,d  
          ADDA num3,d  
          STOREA sum,d 
          DECO sum,d   
          STOP         
          .END
    



Gady Agam 2007-10-08