;========================================================== ; ExecSwitchRoutine ; ; Exec a routine of a switch, according to the sign + or - ; ; input a0 const char *switch ; a1 table of switches to test ; a2 table of routines if the switch is prefixed with + ; a3 table of routines if the switch is prefixed with - ; a4 table of separators to find after switch ; output d0.b 0 if the switch doesn't exist ; destroy d0/a0 ;========================================================== butillib@0008: movem.l d1-d2/a1-a3,-(sp) cmpi.b #'-',(a0) ; Check and skip the sign beq.s \Minus \NoMinus: cmpi.b #'+',(a0) beq.s \Plus \Fail2: moveq.l #-1,d0 bra.s \Fail \Plus: movea.l a2,a3 ; Fix routine adress \Minus: move.l a3,d0 ; Is there a table for this sign ? beq.s \Fail2 addq.l #1,a0 ; Skip sign pea (a3) ; Save it movea.l a0,a2 ; RefString movea.l a1,a0 ; StringTable movea.l a4,a1 ; SeparatorTable suba.l a3,a3 ; NextChar bsr butillib::CompareStrings movea.l (sp)+,a0 ; Routine to execute \Fail: movem.l (sp)+,d1-d2/a1-a3 ; Restore regs tst.w d0 ; Item found ? bpl.s \ItemFound ; Yes moveq.l #0,d0 ; Else return an error rts ; And quit \ItemFound: add.w d0,d0 ; Table of words move.w 0(a0,d0.w),d0 ; Read offset jsr 0(a0,d0.w) ; Jump to the right offset moveq.l #1,d0 ; Return value rts ; Quit