Homework 1 Solutions

22C:116, Fall 1999

Douglas W. Jones

  1. What is your E-mail address? Beats me!

  2. The Problem: What is the difference between a control transfer initiated by longjmp() and a control transfer initiated by the older FORTRAN assigned GOTO?
    The assigned GOTO merely transfers control. The longjmp() not only transfers control, but attempts to put other parts of the execution context into place such as the stack pointer, the local variables, and other elements of the context.

  3. Part A: How would you initialize these registers?
    PIE1:TXIE = 0 because we're not using interrupts.

    PIR1:TXIF = 1 because the initial state of the interface is idle.

    TXREG needs no initialization.

    TXSTA:TX9 = 1 because 8 bits plus parity is 9 bits.
    TXSTA:TXEN = 1 so assignment to TXREG will start transmitter.
    TXSTA:TRMT = 0 because the hardware queue is initially empty.
    TXSTA:TX9D needs no initialization)

    TXIF and TRMT probably need no initialization in software because they are status bits reporting on hardware state information.

    Part B: Write high level pseudocode for a function, TXPUTC, that outputs one character to the asynchronous serial port, using polling, transmitting 8-bits with mark parity.

    	TXPUTC( ch )
    		-- polling loop awaiting ready to transmit
    		while PIR1:TXIF = 0 do nothing
    
    		-- set parity bit appropriately
    		TXSTA:TX9D = 1
    
    		-- send out data
    		TXREG = ch
    	done!