       Idnt    _Val
       Section _Str2Int,Code
       Xdef    Str2Int

	; String nach Integer
	; Stand 10-Jun-93
	;        angepaßt an MINI-Comp
	;       12-Jun-93
	;        Fehler in der Adressbrechnung,A5 Benutzung entfernt
	; RTS.l String


Str2Int:MOVEA.L (A7)+,A3            	; Rts
        Moveq   #0,d2
        move.b  (a7),d2			; Länge des Strings
        Moveq   #0,D6			; Vorzeichen (0=+,-1=-)
        Moveq   #0,D1
        MOVEA.L A7,A4			; Zeiger auf akt. Zeichen
	Move.l	a7,a6		
	adda.l  #256,a6			; = Bereinigter Stack
	Addq.l  #1,a4			; Längenbyte ignorieren
S2Iloop:BSR.S   Gnc			; Zeichen holen
        CMP.B   #$20,D0			; Space(s) am Anfang ignorieren
        BEQ.S   S2Iloop
        CMP.B   #$2B,D0			; '+' ?
        BNE.S   S2Iw1			; Nein 
        BSR.S   Gnc			; Nächstes Zeichen
        BRA.S   S2Iw2
S2Iw1:  CMP.B   #$2D,D0			; '-' 
        BNE.S   S2Iw2
        MOVEQ   #-1,D6			; Negativer Wert
        BSR.S   Gnc
S2Iw2:  CMP.B   #$30,D0			; Zeichen <'0'
        BMI.S   S2Iexit			; Ja -> Abbruch
        CMP.B   #$3A,D0			; Zeichen >'9'
        BPL.S   S2Iexit			; Ja -> Abbruch
        ASL.L   #1,D1			; Mal 10
        MOVE.L  D1,D5
        ASL.L   #2,D1
        ADD.L   D5,D1
        ADD.L   D0,D1			; Dazu neuen Wert
        SUB.L   #$30,D1			; Minus Wert Zeichen '0'
        BSR.S   Gnc
        BRA.S   S2Iw2
S2Iexit:Move.l  a6,a7			; Weg mit String
        TST.B   D6			; Negativer Wert ?
        BEQ.S   S2Iweit
        NEG.L   D1			; ja, negieren
S2Iweit:MOVE.L  D1,-(A7)
        Jmp	(a3)
Gnc:    CLR.L   D0
        MOVE.B  (A4)+,D0
        CMP.B   #$20,D0
        BEQ.S   S2Irts
        CMP.B   #$2B,D0
 BEQ.S S2Irts
 CMP.B #$2D,D0
 BEQ.S S2Irts
 CMP.B #$30,D0
 BMI.S S2Iexit
        CMP.B  #$3A,D0
        BPL.S  S2Iexit
S2Irts: SUBQ.W #1,D2
        BMI.S  S2Iexit
        RTS

