| Mike Zinni

| Test for Parallel Port

MBAR = 0x10000000

PAR = MBAR + 0x00000004

PADDR = MBAR + 0x244

PADAT = MBAR + 0x248

 

ICID_BASE = 0x3000

ICID_LENGTH = 0x14

SYSTEMDIS_BASE = 0x3020

SYSTEMDIS_LENGTH = 0x11

CODE_BASE = 0x3040

CODE_LENGTH = 0x05

SYSTEMARM_BASE = 0x3060

SYSTEMARM_LENGTH = 0x0E

KEY_BASE = 0x4000

KEY_LENGTH = 0x05

TEMP_LENGTH = 0x4040

TEMP_BASE = 0x4050

CODEINV_BASE = 0x3040

CODEINV_LENGTH = 0x0E

 

move.l #CODEINV_BASE, %a1

move.b #0x43, (%a1)+      | C

move.b #0x4F, (%a1)+      | O

move.b #0x44, (%a1)+      | D

move.b #0x45, (%a1)+      | E

move.b #0x20, (%a1)+       | SPACE

move.b #0x49, (%a1)+       | I

move.b #0x4E, (%a1)+       | N

move.b #0x56, (%a1)+       | V

move.b #0x41, (%a1)+       | A

move.b #0x4C, (%a1)+       | L

move.b #0x49, (%a1)+       | I

move.b #0x44, (%a1)+       | D

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

 

move.l #KEY_BASE, %a1

move.b #0x49, (%a1)+       | I

move.b #0x43, (%a1)+      | C

move.b #0x49, (%a1)+      | I

move.b #0x44, (%a1)+      | D

move.b #0x53, (%a1)+      | S

 

move.l #ICID_BASE, %a1

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

move.b #0x49, (%a1)+       | I

move.b #0x43, (%a1)+      | C

move.b #0x49, (%a1)+      | I

move.b #0x44, (%a1)+      | D

move.b #0x53, (%a1)+      | S

move.b #0x20, (%a1)+       | SPACE

move.b #0x53, (%a1)+      | S

move.b #0x45, (%a1)+      | E

move.b #0x43, (%a1)+      | C

move.b #0x55, (%a1)+      | U

move.b #0x52, (%a1)+      | R

move.b #0x49, (%a1)+      | I

move.b #0x54, (%a1)+      | T

move.b #0x59, (%a1)+      | Y

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

 

move.l #SYSTEMDIS_BASE, %a1

move.b #0x53, (%a1)+       | S

move.b #0x59, (%a1)+      | Y

move.b #0x53, (%a1)+      | S

move.b #0x54, (%a1)+      | T

move.b #0x45, (%a1)+      | E

move.b #0x4D, (%a1)+       | M

move.b #0x20, (%a1)+      | SPACE

move.b #0x44, (%a1)+      | D

move.b #0x49, (%a1)+      | I

move.b #0x53, (%a1)+      | S

move.b #0x41, (%a1)+      | A

move.b #0x52, (%a1)+      | R

move.b #0x4D, (%a1)+      | M

move.b #0x45, (%a1)+      | E

move.b #0x44, (%a1)+      | D

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

 

move.l #CODE_BASE, %a1

move.b #0x43, (%a1)+       | C

move.b #0x4F, (%a1)+      | O

move.b #0x44, (%a1)+      | D

move.b #0x45, (%a1)+      | E

move.b #0x3A, (%a1)+      | :

 

move.l #SYSTEMARM_BASE, %a1

move.b #0x53, (%a1)+       | S

move.b #0x59, (%a1)+      | Y

move.b #0x53, (%a1)+      | S

move.b #0x54, (%a1)+      | T

move.b #0x45, (%a1)+      | E

move.b #0x4D, (%a1)+       | M

move.b #0x20, (%a1)+      | SPACE

move.b #0x41, (%a1)+      | A

move.b #0x52, (%a1)+      | R

move.b #0x4D, (%a1)+      | M

move.b #0x45, (%a1)+      | E

move.b #0x44, (%a1)+      | D

move.b #0x0A, (%a1)+      | CR

move.b #0x0D, (%a1)+      | LF

 

move.w #0xFF00, %D0       | Activate [7:0] parallel pins

move.w %D0, PAR

 

move.w #0x000F, %d0      | parallel pins [3:0] are output, [7:4] are input

move.w %d0, PADDR

 

move.w #0x0000, %d0      | reset all parallel signals, alarm disabled...

move.w %d0, PADAT

 

clr.l %d6

move.w #0x00F0, %d6       | D6 will be the enabler mask (00=Disabled or F0=Enabled)

 

| START ACTUAL CODE!!!

|||||||||||||||||||||||||||||||||||||||||||||||||

 

