Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

;challenging task 6_2

;ORG 0000H
;MOV A,#94
;MOV B,#02
;MUL AB
;MOV B,#11
;MUL AB
;MOV R0,A
;MOV R1,B
;MOV A,#11
;MOV B,#11
;MUL AB
;MOV R2,A
;MOV R3,B
;MOV A,#94
;MOV B,#94
;MUL AB
;MOV R4,A
;MOV R5,B
;MOV A,R2
;ADD A,R4
;MOV R2,A
;MOV A,R3
;ADDC A,R5
;MOV R3,A
;MOV A,R2
;SUBB A,R0
;MOV R2,A
;MOV A,R3
;SUBB A,R1
;MOV R3,A
;END
;ORG 0000H

;MOV P1, #0 ; initialize Port 1 to all zeros

;MAIN:
; MOV A, P1 ; read value from Port 1
; ANL A, #1 ; mask out all bits except the least significant bit
; JZ EVEN ; jump to EVEN if A is even
; MOV R3, #5 ; set R3 to 5ms delay for odd numbers
; JMP START ; jump to START
;EVEN:
; MOV R3, #10 ; set R3 to 10ms delay for even numbers
;START:
; MOV R1, #0 ; initialize R1 to zero
; MOV R2, #0 ; initialize R2 to zero
; MOV R0, A ; store value in register R0
; MOV P0, #2 ; set Port 0.1 pin high
; ACALL DELAY ; call delay subroutine
; MOV P0, #0 ; set Port 0.1 pin low
; ACALL DELAY ; call delay subroutine
; SJMP MAIN ; repeat indefinitely

;DELAY:
; MOV R1, #0 ; initialize R1 to zero
; MOV R2, #0 ; initialize R2 to zero
;LOOP1:
; DJNZ R1, LOOP1 ; decrement R1 and repeat until zero
; DJNZ R2, LOOP1 ; decrement R2 and repeat until zero
; DJNZ R3, LOOP1 ; decrement R3 and repeat until zero
; RET ; return from subroutine
;ORG 0000h

;MOV P3, #0FFh


;MOV P2, #0FEh

;MOV A, #0

;MAIN:
; JB P3.4, NEXT

; INC A
; CJNE A, #94, NEXT

; MOVX @DPTR, A
; INC DPTR
; MOV A, #1
; MOVX @DPTR, A

; MOV A, #0
; MOVX @DPTR, A
; INC DPTR

; CLR A

;NEXT:
; SJMP MAIN

;END

You might also like