this ALLDEFS1
Filter:
this.setName('Snippets1')
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bind 'this' to selection
Inspector on: lively.morphic.Window
X

Menu
ALTO Smalltalk-72
X

Menu
Step
Run
Lively-Web NOVA Emulator
Stop
20400: 651 JMP .-127; 020251 20401: 6160 p JSR @160; 010242 20402: 40751A STA 0,.-27; 020353 20403: 22056$. LDA 0,@56; 0124145 20404: 111000 MOV 0,2 20405: 20746! LDA 0,.-32; 020353 20406: 64451i) JSRII .+51; 021133 20407: 666 JMP .-112; 020275 20410: 4755 JSR .-23; 020365 20411: 105004 MOV 0,1,SZR 20412: 64446i& JSRII .+46; 020645 20413: 660 JMP .-120; 020273 20414: 64445i% JSRII .+45; 021600 20415: 6144 d JSR @144; 05453 20416: 655 JMP .-123; 020273 20417: 4741 JSR .-37; 020360 20420: 100513 K NEGLN 0,0,SNC 20421: 652 JMP .-126; 020273 20422: 64427i JSRII .+27; 020747 20423: 42731E STA 0,@.-47; 0400 20424: 10730 ISZ .-50; 020354 20425: 14726 DSZ .-52; 020353 20426: 774 JMP .-4; 020422 20427: 644 JMP .-134; 020273 20430: 4730 JSR .-50; 020360 20431: 100513 K NEGLN 0,0,SNC 20432: 641 JMP .-137; 020273 20433: 22721% LDA 0,@.-57; 0400 20434: 64416i JSRII .+16; 021064 20435: 10717 ISZ .-61; 020354 20436: 14715 DSZ .-63; 020353 20437: 774 JMP .-4; 020433 20440: 633 JMP .-145; 020273 20441: 20300 LDA 0,300; 0300 20442: 7234 JSR @-144,2 20443: 7233 JSR @-145,2 20444: 7237 JSR @-141,2 20445: 7226 JSR @-152,2 20446: 7227 JSR @-151,2 20447: 7236 JSR @-142,2 20450: 7235 JSR @-143,2 20451: 7217 JSR @-161,2 20452: 7221 JSR @-157,2 20453: 7232 JSR @-146,2 20454: 7223 JSR @-155,2 20455: 7230 JSR @-150,2 20456: 7220 JSR @-160,2 20457: 7222 JSR @-156,2 20460: 7215 JSR @-163,2 20461: 7224 JSR @-154,2 20462: 7213 JSR @-165,2 20463: 7214 JSR @-164,2 20464: 7214 JSR @-164,2 20465: 452 * JMP .+52; 020537 INOUT: 20466: 6201 JSR @201; 024141 20467: 21 JMP 21; 021 20470: 105000 MOV 0,1 20471: 6201 JSR @201; 024141 20472: 11 JMP 11; 011 20473: 64771i JSRII .-7; 027523 =OUTLD 20474: 101000 MOV 0,0 20475: 126460 0 SUBC 1,1 20476: 46767M STA 1,@.-11; 0452 20477: 61001b EIR 20500: 101015 MOVN 0,0,SNR 20501: 2170 x JMP @170; 01443 =RFALSE 20502: 2156 n JMP @156; 07667 =EVAL 20503: 1 JMP 1; 01 20504: 404 JMP .+4; 020510 20505: 1 JMP 1; 01 20506: 0 JMP 0; 00 20507: 20250 LDA 0,250; 0250 20510: 0 JMP 0; 00 20511: 0 JMP 0; 00 20512: 0 JMP 0; 00 20513: 0 JMP 0; 00 20514: 0 JMP 0; 00 20515: 0 JMP 0; 00 20516: 0 JMP 0; 00 20517: 0 JMP 0; 00 20520: 0 JMP 0; 00 20521: 0 JMP 0; 00 20522: 0 JMP 0; 00 20523: 0 JMP 0; 00 20524: 0 JMP 0; 00 20525: 0 JMP 0; 00 20526: 0 JMP 0; 00 20527: 0 JMP 0; 00 20530: 0 JMP 0; 00 20531: 0 JMP 0; 00 20532: 0 JMP 0; 00 20533: 0 JMP 0; 00 20534: 177777 ANDCSN 3,3,SBN 20535: 6731 JSR @.-47; 06201 20536: 374 JMP 374; 0374 20537: 54521YQ STA 3,.+121; 020660 20540: 22775% LDA 0,@.-3; 06731 20541: 24775) LDA 1,.-3; 020536 20542: 123000 ADD 1,0 20543: 4401 JSR .+1; 020544 20544: 162400 SUB 3,0 20545: 40403A STA 0,.+3; 020550 20546: 4422 JSR .+22; 020570 20547: 377 JMP 377; 0377 20550: 0 JMP 0; 00 20551: 177400 AND 3,3 20552: 22763% LDA 0,@.-15; 06731 20553: 2505 E JMP @.+105; 022732 20554: 54504YD STA 3,.+104; 020660 20555: 22760% LDA 0,@.-20; 06731 20556: 24760) LDA 1,.-20; 020536 20557: 123000 ADD 1,0 20560: 4401 JSR .+1; 020561 20561: 162400 SUB 3,0 20562: 40403A STA 0,.+3; 020565 20563: 4441 ! JSR .+41; 020624 20564: 377 JMP 377; 0377 20565: 165472 : INCCN 3,1,SZC 20566: 177400 AND 3,3 20567: 2471 9 JMP @.+71; 022732 20570: 54451Y) STA 3,.+51; 020641 20571: 4417 JSR .+17; 020610 20572: 6065 5 JSR @65; 023623 =LOAD 20573: 42445E% STA 0,@.+45; 022625 20574: 434 JMP .+34; 020630 20575: 54444Y$ STA 3,.+44; 020641 20576: 4412 JSR .+12; 020610 20577: 6065 5 JSR @65; 023623 =LOAD 20600: 6163 s JSR @163; 05522 20601: 42437E STA 0,@.+37; 022625 20602: 426 JMP .+26; 020630 20603: 54436Y STA 3,.+36; 020641 20604: 4404 JSR .+4; 020610 20605: 22433% LDA 0,@.+33; 022625 20606: 4457 / JSR .+57; 020665 20607: 421 JMP .+21; 020630 20610: 50451Q) STA 2,.+51; 020661 20611: 54431Y STA 3,.+31; 020642 20612: 344279 LDA 3,.+27; 020641 20613: 25400+ LDA 1,0,3 20614: 147000 ADD 2,1 20615: 44427I STA 1,.+27; 020644 20616: 21401# LDA 0,1,3 20617: 163000 ADD 3,0 20620: 40420A STA 0,.+20; 020640 20621: 21402# LDA 0,2,3 20622: 40421A STA 0,.+21; 020643 20623: 2417 JMP @.+17; 020605 20624: 54415Y STA 3,.+15; 020641 20625: 4763 JSR .-15; 020610 20626: 22412% LDA 0,@.+12; 022625 20627: 6067 7 JSR @67; 023630 20630: 14410 DSZ .+10; 020640 20631: 14413 DSZ .+13; 020644 20632: 24412) LDA 1,.+12; 020644 20633: 10410 ISZ .+10; 020643 20634: 2406 JMP @.+6; 020605 20635: 304241 LDA 2,.+24; 020661 20636: 344039 LDA 3,.+3; 020641 20637: 1403 JMP 3,3 20640: 22625% LDA 0,@.-153; 0452 20641: 23023& LDA 0,@23,2 20642: 20605! LDA 0,.-173; 020447 20643: 0 JMP 0; 00 20644: 40177@ STA 0,177; 0177 20645: 54413Y STA 3,.+13; 020660 20646: 40774A STA 0,.-4; 020642 20647: 44774I STA 1,.-4; 020643 20650: 6203 JSR @203; 024072 20651: 7 JMP 7; 07 20652: 24771) LDA 1,.-7; 020643 20653: 123000 ADD 1,0 20654: 6176 ~ JSR @176; 024111 20655: 7 JMP 7; 07 20656: 20764! LDA 0,.-14; 020642 20657: 2401 JMP @.+1; 022732 20660: 22732% LDA 0,@.-46; 034427 20661: 40172@z STA 0,172; 0172 20662: 20607! LDA 0,.-171; 020471 20663: 11674 ISZ -104,3 20664: 5026 JSR 26,2 20665: 44776I STA 1,.-2; 020663 20666: 54774Y STA 3,.-4; 020662 20667: 6171 y JSR @171; 05565 20670: 40774A STA 0,.-4; 020664 20671: 24772) LDA 1,.-6; 020663 20672: 6065 5 JSR @65; 023623 =LOAD 20673: 40770A STA 0,.-10; 020663 20674: 20770! LDA 0,.-10; 020664 20675: 6067 7 JSR @67; 023630 20676: 20765! LDA 0,.-13; 020663 20677: 6165 u JSR @165; 011352 20700: 307611 LDA 2,.-17; 020661 20701: 2761 JMP @.-17; 020607 20702: 54756Y STA 3,.-22; 020660 20703: 40737A STA 0,.-41; 020642 20704: 6203 JSR @203; 024072 20705: 7 JMP 7; 07 20706: 101213 MOVRN 0,0,SNC 20707: 747 JMP .-31; 020656 20710: 101400 INC 0,0 20711: 743 JMP .-35; 020654 20712: 54546Yf STA 3,.+146; 021060 20713: 24131(Y LDA 1,131; 0131 20714: 147000 ADD 2,1 20715: 6065 5 JSR @65; 023623 =LOAD 20716: 40427A STA 0,.+27; 020745 20717: 6203 JSR @203; 024072 20720: 7 JMP 7; 07 20721: 101112 J MOVLN 0,0,SZC 20722: 412 JMP .+12; 020734 20723: 40421A STA 0,.+21; 020744 20724: 101001 MOV 0,0,SKP 20725: 54533Y[ STA 3,.+133; 021060 20726: 6203 JSR @203; 024072 20727: 15 JMP 15; 015 20730: 24414) LDA 1,.+14; 020744 20731: 122133 [ ADCZLN 1,0,SNC 20732: 406 JMP .+6; 020740 20733: 121000 MOV 1,0 20734: 126000 ADC 1,1 20735: 64445i% JSRII .+45; 022463 20736: 2522 R JMP @.+122; 020755 20737: 44405I STA 1,.+5; 020744 20740: 121400 INC 1,0 20741: 6176 ~ JSR @176; 024111 20742: 7 JMP 7; 07 20743: 6204 JSR @204; 04622 20744: 660 JMP .-120; 020624 20745: 37570?x LDA 3,@170,3 20746: 2512 J JMP @.+112; 020755 20747: 54512YJ STA 3,.+112; 021061 20750: 4732 JSR .-46; 020702 20751: 4741 JSR .-37; 020712 20752: 101300 MOVS 0,0 20753: 40510AH STA 0,.+110; 021063 20754: 4751 JSR .-27; 020725 20755: 24506)F LDA 1,.+106; 021063 20756: 123000 ADD 1,0 20757: 2502 B JMP @.+102; 022120 20760: 54501YA STA 3,.+101; 021061 20761: 40415A STA 0,.+15; 020776 20762: 105400 INC 0,1 20763: 6065 5 JSR @65; 023623 =LOAD 20764: 100513 K NEGLN 0,0,SNC 20765: 2474 < JMP @.+74; 022120 20766: 40475A= STA 0,.+75; 021063 20767: 102460 0 SUBC 0,0 20770: 40405A STA 0,.+5; 020775 20771: 4721 JSR .-57; 020712 20772: 101001 MOV 0,0,SKP 20773: 4732 JSR .-46; 020725 20774: 6205 JSR @205; 04643 20775: 6242 JSR @242; 00 20776: 41220B STA 0,-160,2 20777: 14464 4 DSZ .+64; 021063
this.AC0 = 1; this.AC1 = 0; this.AC2 = 034344; this.AC3 = 020474; this.PC = 020474; this.CRY = 0; // instruction# = 0
Restart
Show Nova
About Smalltalk-72
About this Emulation
About Lively Web
Open the ST-72 Manual
ALLDEFS
Keyboard Help
Snippets1
Snippets2
Snippets3
Snippets1
X

