Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
banksel <ADDRESS>
banksel TRISA
;or
banksel 0x80
org 0x0000 ;reset vector
goto START
<LABEL> <INSTRUCTION> <OPERAND>
List p=pic16f877
include "P16F877.INC"
__CONFIG _CP_OFF & _WDT_OFF &_BODEN_OFF & _PWRTE_ON & _HS_OSC & _WDT_OFF & _LVP_OFF & _CPD_OFF
ERRORLEVEL -302
;#####################################################################
;# constant definitions #
;#####################################################################
#define E_line 0 ;from wiring
#define RS_line 1 ; -//-
#define RW_line 2 ; -//-
#define carry_bit 0 ; from datasheet
;######################################################################
; variable declaration
;######################################################################
cblock 0x20
delay_counter1
delay_counter2
temp ;variable store 8-bit data to send to LCD
GPR1
key ;variable store key value from keypad
tmp
tmp2
tmp3
s0 ;(s0-s15): 16bytes of state
s1 ;
s2 ;
s3 ;
s4
s5
s6
s7
s8
s9
s10
s11
s12
s13
s14
s15
k0 ; (k0-k15): 16 bytes of key
k1
k2
k3
k4
k5
k6
k7
k8
k9
k10
k11
k12
k13
k14
k15
Offset_H
Offset_L
sbox
mixtmp
mix0
mix1
mix2
mix3
keytmp0
keytmp1
keytmp2
keytmp3
rconReg
rconValue
rconValue10round
counter ; counter for AES steps
rconReg2
invkeyexpcounter
endc
;######################################################################
; register equates
;######################################################################
status equ 0x03
portd equ 0x08
porte equ 0x09
portb equ 0x06
porta equ 0x05
portc equ 0x07
intcon equ 0x0B
;subBytes equ 0x200
#include "macro.inc"
;org 0h
org 0h
goto port_initialization
;######################################################################
; PORTS INITIALIZATION
;######################################################################
;WIRING:
; PortD PortE PortB
; 0 --> lcd bus 0 0 --> lcd RS 0 --> keypad row0
; 1 --> lcd bus 1 1 --> lcd E 1 --> keypad row1
; 2 --> lcd bus 2 2 --> lcd R/W 2 --> keypad row2
; 3 --> lcd bus 3 3 --> keypad row3
; 4 --> lcd bus 4 4 --> not used
; 5 --> lcd bus 5 5 --> keypad column0
; 6 --> lcd bus 6 6 --> keypad column1
; 7 --> lcd bus 7 7 --> keypad column2
port_initialization
Bank1
movlw b'00000111'
movwf TRISB
movlw b'00001000'
movwf OPTION_REG
Bank0
CLRF PORTA ; Initialize PORTA by clearing output data latches
CLRF PORTB ; Initialize PORTB by clearing output data latches
CLRF PORTE
CLRF PORTD
Bank1
MOVLW 0X06
MOVWF ADCON1
MOVLW 0xCF
MOVWF TRISA
MOVLW B'00000000' ; Value used to initialize data direction
MOVWF TRISD ; Set RB<7:0> as outputs
MOVWF TRISE
Bank0
;######################################################################
; MAIN PROGRAMM
;######################################################################
main
call initializeLCD
call clearLCD
nop
nop
call result_in_lcd
nop
nop
goto stop
stop
goto stop
include "display.asm"
end