The main program
Below is the main program segment. It makes use of the new .IMPRT directive on the modified comiler to import the other module files. A summary of the modules that make up the project is found here.
Download:
; ///////////////////////////////////////////////////////////
; // Security system main program segment
; // (c) 1999 Geoff Knagge, Andrew Carr, Mark Lynn
; // last modified : 22/10/1999
; //
; ///////////////////////////////////////////////////////////
.imprt "modules.asm" ; imports modules and defines
; start address. Program entry
; point must immediately follow.
mvi a,st_main
mvi c,sc_intro
call ww_set
mvi a,0FF ; unlock all doors
sta sd_lock
call sd_rst ; set door out stats
call ala_on ; enable alarm system
mvi a,0
sta smokestat ; enable smoke alarm
sta tq ; clear alarm queue
sta tq1 ; clear alarm queue
sta tq2 ; clear alarm queue
sta tq3 ; clear alarm queue
sta tq4 ; clear alarm queue
sta tq5 ; clear alarm queue
sta ub_panic ; clear Uart print queue
sta ub_smoke ; clear Uart print queue
sta ub_windows ; clear Uart print queue
sta ub_doors ; clear Uart print queue
sta ub_edoors ; clear Uart print queue
sta u_active
lxi hl,u_nomsg
shld u_message
MainLoop:
lda alar_stat
cpi 00
jnz MaiL1
call ChkaArm
call ChkAlarms
MaiL1:
lxi HL,modecode ; point HL to the status code
mov c,m ; load it into C
lxi HL,jumptable; point HL to the jump table
mvi b,0 ; BC = status code
dad bc
dad bc ; HL = HL + 2 * BC
mov e,m ; E = LSB of jump address
inx hl
mov d,m ; D = MSB of jump address
lxi hl,callmode ; point HL to the call instruction
inx hl ; skip the jump instruction
mov m,e ; store the LSB
inx hl ; next byte
mov m,d ; store the MSB
callmode:
call dummyproc
jmp mainloop
;///////////////////////////
dummyproc:
mvi A,1;
lxi HL,modecode
mov m,a
ret;
;//////////////////////////
.imprt "data.asm"
.END
; ///////////////////////////////////////////////////////////
; // Security program common code segment
; // (c) 1999 Geoff Knagge, Andrew Carr, Mark Lynn
; // last modified : 22/10/1999
; //
; // This module imports and initialises the modules used by
; // the main program, and all the test modules. This module
; // should be imported at the start, and the program entry
; // point should immediately follow. This module does not
; // import a data module, so that needs to be done
; // separately.
; //
; ///////////////////////////////////////////////////////////
.=8000
DI
jmp progstrt; // IRQ 0 - unconnected
nop; // irq1
jmp inthandler;
nop ; // irq2 - lcd
jmp lcd_interrupt;
nop;
jmp u_interrupt;// iq3 - uart controller
ProgInit:
call c_refresh
call io_init
call LCD_init
call initTimers
call u_init
call initInterrupts
call ala_on
ei
ret
modecode: .byte 0;
.imprt 'io.asm'
.imprt 'jumptable.asm'
.imprt 'modes.asm'
.imprt 'lcd.asm'
.imprt 'interrupts.asm'
.imprt 'nukeys.asm'
.imprt 'timers.asm'
.imprt 'passwords.asm'
.imprt 'passwordsin.asm'
.imprt 'security.asm'
.imprt 'alarms.asm'
.imprt 'uart.asm'
progstrt:
call ProgInit
|