Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: for us beginners? Help Message-ID: <2090.UUL1.3#5129@willett.pgh.pa.us> Date: 11 Dec 90 02:57:39 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 50 Category 2, Topic 5 Message 170 Sun Dec 09, 1990 D.RUFFER [Dennis] at 23:10 EST Re: DALE SMITH > What's the best way to code things like xfer protocols that have > goto's jumping from a case inside a while loop to some things > back before the loop started? Or go to one of several error > exits? There is lots of stuff like that in the sz/rz programs. Ah, glad to see someone else is going to try to tackle the zmodem protocol. I've tried, and gave up half way in the middle. Well, I didn't actually give up, I still have the code, but I haven't had time to ever finish it. In the process of trying to code Chuck Forsberg's C code (not the most structured stuff that I ever saw), I wrote up the following: ( Simple GOTO in Forth ) CODE @R ( - a P: Fetch return stack pointer ) R PUSH NEXT CODE !R ( a - P: Store return stack pointer ) R POP NEXT : LABEL ( name \ - P: Define a label to goto ) 2VARIABLE ;CODE R 1 CELLS W) MOV I 2 CELLS W) MOV NEXT : goto ( - P: Return to the label that is compiled next ) R> @ ( cfa of label ) CELL+ 2@ !R >R ; : exit ( - P: Exit from where label is used ) R> @ ( cfa of label ) CELL+ @ !R ; EXIT LABEL loop ( - P: Looping label for test ) : test ( n - P: A test for these features ) loop DUP . 1- ?DUP IF goto loop THEN exit loop 1 ABORT" Didn't work" ; It is written for polyFORTH, but might be able to be translated to something else. In pF assembler code, R is the return stack pointer register and W points to the CFA of the word being executed. This allowed me to get close. I was building it on top of my PFMODEM stuff that is in the library. Let me know if you want some incomplete source code, and I will upload it. However, it sure isn't anywhere close to being something that works yet. I don't even think I ever got the transfer side of it coded, but you are welcome to whatever I've got. Hope to see what you can come up with. DaR ----- This message came from GEnie via willett through a semi-automated process. Report problems to: dwp@willett.pgh.pa.us or uunet!willett!dwp