implemented boolean functions for each pin

This commit is contained in:
lucic71 2020-06-04 21:27:42 +03:00
parent 6b696180d2
commit 91cbd23255
2 changed files with 250 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 KiB

View File

@ -23,13 +23,6 @@
.equiv TEMP1, 22
.equiv TEMP2, 23
; Aliases for PINs connected to the 7 segment display. These are the
; values written in PORTD. DIGITAL PINs 0-6 are connected to PINs a-g
; of the 7 segment display.
; TO BE IMPLEMENTED
.org 0x0000
rjmp INIT
@ -72,6 +65,8 @@ COUNTER:
mov r24, r16
call ENCODE
call WAIT
call WAIT
call WAIT
inc r16
@ -94,11 +89,11 @@ ENCODE:
; b = !B + !C!D + CD
; c = B + !C + D
; d = !B!D + C!D + B!CD + !BC + A
; e = !b!d + C!D
; e = !B!D + C!D
; f = A + !C!D + B!C + B!D
; g = A + B!C + !BC + C!D
;
; Each PIN equation will be computed in r21 and sent to its corresponding
; Each PIN equation will be computed in RESULT and sent to its corresponding
; PIN. Other registers will be used to extract the bits from the binary
; number and to perform logic operations.
@ -119,15 +114,19 @@ ENCODE:
asr DBIT
asr DBIT
; TEMP2 will be used for eor'ing with register TEMP1 or RESULT
; It is equivalent with flipping the bit in TEMP1 or RESULT.
ldi TEMP2, 0x01
; Compute a. Steps:
;
; 1. Move A in RESULT and perform OR with C
; 2. Move B in TEMP1 and perform AND with B
; 3. Perform OR between (A + C) and BD
; 4. Move B in TEMP1, perform or with D and negate the result (!B!D = !(B + D))
; (to negate all the bits we will use exclusive or between the register
; and the value 0xFF)
; 5. Perform OR between (A + C + BD) and !B!D
; 1. Move A in RESULT
; 2. Perform RESULT = RESULT + C
; 3. Compute DB using TEMP1 and perform RESULT = RESULT + BD
; 4. Compute !D!B = !(D + B) using TEMP1 and TEMP2 and perform
; RESULT = RESULT + !B!D.
; 5. Write RESULT to DIGITAL PIN 0
mov RESULT, ABIT
@ -139,13 +138,246 @@ ENCODE:
mov TEMP1, BBIT
or TEMP1, DBIT
ldi TEMP2, 0xFF
eor TEMP1, TEMP2
andi TEMP1, 0x01
and RESULT, TEMP1
out PORTD, RESULT
call WAIT
; Compute b. Steps:
;
; 1. Move B in RESULT and invert the bits.
; 2. Compute !C!D using TEMP1 and TEMP2 and perform RESULT = RESULT + !C!D
; 3. Compute CD using TEMP1 and perform RESULT = RESULT + CD
; 4. Write RESULT to DIGITAL PIN 1
mov RESULT, BBIT
eor RESULT, TEMP2
mov TEMP1, CBIT
or TEMP1, DBIT
eor TEMP1, TEMP2
or RESULT, TEMP1
mov TEMP1, CBIT
and TEMP1, DBIT
or RESULT, TEMP1
clc
rol RESULT
out PORTD, RESULT
call WAIT
; Compute c. Steps:
;
; 1. Move B in RESULT
; 2. Perform RESULT = RESULT + !C
; 3. Perform RESULT = RESULT + D
; 4. Write RESULT to DIGITAL PIN 2
mov RESULT, BBIT
mov TEMP1, CBIT
eor TEMP1, TEMP2
or RESULT, TEMP1
or RESULT, DBIT
clc
rol RESULT
clc
rol RESULT
out PORTD, RESULT
call WAIT
; Compute d. Steps:
;
; 1. Move A int RESULT
; 2. Perform RESULT = RESULT + !B!D
; 3. Perform RESULT = RESULT + C!D
; 4. Perform RESULT = RESULT + B!CD
; 5. Perform RESULT = RESULT + !BC
; 6. Write RESULT to DIGITAL PIN 3
mov RESULT, ABIT
mov TEMP1, BBIT
or TEMP1, DBIT
eor TEMP1, TEMP2
or RESULT, TEMP1
mov TEMP1, DBIT
eor TEMP1, TEMP2
or TEMP1, CBIT
or RESULT, TEMP1
mov TEMP1, CBIT
eor TEMP1, TEMP2
and TEMP1, BBIT
and TEMP1, DBIT
or RESULT, TEMP1
mov TEMP1, BBIT
eor TEMP1, TEMP2
and TEMP1, CBIT
or RESULT, TEMP1
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
out PORTD, RESULT
call WAIT
; Compute e. Steps:
;
; 1. Compute RESULT = C!D
; 2. Compute RESULT = RESULT + !B!D
; 3. Write RESULT to DIGITAL PIN 4
mov RESULT, DBIT
eor RESULT, TEMP2
and RESULT, CBIT
mov TEMP1, BBIT
or TEMP1, DBIT
eor TEMP1, TEMP2
or RESULT, TEMP1
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
out PORTD, RESULT
call WAIT
; Compute f. Steps:
;
; 1. Compute RESULT = A
; 2. Compute RESULT = RESULT + !C!D
; 3. Compute RESULT = RESULT + B!C
; 4. Compute RESULT = RESULT + B!D
; 5. Write RESULT to DIGITAL PIN 5
mov RESULT, ABIT
mov TEMP1, CBIT
or TEMP1, DBIT
eor TEMP1, TEMP2
or RESULT, TEMP1
mov TEMP1, CBIT
eor TEMP1, TEMP2
and TEMP1, BBIT
or RESULT, TEMP1
mov TEMP1, DBIT
eor TEMP1, TEMP2
and TEMP1, BBIT
or RESULT, TEMP1
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
out PORTD, RESULT
call WAIT
; Compute g. Steps:
;
; 1. Compute RESULT = B!C
; 2. Compute RESULT = RESULT + !BC
; 3. Compute RESULT = RESULT + C!D
; 4. Compute RESULT = RESULT + A
; 5. Write RESULT to DIGITAL PIN 6
mov RESULT, CBIT
eor RESULT, TEMP2
and RESULT, BBIT
mov TEMP1, BBIT
eor TEMP1, TEMP2
and TEMP1, CBIT
or RESULT, TEMP1
mov TEMP1, DBIT
eor TEMP1, TEMP2
and TEMP1, CBIT
or RESULT, TEMP1
or RESULT, ABIT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
clc
rol RESULT
out PORTD, RESULT
call WAIT
ret
WAIT:
; Description
; -----------
;
; Loop 0x400000 times which takes approximately 12 milion cycles which is
; approximately 0.7s.
ldi r17, 0x10
ldi r18, 0x00
ldi r19, 0x00
_WAIT:
dec r19
brne _WAIT
dec r18
brne _WAIT
dec r17
brne _WAIT
ret