Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: Graphics Message-ID: <292.UUL1.3#5129@willett.UUCP> Date: 19 Jan 90 23:18:46 GMT Organization: Latest Link in ForthNet Chain (Pittsburgh, PA) Lines: 67 Date: 01-17-90 (23:48) Number: 1716 (Echo) To: MARK SMILEY Refer#: 1710 From: MIKE SPERL Read: NO Subj: GRAPHICS Status: PUBLIC MESSAGE Mark, > LABEL DODEFER ( addr -- ) <-- expects a number on TOS old diagram; should be ( -- ) if my suggestion is adopted. > MOV BX, AX <-- what's in AX? see discussion below > MOV AX,3 [BX] > JMP AX END-CODE <-- how was addr used? it wasn't there to be used, actually. My one track mind neglected to change the stack diagram when pasting it into the last message; the new one is just ( -- ). Lets look at the senario of a word calling a deferred word. defer mark : t1 ." I'm Mark." cr ; ' t1 is mark : t2 ." I'm testing mark, and " mark ; \ run T2 then ' mark 1 dump (dump cfa's in code space) 81fa = mark 81ff = t1 8204 = t2 UMMMMMMMMMQMMMMMMMMMMMMMMMQMMMMMMMMMMMMMMMQMMMMMMMMMMMMMMMM 3 SEG:OFF 3 A B C D E3 F 0 1 2 33 4 5 6 7 8 FMMMMMMMMMXMMMMMMMMMMMMMMMXMMMMMMMMMMMMMMMXMMMMMMMMMMMMMMMM 34BDF:81FA3 E8 7B 81 FF 813 E9 57 80 C9 143 E9 52 80 CA 14 TMMMMMMMMMOMMMMMMMMMMMMMMMOMMMMMMMMMMMMMMMOMMMMMMMMMMMMMMMM cfa of mark cfa of t1 cfa of t2 E8 7B 81 == CALL DODEFER (call $0398, you can set a breakpoint at 081fa in D86 to see it work) 81FF is placed on the stack by CALL as the "return address", explaining the PRESENT stack diagram. Notice that it is the address of T1, the word that will be run by DODEFER. This is the same trick used in F-PC by VARIABLE to push the address of its body. Now, to NEXT. NEXT does ES: LODSW to get the cfa from list space into ax, and jumps to the code with JMP AX. In the deferred word, the code jumped to is CALL DODEFER, compiled in MARK by DEFER. The CALL places the address of the calling word's body on the stack (it thinks we'll return, and that's where the next instruction should be). AX isn't changed, so the cfa of the deferred word is still in ax when DODEFER runs; my suggestion is simply to move it to bx and MOV AX, 3 [BX] (which takes the same number of clocks as the present MOV AX, 0 [BX]) thus saving the overhead of a CALL and POP, which will make the whole process twice as fast. For this to work properly DEFER also must be modified as was indicated previously to change the CALL compiled in the deferred word by DEFER to JMP (or the stack will accumulate all those return addresses!). Clear as mud? Use D86 to step through it. Setting a breakpoint at $0398 reveals the remarkable number of deferred words in the keyboard input loop - almost twenty in F-PC. - Mike - ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'