main_loop:

      | Output ICIDS SECURITY string

      move.w #ICID_BASE, %a3

      clr.l %d2

      move.w #ICID_LENGTH, %d2

      bsr out_string

 

monitor_loop:

      move.w #TEMP_BASE, %a4         | Init base address

      clr.l %d4  

     

      move.w #CODE_BASE, %a3         | Output CODE:

      clr.l %d2

      move.w #CODE_LENGTH, %d2

      bsr out_string

 

code_loop:

      move.l #0x0014, %d0            | Use key_present trap 15 function

      trap #15

 

      cmp.l #0x00, %d0        | if d0 is zero, no key present, so jump to end...

      beq end_loop

     

      move.l #0x0010, %d0            | if there's a key present, get it and store it in d1

      trap #15

 

      cmp.l #0x000d, %d1            | Is it a CR?

      bne next

      move.b #0x0a, %d1      

      move.b #0x0013, %d0

      trap #15

      move.b #0x0d, %d1      

      move.b #0x0013, %d0

      trap #15

      bsr check_code

     

      cmp.l #0x00, %d5        | result from check_code is in d5

      beq jump_over

 

| Start toggle enabled...

      move.w PADAT, %d3        | get current PADAT value

      and.l      #0x0008, %d3            | isolate ENABLE signal

      beq not_enabled

enabled:

      | The alarm is enabled, disable and shut off alarm (if on)

      move.w PADAT, %d3

      and.l #0xFFF3, %d3                  | Will only turn PP[3:2] to low

      move.w %d3, PADAT

 

      move.w #SYSTEMDIS_BASE, %a3          | SYSTEM DISARMED

      clr.l %d2

      move.w #SYSTEMDIS_LENGTH, %d2

      bsr out_string 

      bra jump_over

not_enabled:

      | Alarm not enabled, so just enable it...

      move.w #0x0008, %d3

      move.w %d3, PADAT

      move.w #SYSTEMARM_BASE, %a3          | SYSTEM DISARMED

      clr.l %d2

      move.w #SYSTEMARM_LENGTH, %d2

      bsr out_string 

 

jump_over:

      | Reset temp stuff

      move.w #TEMP_BASE, %a4         | Init base address

      clr.l %d4  

 

      move.w #CODE_BASE, %a3         | Output CODE:

      clr.l %d2

      move.w #CODE_LENGTH, %d2

      bsr out_string

      bra end_loop

next:

      move.b %d1, (%a4)+

      addq.l #1, %d4

      move.l %d4, TEMP_LENGTH       | update length of temp code...

      move.b #0x2a, %d1       | Output * for visual confirmation

      move.b #0x0013, %d0

      trap #15

end_loop:

 

      || MONITOR DETECTION UNIT HERE!!!

      clr.l %d1                     | Get the current state of the input and apply the mask to it...

      move.w PADAT, %d1

      and.l #0x08, %d1              | Check to see if the alarm is enabled...

      beq finish                        | alarm not armed... who cares if there's an intruder

 

      move.w PADAT, %d1

      and.l #0xF0, %d1              | Check to see if the alarm is enabled...

      beq finish                        | alarm not armed... who cares if there's an intruder

     

      || START ALARM!!!!!!!!!!!!!

      clr.l %d3        

      move.w PADAT, %d3       

      or.l #0x0004, %d3

      move.w %d3, PADAT

finish:

bra code_loop  

 

|| NEVER HIT!!!

exit:

move.l #0x0000, %d0

trap #15

 

|||||||||||||||||||||||||||||||||||||||||||||||

|| END MAIN ALARM CODE

 

|| Start "Functions"

 

out_string:

      out_loop:

      move.b (%a3)+, %d1

      move.b #0x0013, %d0

      trap #15

      subq.l #1, %d2

      bgt out_loop

rts

 

check_code:

      move.l TEMP_LENGTH, %d0

      move.l #TEMP_BASE, %a1

      move.l #KEY_LENGTH, %d1

      move.l #KEY_BASE, %a2

 

      cmp.l %d0, %d1                | For the strings to be equal, the lengths must be equal

      bne check_fail

 

check_loop:

      clr.l %d2

      clr.l %d3

      move.b (%a1)+, %d2

      move.b (%a2)+, %d3

      cmp.l %d2, %d3

      bne check_fail

      subq.l #1, %d0

      bgt check_loop

      bra check_success

 

check_fail:

      move.l #0x00, %d5

      move.w #CODEINV_BASE, %a3            | Output CODE:

      clr.l %d2

      move.w #CODEINV_LENGTH, %d2

      bsr out_string

rts

 

check_success:

      move.l #0x0F, %d5        | Codes match, toggle alarm enable     

rts