6.004 On-line: Questions for Lab #5

When entering numeric values in the answer fields, you can use integers (1000), floating-point numbers (1000.0), scientific notation (1e3), or JSim numeric scale factors (1K).

Problem 1. For each of the Beta instruction sequences shown below, indicate the values of the specified registers after the sequence has been executed by an unpipelined Beta. Consider each sequence separately and assume that execution begins at location 0 and halts when the HALT() instruction is about to be executed. Also assume that all registers have been initialized to 0 before execution begins.

You will find it helpful to read the note above for information on how to enter hex constants (useful for entering addresses and values). Remember that even though the Beta reads and writes 32-bit words from memory, all addresses are byte addresses, i.e., the addresses of successive words in memory differ by 4.

You can find detailed descriptions of each Beta instruction in the "Beta Documentation" handout distributed in lecture and available on-line.

  1. 
        . = 0
    
        AND(r31, r31, r0)
    
        CMPEQ(r31, r31, r1)
    
        ADD(r1, r1, r2)
    
        OR(r2, r1, r3)
    
        SHL(r1, r2, r4)
    
        HALT()
    
        

    :  

    :  

    :  

    :  

    :  

  1. 
        . = 0
    
        ADDC(r31, N, r0)
    
        LD(r0, 8, r1)
    
        SRAC(r1, 4, r2)
    
        ST(r2, 4, r0)
    
        HALT()
    
    
    
        . = 0x2000
    
    N:  LONG(0x12345678)
    
        LONG(0xDEADBEEF)
    
        LONG(0xEDEDEDED)
    
        LONG(0x00000004)
    
        

    :  

    :  

    :  

    :  

    :  

  1. 
        . = 0
    
        LD(r31, X, r0)
    
        CMPLE(r0, r31, r1)
    
        BNE(r1, L1, r31)
    
        ADDC(r31, 17, r2)
    
        BEQ(r31, L2, r31)
    
    L1: SUB(r31, r0, r2)
    
    L2: XORC(r2, 0xFFFF, r2)     | be careful here!
    
        HALT()
    
    
    
        . = 0x1CE8
    
    X:  LONG(0x87654321)
    
        

    :  

    :  

    :  

    :  

    :  

  1. 
        . = 0
    
        ADDC(r31, 0, r0)
    
        LD(r31, N, r1)
    
        BEQ(r31, L3, r31)
    
    L1: ANDC(r1, 1, r2)
    
        BEQ(r2, L2, r31)
    
        ADDC(r0, 1, r0)
    
    L2: SHRC(r1, 1, r1)
    
    L3: BNE(r1, L1, r31)
    
        HALT()
    
    
    
        . = 0x2468
    
    N:  LONG(0x8F2E3D4C)
    
        

    :  

    :  

    :  

    Suppose that the instructions above were relocated so that the first instruction were at location 0x100 instead of location 0. Assuming we then started execution at location 0x100 and we wanted the instructions to perform the same computation, which instruction encodings should be changed when relocating the program?

    :  

  1. 
        . = 0
    
        BEQ(r31, L1, r0)
    
        ADDC(r0, 0, r0)
    
    L1: LD(r0, 0, r1)
    
        HALT()
    
        

    :  

    :  

source: on_line_questions.py, course/assignments/lab5questions.xdoc