Menu
A series of snippets to reveal the spirit of Smalltalk-72. If you click twice to the right of an Alto character , it will select from there to the following do-it character , and then type that in to the Smalltalk-72 simulation here. You can type there directly of course, ending with a backslash for do-it. If you get a debug window, type 'done\' (five characters, no quotes) directly into the St-72 window. typing esc will restart the evaluator. For a complete restart, press Show-Nova, Restart, Show-Smalltalk [Need one simple button for this]. Note: there is a bug in this emulation: kbd is defined as to kbd (!kmap[TTY]) but kmap[19] = 5 so references to character 19 ('s) get perverted. This would be easy to fix except that, even if you change the table entry, it gets changed back :-(. The following is a workaround for it. So click after the Alto character and make a live repair :-)... to kbd c ("c _ TTY. c = 19?(!19) !kmap[c]) [Let's build this into restart if we don't find the bug first] Now have a seat and we'll take a look at Smalltalk-72... 3+4 We always typed this as our first evaluation after a new build. It tests a lot of the system including how to read from keyboard, build and eval vectors (more later) and print to the display. For a first-timer, this is a chance to explain that this sequence means: start with the 3, and pass it the message +4, something that 3 understands and can return an appropriate result. After the do-it character we print the result and invite more input. 355.0/113 This second test runs floating-point and the floating point print routine, a mass of St-72 code. At this point we could be sure things were working right. @ go 50We are introduced to 'Smiley' the resident turtle object (typed as an at-sign). Yay a line appears on the screen. @ turn 90 go 50 We talk about turtles and how they have state such as location and direction. This tells Smiley to turn before drawing another line. do 4 (@ go 50 turn 90) Here we have a chance to talk about how we left her at the end of a line so she started this square away from the center. do 4 (@ go 100 turn 90) Bigger is better and here is a chance to talk through why this square is where it is on the screen. We are following a loose 'turtle geometry curriculum' inspired by the work of Seymour Pappert. @ home up erase We talk about housekeeping - Smiley is in charge of the display. 'home' takes her back to the center, 'up' tells her to point upwards, and 'erase' clears the screen. At this point, some learners want to do more with geometry, some with numbers and some with 'making things'. We'll do a bit with each and then go on to explore how this whole system works. After the above examples, it's natural to want to make squares of all sizes, and to we learn to define a new function. Here we follow the Logo use of the English defining word 'to' as follows: to square size (:size. do 4 (@ go size turn 90)) This is our first function definition. It declares the name, 'square' and a temporary variable, 'size', followed y code in parentheses. The code begins with a construct read as 'fetch size' which will read a value from the following message stream, and bind it to the variable, size, that then becomes the input value to '@ go' inside the loop. Parentheses are used to indicate code structure both for the body of 'square', and the code to be repeated by 'do'. square 20square 40. square 60. square 80 It is exciting to see things happen on the screen, and more is better. We introduce a more powerful iterator... for i to 200 by 10 (square i) The induction variable offers a new dimension of experiments. @ home up erase. for i to 200 by 2 (@ go i turn 60) We are now exploring geometry in a very creative way. Polygons, inside angles, outside angles, etc. We make one more tool before going on to other things. Here is an exercise in variable bindings being passed among levels... to spiral angle n d ((:angle. :n. :d. for i to n by d (@ go i turn angle))) Here three parameters are fetched from the input to 'spiral', and then used to control the iterator 'for' and the inner 'go' and 'turn' messages to Smiley. @ home erase. spiral 89 250 2@ home. spiral 91 250 2 One can see the effects of our early and simple use of the bitmap display, as the code that scrolls the text are shares the graphics area and interferes with the bottom of this design. Most early learners learn by pattern matching and rote repetition with gentle variations. It's now time to say a few words that would have interfered with our flow to this point. Let's use this Smalltalk to take a look at itself... show for to for token step stop var start exp (:"var. (%_?(:start.) "start_1). (%to?(:stop.) "stop_start). (%by?(:step.) "step_1). %do. :#exp. CODE 24) : is a primitive function that fetches values from the message stream, and it is seen here in three variants. The first, ':"var' (read 'fetch-quote') fetches the very token that is next in the message, the atom 'i' in our examples, and binds it to the temporary variable 'var'. The second, ':#exp' (read 'fetch-bind') also fetches the next token in the stream which in our examples is an embedded literal vector (array of tokens) which is the basic form of all St-72 code. The one difference with fetch-bind is that if the next token in the message is an atom, it will look up the value of that atom in the message context before binding the value to its argument. The final form of fetch, and the most common, appears as ':start' and others above. Simple fetch will start a new evaluation in the message stream, and bring its final value in to be bound to its variable if present. It's worth noting that all these forms of fetch may be used with no target variable, in which case they simpl return their value, presumably to be consumed in some other expression. newAtomsymbol has no value "newAtom _ 6. newAtom6 By way of explaining a few more tokens, the middle three lines mean If you see '_', then fetch a value for start, otherwise set it to 1. If you see 'to', then fetch a value for stop, otherwise set it to start. If you see 'by', then fetch a value for step, otherwise set it to 1. From this it should be apparent that '%' (read as 'peek for' or 'match') looks in the message stream for a matching token. Peek is the essence of Smalltalk-72's self-defining syntax. If the following token is found in the incoming message, then the message stream will be advanced and a value of true will be returned; if not, then false will be returned and the message stream will remain undisturbed. Note also the expression '%do.' This does what it looks like - it simply consumes the token 'do' if it is found, affording the user of 'for' the option of putting the word 'do' before the loop body for clarity. While we're here, notice how conditionals work in Smalltalk-72: an 'implies-arrow' (read as 'then') in the message stream is followed by a subvector with consequent code in it. If any value other than false precedes a 'then', evaluation proceeds in the subvector instead of continuing in the outer vector. Note that when execution hits the end of the consequent subvector, it concludes evaluation of the outer vector as well. While the vector structure is not symmetric, the subvector and continuation of the outer vector behave as two equal forks chosen by the implies arrow. Finally we come to 'CODE 24', which invokes primitive code in the Smalltalk interpreter. The code escapes in this interpreter exist partly to get things going from scratch and partly to maintain reasonable performance. So far we have seen the evaluation of simple expressions, messages sent to a 'turtle' object Smiley, and some locally parsed syntax defining a for-loop. Since we have been sending messages to Smiley, let's take a look at the turtle class to see how the class is defined whose instance we have been exercising. to turtle var : pen ink width dir xor x y frame : f ( CODE 21 '%go?(draw a line of length :. !SELF) %turn?(turn right :. !SELF) %goto?(draw a line to :x :y. !SELF)' %pendn?("pen _ 1. !SELF) %penup?("pen _ 0. !SELF) %ink?(%_. :ink. !SELF) %width?(%_. :width. !SELF) %xor?("xor _ (%off?(0) 1). !SELF) %is?(ISIT eval) %home?("x _ frame  frmwd/2. "y _ frame  frmht/2. "xf _ "yf _ 0. "dir_270. !SELF) %erase?(frame fclear. !SELF) %up?("dir _ 270. !SELF) isnew?("ink _ "black. "pen _ "width _ 1. "xor _ 0. (%frame?("frame _ :) "frame _ f) %at?(:x. :y. "dir_270) SELF home) ) The first line declares names of temporary variables, instance variables and class variables. More about this later. Notice that most turtle methods end with !SELF. This means that, not only is SELF the value returned, but that it is returned 'actively', so that if any code remains in the message stream, this instance will again try to parse and execute it (as with @ go 10 turn 90). This cascading of messages is frequently convenient for objects with such streaming behavior. Take a look at the phrase '%is?(ISIT eval)'. We can't know what this is doing without knowing what ISIT is. ISIT ( % ~ ? ( ! TITLE ) ! TITLE = :") Thus, this method provides answers regarding the type of a turtle @ is ~ turtle @ is number false This same phrase is copied into each class so that all objects can answer about their type. In situations like this, we began to feel the need for a superclass 'object' with methods inherited by all the other classes. This sharing of the global method ISIT was a weak second best. It served in this early world where instances did not have direct access to their classes, and the classes were not first-class objects (ie, with code of their own). The 'isnew' phrase of turtle is notable. isnew is a special function that allows functions to act as classes. If an existing turtle receives a message, it begins running its code with SELF set to itself in the current activation record (stack frame). However if one calls 'turtle' as a function, SELF will be nil when it reaches isnew. In this case, 'isnew' creates a new instance, binds it to SELF, and returns true, thus causing the associated initalization code to be run. If SELF is set already, then isnew returns false, and the initialization code is skipped, as it should be. Essential to the notion of 'what is a Smalltalk' is that all modes of interaction be delivered to the users in a live way. From the beginning, it was possible to read the Alto's mouse x and y positions, leading to early rewards from such one-line programs as this: @ home erase. repeat (@ goto mx my) Make sure to move your mouse in the display area. End this by pressing the escape key in the St window. [**make this work in either window] With a bit of embellishment, we have the beginnings of a paint program @ home erase. repeat (@ penup goto mx my pendn. repeat (4=mouse 4?(done) @ goto mx my)) ***doesnt work End this by pressing the escape key in the St window. Let's define a class of our own; one that should be familiar to LISPers... to cons : car cdr ( isnew?("car _ :. "cdr _ :) % car ?(% _ ? ("car _ :) !car) % cdr ?(% _ ? ("cdr _ :) !cdr) % print ?("[ print. car print. ". print. cdr print. "] print)) "a _ cons 2 5 [2.5] "b _ (a cdr _ cons 3 7) [2.[3.7]] b cdr car 3
fontfns.st
X

Menu
 to fontfns (!" (fontfns putter getwidth getheight pnt fontchar confine setup block ftedit filfont)) to putter (!dispframe 0 100 0 32 string 10 noframe) to getwidth char topfnt (:char. "topfnt _ (%font? (4 + pnt :) mem 70) + char. ! (mem topfnt + mem topfnt) / 2) to getheight (%font? (!mem 2 + pnt :) !mem(mem 70) - 2) to pnt (mem 254 _ :. !mem 254) to fontchar i j k a b : fptr wid hth fontadr : blanko blacko (%setbit? (:a. @ penup goto mx my pendn. (a = 0?(@ white) @ black). repeat (0 > "k _ disp mfindc mx my[1]?() "i _(k - 1) mod wid. "j _(k - 1) / wid. disp (@ goto frmx + 8 + i * 16 frmy + 7 + 14 * j. buf[k] _ (a = 0?(blanko) blacko)). block i j a. 0 = mouse 3?(done)). disp show) %bug?(ftedit SELF) %running?() %enter?(disp display) %exit?() %kbd?(SELF charset kbd) %charset? ("fptr _ fontadr + :. "fptr _ fptr + mem fptr. "wid _(mem fptr) &/ - 1. "hth _ 255 &* mem fptr + 1. setup) %new?(SELF charset 46) %setwidth? (disp fclear. waitnext(but1on). "wid _ confine (mx - disp frmx) / 16 0 16. mem fptr _ 1 + 2 * wid. disp frame white. setup) %setheight? (disp fclear. waitnext(but1on). "i _ ( (mem fptr + 1) &/ - 8) + (my - disp(frmy + frmht)) / 14. (i < 0? ("i _ 0)). mem fptr + 1 _ (255 &* mem fptr + 1) + i &/ 8. disp show) isnew? (mem 70 _ disp  font. mem 70 _ 4+mem 70. "fontadr _ mem 70. "blanko _ 4. "blacko _ 037. !window dispframe 16 16 16 14 string 250 noframe SELF)) to confine x y z (:x. :y. :z. x < y?(!y) x > z?(!z) !x) to setup (disp hide. disp ("frmwd _ "winwd _ wid * 16. "frmht _ "winht _ hth * 14. frame black. buf[1 to 1000] _ all blanko. "last _ wid * hth). for j _ 0 to hth - 1 ("k _ mem fptr + j - hth. disp (for i _ 0 to wid - 1 (1 = 1 &* k &/ i - 15? (buf[i + 1 + j * wid] _ blacko)))) disp show) to block i j k u v (:i. :j. "u _ fptr + j - hth. :v. "k _ 1 &/ 15 - i. mem u _ (v = 0? ((mem u) &* k &- 0 - 1) k &+ mem u)) to ftedit b c (:b. but1on? (" (() (disp hide. waitnext(but1on). disp moveto mx my. disp display) (disp hide. sched delete b. done)(b setheight)(b setwidth)) [1 + disp corner mx my] eval) 2 = mouse 2?(b setbit 1) 1 = mouse 1?(b setbit 0)) to filfont f a b (dsoff. "b _ :. (%in? (dispframe ("defont _ file b intostring. ). disp ("font _ dispframe defont). mem 70 _ disp font. mem 70 _ 4 + mem 70) %out? ("f _ file b. f _ disp font. f close)). dson. )