Exercise 9        Name _________________ Points      /13

1. (2) The interrupt vector shows the segment and offset of the Divide routine executed when a Divide Overflow or Type 0 interrupt occurs. Fill in the interrupt vector assuming that Print is to be executed on a Type 5 interrupt and Break is to be executed on a Type 3 interrupt.

   Interrupt     Physical
     Vector      Address          Segment:Offset
| Offset  1401  | 00000             2B41 : 412B  Print Proc Far
| Segment A114  | 00002                              :
|               | 00004                             Iret
|               | 00006                          Print Endp
|               | 00008
|               | 0000A             2BAD : 12B4  Break Proc Far
| Offset  12B4  | 0000C                              :
| Segment 2BAD  | 0000E                             Iret
|               | 00010                          Break Endp
|               | 00012
| Offset  412B  | 00014             A114 : 1401  Divide Proc Far
| Segment 2B41  | 00016                                :
| Offset  1234  | 00018                               Iret
| Segment 5678  | 0001A                          Divide Endp

2. (4) Show the stack contents and indicated registers after the execution of the Int 6 instruction below.

                 101A             Segment : Offset
|   Flags      | 1018                412C : A2B4  Int 6
|   412C       | 1016                412C : A2B6  Mov Ax, 178
|   A2B6       | 1014 <- Sp
|              | 1012              Sp   1014            Cs   5678
|              | 1010
|              | 100E              IF    0              Ip   1234
 

3. (4) Give the Assembly code fragment that uses the BIOS Int 10h to read the character at cursor position row 10, column 42 on video page 0.

Mov    Ah, 2
Mov    Bh, 0
Mov    Dh, 10
Mov    Dl, 42
Int      10h
Mov    Ah, 8
Int      10H
4. (2) Using DOS Int 21h, give the code fragment to set the system time to 5:30:45 pm.
Mov    Ch, 17
Mov    Cl, 30
Mov    Dh, 45
Mov    Dl, 00
Mov    Ah, 2Dh
Int      21h
5. (1) Using the DOS Int 21h interrupt, give the code fragment to wait for any key to be pressed and read the key that was pressed.
Mov    Ah, 8
Int      21h

 6. (5) In the following:

  1. What device of the Launchpad does P1DIR.6 refer? _____red LED______
     
  2. What device of the Launchpad does P1DIR.3 refer? _____push button____
     
  3. What device of the Launchpad does P1IN.3 refer?  _____push button____
     
  4. What assembly instruction turns on the green LED? _____none______
     
  5. What does the following code perform?                   _Place address of main in interrrupt vector at location of RESET operation_

                .sect   ".reset"
                .short  main                 
            .cdecls C,LIST,  "msp430G2231.h"
            .text                           
main        mov.w   #0280h,SP               ; Set stackpointer (128B RAM device)
            mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
            bis.b   #01000000b,&P1DIR       ; Set P1DIR.6 = 1
            bic.b   #00001000b,&P1DIR       ; Set P1DIR.3 = 0
            bic.b   #00001000b,&P1SEL       ; Select Port 1 P1.3
            bic.b   #01000000b,&P1OUT       ; Set P1OUT.6 = 0               

_while                                      ; while(1) {
_if         mov.b   &P1IN, R15              ;    if( P1IN.3 == 0)
            and.b   #00001000b, R15         ;       P1OUT.6 = 1
            jz      _then                   ;    else
            jmp     _else                   ;       P1OUT.6 = 0
_then       bis.b   #01000000b, &P1OUT      ; }
            jmp     _endif
_else       bic.b   #01000000b, &P1OUT
_endif
            jmp     _while
_endwhile
;           Interrupt Vectors
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  main                  
            .end

7. (5) In the following:

  1. What device of the Launchpad does &CCR0 refer?     ____Timer A count register___
     
  2. What device of the Launchpad does &TACTL refer?   ____Timer A count control register___
     
  3. What device of the Launchpad does &CCTL0 refer?   ____Timer A interrupt control register___
     
  4. &CCR0 count to generate a 2 second interrupt ?      ___24,000_____________
     
  5. What does the following code perform?                   _Powers off the CPU and enables processor interrupts_

                bis.w   #CPUOFF+GIE,SR
 	.cdecls C,LIST,  "msp430g2231.h"
      .text                           ; Progam Start
main  mov.w   #0280h,SP               ; Initialize stackpointer
      mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop Watch Dog Timer
      bis.b   #01000001b,&P1DIR       ; P1.0 and P1.6 output
      bic.b   #00000001b,&P1OUT       ; Set green LED off
      bis.b   #01000000b,&P1OUT       ; Set red LED on
      mov.w   #10h,&CCTL0             ; CCR0 interrupt enabled, bit 4 = 1
      mov.w   #12000,&CCR0            ; Count 12000 to CCR0
      mov.w   #TASSEL_1+MC_1,&TACTL   ; ACLK source (~12KHz), UP mode (count up to CCR0 value)
						
      bis.w   #CPUOFF+GIE,SR          ; CPU off, interrupts enabled

TA0   xor.b   #01000001b,&P1OUT       ; Toggle P1.0 and P1.6
      reti                            		

;     Interrupt Vectors
      .sect   ".reset"                ; MSP430 RESET Vector
      .short  main                    ;
      .sect   ".int09"                ; Timer_A0 Vector
      .short  TA0                 
      .end