Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: How to delay this code from 1 second delay to 0.5 second delay? org 00

ID: 2293952 • Letter: Q

Question

Question: How to delay this code from 1 second delay to 0.5 second delay?

org 0000h;

ljmp main;

org 0050h;

main:

     mov dptr,#SMG_DUAN ;

    mov r0,#00h;

    mov r1,#0ah;

lin1:mov a,r0;

    movc a,@a+dptr; get first indexed data in rom to accumolator a

    mov p1,a; move data in a to port 1

    lcall delay; subroutine call for the delay

    inc r0; increase r0 by one to get to the next index

    djnz r1,lin1; repeat the above instructions till we get all the data

    sjmp main;

delay:

mov r3,#0fh; move 0fh to regester 3

lin2: mov r4,#0ffh; mov 0ff to reginster 4

lin3: mov r5,#0ffh; move 0ff to register 5

djnz r5,$; decrease r5 till it equal to 0

djnz r4,lin3; decrease r4 till it equal to 0

djnz r3,lin2; decrease r3 till it equal to 0

ret

org 0200h

SMG_DUAN: ; rom memeory

   db 0c0h,0f9h,0a4h,0b0h,99h,92H,82h,0f8h;

   db 80h,90h,88h,7ch,39h,5eh,79h,71h;

   end

Explanation / Answer

In the delay block instead of moving 0FH to registers, move half the value which is 08H and decrement these values to 0 so that the delay will become half of the earlier.

org 0000h;

ljmp main;

org 0050h;

main:

     mov dptr,#SMG_DUAN ;

    mov r0,#00h;

    mov r1,#0ah;

lin1:mov a,r0;

    movc a,@a+dptr; get first indexed data in rom to accumolator a

    mov p1,a; move data in a to port 1

    lcall delay; subroutine call for the delay

    inc r0; increase r0 by one to get to the next index

    djnz r1,lin1; repeat the above instructions till we get all the data

    sjmp main;

delay:

mov r3,#08h; move 0fh to regester 3

lin2: mov r4,#08fh; mov 0ff to reginster 4

lin3: mov r5,#08fh; move 0ff to register 5

djnz r5,$; decrease r5 till it equal to 0

djnz r4,lin3; decrease r4 till it equal to 0

djnz r3,lin2; decrease r3 till it equal to 0

ret

org 0200h

SMG_DUAN: ; rom memeory

   db 0c0h,0f9h,0a4h,0b0h,99h,92H,82h,0f8h;

   db 80h,90h,88h,7ch,39h,5eh,79h,71h;

   end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote