.pl 60 ;*************************************************************** ; ; Assembler-Include-File zur Einbindung eigener Proceduren ; in OC-BASIC-Programme ; ;*************************************************************** ;*************************************************************** ; Include-File für Assembler ;*************************************************************** .nlist .include "st904x.inc" .list .page ;*************************************************************** ; Prozedurtabelle ;*************************************************************** .org 8000h .byte 09h .ascii "PORT2INIT" .word port2init .byte 08h .ascii "CHECKPIN" .word checkpin .byte 0ffh ;*************************************************************** ; Beginn der Prozeduren ;*************************************************************** port2init:: pushu PPR spp #P3C_PG or P2C0R,#00100000b ; P2C0.5 - TTL-Pegel and P2C1R,#11011111b ; P2C2.5 - Output Tristate or P2C2R,#00000000b ; P2C2.5 - Input ld P2DR,#01100000b popu PPR ret checkpin:: pushuw rr10 pushu r0 ldw rr10,#04ffh ; Timout-Zähler ldw rr2,#0 ; Rückgabewert 0 10$: decw rr10 jrz 20$ ; 65536-mal fragen ld r0,P2DR ; Port 2 laden btjt r0.5,10$ ; solange Springen bis Bit5 = 0 ldw rr2,rr10 ; Rückgabewert 1 wenn Bit5 = 0 20$: popu r0 popuw rr10 ; Register retten ret ; Rücksprung zum Basic