Lab 5

  1. Watch videos entitled “ Introduction” and “ Procedures
  2. Using the microprocessor simulator, open the program  06proc.asm.
  3. Step through its execution to understand its current operation.
  4. Modify the traffic light program from Module 4 to utilize the code in 06proc.asm to establish a  realistic  time  delay.
  5. Include all of the following in a Word document entitled “Lab5_StudentID”. Where your student id is substituted in the file name.
    • A screenshot of the modified assembly code
    • A few screenshots that show the traffic lights on Port 1 as the program is stepped through
  6. Upload file “Lab5_StudentID”.

DIRECTIONS:

Modify the traffic light program from Module 4 (below #1) to utilize the code in 06proc.asm (below #2) to establish a realistic time delay.

 

Module 4 traffic light program:

      CLO          ; close unwanted windows

start:

           MOV BL,10    ; START BL REGISTER AT 10

                        ; TURN OFF ALL TRAFFIC LIGHTS

           MOV AL,10    ; COPY 00000000 INTO THE AL REGISTER

           OUT 01       ; SEND AL TO PORT ON

 

   MOV BL,0A ; BL=TEN

LOOP:

                                                         ; TURN RED LIGHTS ON

                         MOV AL,90            ; COPY 10010000 INTO THE AL REGISTER

                         OUT 01                  ; SEND AL TO PORT ONE

                         MOV AL,10            ; DELAY

 

                                                         ; TURN ON AMBER LIGHTS

                        MOV AL,48             ; COPY 01001000 INTO THE AL REGISTER

                        OUT 01                   ; SEND AL TO PORT ONE

                        MOV AL,10              ; DELAY

 

                                                          ; TURN ON GREEN LIGHTS

                        MOV AL,24               ; COPY 00100100 INTO AL REGISTER

                        OUT 01                    ; SEND AL TO PORT ONE

                        MOV AL,10              ; DELAY

 

                        DEC BL                    ; SUBTRACT ONE FROM BL

                         JNZ LOOP              ; JUMP BACK TO LOOP IF BL WAS NOT ZERO

                        END                          ; PROGRAM ENDS

 

06PROC.ASM:


; When the procedure terminates, the CPU registers are
; restored to the same values that were present before
; the procedure was called. Push, Pop, Pushf and Popf
; are used to achieve this. In this example one procedure

; is re-used three times. This re-use is one of the main
; advantages of using procedures.

;------ The Main Program ----------------------------------------
Start:
    MOV    AL,8    ; A short delay.
           

    CALL    30    ; Call the procedure at address [30]

    MOV    AL,10    ; A middle sized delay.
    CALL    30    ; Call the procedure at address [30]

    MOV    AL,20    ; A Longer delay.
    CALL    30    ; Call the procedure at address [30]

JMP    Start    ; Jump back to the start.

; ----- Time Delay Procedure Stored At Address [30] -------------
    ORG    30    ; Generate machine code from address [30]

    PUSH    AL    ; Save AL on the stack.
    PUSHF        ; Save the CPU flags on the stack.
Rep:
    DEC    AL    ; Subtract one from AL.
    JNZ    REP    ; Jump back to Rep if AL was not Zero.

    POPF        ; Restore the CPU flags from the stack.
    POP    AL    ; Restore AL from the stack.

    RET        ; Return from the procedure.
; ---------------------------------------------------------------
    END
; ---------------------------------------------------------------

TASK

15)    Re-do the traffic lights program and use this procedure
    to set up realistic time delays. 02tlight.asm

16)    Re-do the text input and display program with procedures.
    Use one procedure to input the text and one to display it.

; ---------------------------------------------------------------

Answers

Related Questions

discusion II...

"Pricing for a Lifetime" Please respond to the following:Assess the challenges of developing pricing over a product’s life...

discusion II...

"Pricing for a Lifetime" Please respond to the following:Assess the challenges of developing pricing over a product’s life...

3...

 ...

please read...

Has anyone taken this Capstone class HCS/589...

Goals & Objectives Paper...

Goals & Objectives Paper due in 3 hours ...

sociology 3...

In a reflective essay of 3-5 pages, and using the Christiano text, Lesson 3 and online readings, your MTB exercise, and any other credible and auth...

If you didn't find the right answer

Ask Your Questions, We'll notify you once someone answers it