; ==== ISUAL Flight Software -- Univ of California, Berkeley, SSL ==== ; DPU.a -- main startup module ; ; Includes Restart, DPU_RUN, Utility Functions (UTIL.I) ; ; Revision History: ; 18-Dec-2002 - SPG - ISUAL Flight Software rev 7.3 ; First Official Release include ioports.i include util.i ; === this is at address 0000 -- power-on restart ; copy PROM code into RAM, then switch from PROM to RAM PROM_START: ; when starting in PROM, a store into 0000-3FFF goes into ; underlying RAM lxi h,44h ; start after RST vectors cpylp: mov a,M ; read PROM mov M,a ; write RAM inx h mov a,h cpi 40h ; 4000h is after 3FFF jnz cpylp ; ; the PROM switchoff has to execute outside of PROM space ; copy a little bit of code up to 8000 lxi d,8000h lxi h,switchcode mvi c,eswc-switchcode cpys: mov a,M stax d inx d inx h dcr c jnz cpys ; execute at 8000h jmp 8000h switchcode: mvi a,0 out PROM_ENBL_O ; switch to RAM nop ; wait at least 2 microsecs nop nop jmp base ; start running eswc: ds 1Ch ; ====this should be 0045, after the restart vector area=== ; ; code to copy new program from EEPROM ; (ioport 02h has previously been set with Bank) public DPU_RUN DPU_RUN: di ; no interrupts allowed lxi h,base ; HL=past PROM_START etc. which does not change mov e,l mvi d,40h ; DE now has same offset into 4000h-block kopy: ldax d ; copy from EEPROM mov M,a ; to RAM out WATCHDOG_PET_O ; restart WATCHDOG timeout inx h inx d mov a,d cpi 80h ; past top of Bank window? jnz kopy ; not yet ; copy complete -- continue, executing new program ; ======= ; from 0000 down to here, ; the code should remain unchanged from Rev to Rev public main base: jmp main ; (in BGLOOP.a) ; Common utility subroutines ; ; this copy subroutine is used by several classes ; note: no registers saved; ; HL and DE are returned incremented by (C) ; ; Copy (C) bytes from [HL] to [DE] COPY_BYTES: cpyl: mov a,M stax d inx h inx d dcr c jnz cpyl ; return DE and HL altered; C=0 ret ; ; 16-bit subtract ; SUBTRACT [HL] = [HL] - [DE] SUB16 push psw MOV A,L SUB E MOV L,A MOV A,H SBB D MOV H,A pop psw RET ; ; wait at least 1 millisecond WAIT_1MS: push psw mvi a,70 ; out WATCHDOG_PET_O WL1: dcr a jnz wl1 mvi a,70 WL2: dcr a jnz wl2 pop psw ret ; ; subroutine to increment a Big-Endian word ; HL - points to word INCBIG: push d push h mov d,M ; D = high byte inx h mov e,M ; E = low byte inx d ; increment the word in DE mov M,e ; store low byte pop h ; get original pointer mov M,d ; store high byte pop d ret ; ; subroutine to decrement a Big-Endian word ; HL - points to word DECBIG: push d push h mov d,M ; D = high byte inx h mov e,M ; E = low byte dcx d ; decrement the word in DE mov M,e ; store low byte pop h ; get original pointer mov M,d ; store high byte pop d ret