papierkorb:sample4.blk
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| papierkorb:sample4.blk [2025-08-16 17:50] – ↷ Seite von projects:sample4.blk nach papierkorb:sample4.blk verschoben mka | papierkorb:sample4.blk [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | === EXAMPLES FOR LECTURE #4 === | ||
| - | < | ||
| - | Screen 0 not modified | ||
| - | 0 \ EXAMPLES FOR LECTURE #4 15: | ||
| - | 1 \ Last change: | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 User stacks. | ||
| - | 14 An application for FORTH to Survey Technology. | ||
| - | 15 | ||
| - | |||
| - | Screen 1 not modified | ||
| - | 0 \ Load screen for help system. | ||
| - | | ||
| - | 2 \ The word FROM temporarily redirects the input to the | ||
| - | 3 \ indicated block file for ONE screen load only. | ||
| - | 4 \ However.... that one screen could specify that others be | ||
| - | 5 \ loaded. | ||
| - | 6 \ Go back and check it yourself. | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 FROM B: | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 2 not modified | ||
| - | 0 \ REVIEW - 1 NUMBER DISPLAY | ||
| - | 1 \ Single signed 16bit numbers. | ||
| - | | ||
| - | | ||
| - | | ||
| - | 5 \ Single unsigned 16bit numbers. | ||
| - | | ||
| - | | ||
| - | | ||
| - | 9 \ Double signed 32bit numbers | ||
| - | 10 D. ( d -- ) Display signed 32bit # followed by space. | ||
| - | 11 D.R ( d w -- ) Display # right justified in w wide field. | ||
| - | 12 | ||
| - | 13 \ Double unsigned 32bit numbers. | ||
| - | 14 UD. ( ud -- ) Display unsigned 32bit # followed by space | ||
| - | 15 UD.R ( ud w -- ) Display # right justified in w wide field. | ||
| - | |||
| - | |||
| - | Screen 3 not modified | ||
| - | 0 \ REVIEW - 2 | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 ? | ||
| - | |||
| - | |||
| - | Screen 4 not modified | ||
| - | 0 \ REVIEW - 3 CONDITIONALS | ||
| - | 1 \ Note: These operators work at the binary bit level!! | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 Starting FORTH NOT is different than F83 NOT | ||
| - | 12 F83 NOT operates on each of a numbers 16 bits. | ||
| - | 13 F83 NOT leaves a false flag ( zero ) only if it | ||
| - | 14 operates on a true flag -1=1111111111111111 binary | ||
| - | 15 F83 NOT is not the same as 0= | ||
| - | |||
| - | |||
| - | Screen 5 not modified | ||
| - | 0 \ REVIEW - 4 Miscellaneous | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 9 \ IF ELSE THEN | ||
| - | 10 si = step i ci = condition i | ||
| - | 11 \ Do step 2 if condition 1 is true. | ||
| - | 12 | ||
| - | 13 \ Do step 2 if condition 1 is true, otherwise do step 3. | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 6 not modified | ||
| - | 0 \ REVIEW - 5 Interval Logic | ||
| - | 1 \ (IN) leaves a true flag if a < x < b | ||
| - | 2 : (IN) ( x a b flag ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | 6 \ [IN] leaves a true flag if a <= x <= b , otherwise false. | ||
| - | 7 : [IN] ( x a b flag ) | ||
| - | | ||
| - | 9 \ (IN] leaves a true flag if a < x <= b , otherwise false. | ||
| - | 10 : (IN] ( x a b flag ) | ||
| - | 11 1+ (IN) ; | ||
| - | 12 | ||
| - | 13 \ [IN) leaves a true flag if a <= x < b , otherwise false. | ||
| - | 14 : [IN) ( x a b flag ) | ||
| - | 15 SWAP 1- SWAP (IN) ; | ||
| - | |||
| - | |||
| - | Screen 7 not modified | ||
| - | 0 \ Support for bullet proof #IN | ||
| - | 1 : BELL ( -- -- ) 7 EMIT -1 #OUT +! ; | ||
| - | 2 : DIGIT? | ||
| - | | ||
| - | 4 : RUBOUT | ||
| - | | ||
| - | 6 \ Remove digit from screen and number then dec digit count. | ||
| - | 7 : -DIGIT | ||
| - | | ||
| - | 9 \ Increment digit count and add in digit. | ||
| - | 10 : +DIGIT | ||
| - | 11 SWAP 10 UM* 2 PICK 48 - 0 D+ 32767. 2OVER DU< | ||
| - | 12 | ||
| - | 13 ELSE DROP SWAP EMIT SWAP 1+ SWAP THEN ; | ||
| - | 14 : RESET? | ||
| - | 15 OVER 0= IF ROT DROP FALSE -ROT THEN ; --> | ||
| - | |||
| - | |||
| - | Screen 8 not modified | ||
| - | 0 \ Support for bullet proof #IN | ||
| - | 1 \ Correct an error input. | ||
| - | 2 : CORRECT.IT ( flg cnt num key flg cnt num ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | 6 \ Process all other keystrokes. | ||
| - | 7 : PROCESS.IT ( flg cnt num key flg cnt num ) | ||
| - | | ||
| - | | ||
| - | 10 ELSE DROP BELL THEN ; \ Invalid key or overflow. | ||
| - | 11 \ Apply sign to number. | ||
| - | 12 : APPLY-SIGN | ||
| - | 13 DROP NIP SWAP \ Drop key, nip cnt, get flg. | ||
| - | 14 IF NEGATE THEN ; \ Apply sign to number. | ||
| - | 15 : NEGATIVE? ASCII - = 3 PICK 0= AND ; --> \ Negative number? | ||
| - | |||
| - | |||
| - | Screen 9 not modified | ||
| - | 0 \ Bullet proof #IN | ||
| - | 1 : SET-FLAG | ||
| - | | ||
| - | | ||
| - | 4 : #IN ( -- num ) \ flg=sign flag | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 IF APPLY-SIGN EXIT THEN \ Apply sign to number & exit | ||
| - | 11 DUP CONTROL H = \ Correct error input? | ||
| - | 12 IF | ||
| - | 13 ELSE PROCESS.IT | ||
| - | 14 THEN AGAIN ; | ||
| - | 15 : TEST BEGIN CR #IN 3 SPACES DUP . 0= UNTIL ; | ||
| - | |||
| - | |||
| - | Screen 10 not modified | ||
| - | 0 \ Return Stack | ||
| - | 1 \ New Words: | ||
| - | 2 \ These words are very dangerous!! Do NOT test or execute them | ||
| - | 3 \ interactively. They can only be used within colon definitions. | ||
| - | 4 \ Note: D) indicates data stack, | ||
| - | 5 \ Transfer top data stack item to return stack. | ||
| - | 6 \ >R ( n -- D) ( -- n R) | ||
| - | 7 \ Transfer top return stack item to data stack. | ||
| - | 8 \ R> ( -- n D) ( n -- R) | ||
| - | 9 \ Copy top return stack item to data stack. | ||
| - | 10 \ R@ ( -- n D) ( n | ||
| - | 11 | ||
| - | 12 \ RULES: | ||
| - | 13 \ 1. Each use of >R must be balanced with a corresponding R> | ||
| - | 14 \ 2. Do not use >R R> and R@ within DO ... LOOPs. | ||
| - | 15 \ info is kept on the return stack and could be destroyed. | ||
| - | |||
| - | |||
| - | Screen 11 not modified | ||
| - | 0 \ Example 1: Average, Problem 1 14: | ||
| - | | ||
| - | 2 : AVERAGE | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 \ Problem 0: | ||
| - | 8 \ Rewrite AVERAGE without using the return stack. | ||
| - | 9 \ Problem 1: | ||
| - | 10 \ Rewrite AVERAGE | ||
| - | 11 \ and frequency fi . ie average = [ sum xi*fi ]/n n = sum fi | ||
| - | 12 | ||
| - | 13 \ AVERAGE ( x1 f1 x2 f2 ... xk fk -- ) | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 12 not modified | ||
| - | 0 \ Problem 1 solution. | ||
| - | 1 : AVERAGE | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 \ Given n frequencies construct histogram or bar chart. | ||
| - | 8 : WHITE 177 EMIT ; | ||
| - | 9 : HISTOGRAM ( f1 f2 ... fn -- ) | ||
| - | 10 CR DEPTH 0 | ||
| - | 11 ? | ||
| - | 12 \ Problem 2: | ||
| - | 13 \ Modify HISTOGRAM so that the bars come out in the proper order | ||
| - | 14 \ ( f1 first). Hint: " ROLL " | ||
| - | 15 \ the stack when finished printing bars. | ||
| - | |||
| - | |||
| - | Screen 13 not modified | ||
| - | 0 \ Example - 3 Square Root 21: | ||
| - | 1 \ Square root by Newton' | ||
| - | 2 \ Theory: | ||
| - | 3 \ function is the square root of n. | ||
| - | 4 \ Newton' | ||
| - | 5 \ according to: xn = xo - f(xo)/ | ||
| - | 6 \ It can be shown that: xn = ( xo + n/xo )/2 | ||
| - | | ||
| - | 8 : XNEW ( n xold n xnew ) | ||
| - | | ||
| - | 10 : SQRT ( n root ) | ||
| - | 11 DUP 0< ABORT" Illegal argument." | ||
| - | 12 DUP 1 > | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 \ Note: This is not the best or fastest square root algorithm. | ||
| - | |||
| - | |||
| - | Screen 14 not modified | ||
| - | 0 \ Example 4 Hypotenuse, Problem 3 Area | ||
| - | 1 \ Hypotenuse of a right triangle. | ||
| - | 2 : HYPO ( a b c ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 : TEST 15 1 DO 15 1 DO | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 \ Problem 3: Write a word that calculates the area of a triangle | ||
| - | 12 \ using HERO's formula. | ||
| - | 13 \ where s is the semi perimeter. | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 15 not modified | ||
| - | 0 \ | ||
| - | | ||
| - | 2 : AREA ( a b c area ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 \ Warning! | ||
| - | 11 \ above definition. | ||
| - | 12 \ occur within one word as FORTH uses the return stack to nest | ||
| - | 13 \ the calling | ||
| - | 14 | ||
| - | 15 \ Can you give a solution that does not use the return stack? | ||
| - | |||
| - | |||
| - | Screen 16 not modified | ||
| - | 0 \ F83 Memory Map 21: | ||
| - | | ||
| - | 2 bytes of memory has its own unique 16 bit address. | ||
| - | 3 range from 0 through 65535 decimal | ||
| - | 4 hexadecimal ( base 16 ) as 0000 throught FFFF . | ||
| - | | ||
| - | 6 HEX ( -- -- ) Set system number BASE to 16 (decimal). | ||
| - | 7 DECIMAL ( -- -- ) Set system number BASE to 10 (decimal). | ||
| - | | ||
| - | 9 LIMIT ( -- adr ) Leave address of end of disk buffer area. | ||
| - | 10 FIRST ( -- adr ) Leave address of start of disk buffer area. | ||
| - | 11 INIT-R0 ( -- adr ) Leave address of top of return stack. | ||
| - | 12 TIB ( -- adr ) Leave address of terminal input buffer. | ||
| - | 13 PAD ( -- adr ) Leave address of text output buffer. | ||
| - | 14 HERE ( -- adr ) Leave address of word buffer. | ||
| - | 15 ORIGIN | ||
| - | |||
| - | |||
| - | Screen 17 not modified | ||
| - | 0 \ Memory Operators | ||
| - | | ||
| - | 2 DUMP ( adr n -- ) Dump n bytes of memory starting at adr. | ||
| - | 3 ERASE ( adr n -- ) Erase n bytes of memory starting at adr | ||
| - | | ||
| - | 5 FILL ( adr n m -- ) Fill n bytes of memory starting at adr | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 NOTE: 16 bit numbers are stored with the low byte at adr | ||
| - | 11 and the high byte at adr+1 ( this is convention for | ||
| - | 12 6502 and 8086 CPUs - 68000 is the reverse ). | ||
| - | 13 C! ( n adr -- ) Store low 8 bits of n at address adr. | ||
| - | 14 C@ ( adr | ||
| - | 15 ? ( adr -- ) Display contents of cell at adr. | ||
| - | |||
| - | |||
| - | Screen 18 not modified | ||
| - | 0 \ Variables | ||
| - | 1 Values which change quite frequently and must be accessed by | ||
| - | 2 a number of words are best represented by the use of VARIABLEs. | ||
| - | 3 Values represented by variables have the added convenience of | ||
| - | 4 reference by name. | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 VARIABLE | ||
| - | 11 2 RAIN ! RAIN ? | ||
| - | 12 | ||
| - | 13 : DRIP RAIN @ 1+ RAIN ! ; | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 19 not modified | ||
| - | 0 \ Constants | ||
| - | 1 \ Values which never change are best represented by CONSTANTs. | ||
| - | 2 \ | ||
| - | 3 \ CONSTANT < | ||
| - | 4 \ value is n. | ||
| - | 5 \ < | ||
| - | 6 \ Examples: | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 12 CONSTANT | ||
| - | 11 | ||
| - | 12 31416 CONSTANT PI | ||
| - | 13 : *PI PI 10000 */ ; | ||
| - | 14 : AREA ( r area ) | ||
| - | 15 DUP * *PI ; | ||
| - | |||
| - | |||
| - | Screen 20 not modified | ||
| - | 0 \ Random Numbers | ||
| - | | ||
| - | 2 : (RND) SEED @ 259 * 3 + 32767 AND DUP SEED ! ; | ||
| - | 3 : RND ( n r ) \ r is a random number | ||
| - | | ||
| - | | ||
| - | 6 : DICE ( -- | ||
| - | | ||
| - | 8 \ Problem 4 Write the word CARD described below. | ||
| - | 9 \ CARD draws one card from a deck. When CARD is executed it | ||
| - | 10 \ will leave the suit as a number 1 - 4 and the face value as | ||
| - | 11 \ 1 - 13. CARD ( -- | ||
| - | 12 | ||
| - | 13 \ Problem 5 | ||
| - | 14 \ Write words SUIT and VALUE that use the result of CARD | ||
| - | 15 \ to display | ||
| - | |||
| - | |||
| - | Screen 21 not modified | ||
| - | 0 \ Pythagorean Triples. Problem 6. 21: | ||
| - | | ||
| - | | ||
| - | 3 : .ABC ( -- -- ) | ||
| - | | ||
| - | 5 : TRIPLES ( -- -- ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 IF .ABC THEN | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 \ Problem 6: Modify to find all triples upto 100. Can you make | ||
| - | 14 \ it run faster, using SQRT ? , without using variables? | ||
| - | 15 \ Modify so that triples are counted. | ||
| - | |||
| - | |||
| - | Screen 22 not modified | ||
| - | 0 \ More Memory Operators | ||
| - | 1 Note: cell = 2 bytes = 16 bits = 1 word | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 6 CREATE < | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 ALLOT ( n -- ) Allocate n bytes of memory in the | ||
| - | 11 dictionary. | ||
| - | 12 , | ||
| - | 13 initializing it to the value n. | ||
| - | 14 C, ( n -- ) Allocate 8 bits ( 1 byte ) of memory | ||
| - | 15 initializing it to low 8 bits of n. | ||
| - | |||
| - | |||
| - | Screen 23 not modified | ||
| - | 0 \ Tables | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 : MARBLES | ||
| - | | ||
| - | | ||
| - | 10 2 RED | ||
| - | 11 8 BLACK MARBLES ! 13 WHITE MARBLES ! 21 GREEN MARBLES ! | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 24 not modified | ||
| - | 0 \ Tables | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 5 : LESS -1 MODE ! ; : LESS? MODE @ -1 = ; | ||
| - | 6 : SHOW 0 MODE ! ; : SHOW? MODE @ 0= ; | ||
| - | 7 : MORE 1 MODE ! ; : MORE? MODE @ 1 = ; | ||
| - | 8 : ONLY 2 MODE ! ; ONLY | ||
| - | 9 : MARBLES | ||
| - | 10 | ||
| - | 11 LESS? IF SWAP NEGATE SWAP +! | ||
| - | 12 ELSE SHOW? IF @ . | ||
| - | 13 ELSE MORE? IF | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 25 not modified | ||
| - | 0 \ Arrays | ||
| - | | ||
| - | 2 : DATA@ ( i | ||
| - | 3 : DATA! ( n i -- ) 2* DATA + ! ; | ||
| - | 4 \ : CLEAR-DATA | ||
| - | 5 : CLEAR-DATA | ||
| - | 6 : GET-DATA | ||
| - | | ||
| - | 8 : SHOW-DATA | ||
| - | | ||
| - | 10 \ Problem 7: | ||
| - | 11 \ Write a word COUNT-DATA ( -- k ) that leaves the number of | ||
| - | 12 \ non zero items k in the array DATA on the stack. | ||
| - | 13 \ Write SUM-DATA ( -- sum ) that sums the non zero data values. | ||
| - | 14 \ Write AVERAGE-DATA ( -- -- ) prints average of non 0 values. | ||
| - | 15 \ Be sure to test you words. | ||
| - | |||
| - | |||
| - | Screen 26 not modified | ||
| - | 0 \ User stacks. | ||
| - | | ||
| - | 2 : P-CLEAR | ||
| - | 3 : P-DEPTH | ||
| - | 4 : P-INC ( -- -- D) | ||
| - | | ||
| - | | ||
| - | 7 : P-DEC ( -- -- D) | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 : >P ( n -- D) ( -- n P) P-INC P-INDEX @ P-STACK + ! ; | ||
| - | 12 : P@ ( -- n D) ( n n P) P-INDEX @ P-STACK + @ ; | ||
| - | 13 : P> ( -- n D) ( n -- P) P@ P-DEC ; | ||
| - | 14 : .P P-DEPTH ?DUP IF 1+ 1 ?DO I 2* P-STACK + @ 8 .R LOOP | ||
| - | 15 ELSE ." P-STACK EMPTY" THEN ; | ||
| - | |||
| - | |||
| - | Screen 27 not modified | ||
| - | 0 \ Problem 8: User stacks. | ||
| - | 1 \ Write FORTH words for the following user stack operations. | ||
| - | 2 \ The should leave the data stack unchanged!!! | ||
| - | 3 : PDUP ; | ||
| - | 4 : PDROP ; | ||
| - | 5 : PSWAP ; | ||
| - | 6 : POVER ; | ||
| - | 7 : PROT ; | ||
| - | 8 : -PROT ; | ||
| - | 9 : PTUCK ; | ||
| - | 10 : PNIP ; | ||
| - | 11 : 2PDUP ; | ||
| - | 12 : 3PDUP ; | ||
| - | 13 : 2PSWAP | ||
| - | 14 : 2PDROP | ||
| - | 15 : 2POVER | ||
| - | |||
| - | |||
| - | Screen 28 not modified | ||
| - | 0 \ Double Variables and Constants. | ||
| - | | ||
| - | 2 2VARIABLE | ||
| - | | ||
| - | 4 < | ||
| - | | ||
| - | | ||
| - | 7 2CONSTANT | ||
| - | | ||
| - | 9 < | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 2! ( d adr -- ) Store the double number d at adr. | ||
| - | 13 | ||
| - | 14 2@ ( adr d ) Fetch the double number d from adr. | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 29 not modified | ||
| - | 0 \ Hard copy screen documentation. | ||
| - | | ||
| - | 2 \ Print three screens starting with n on the printer. | ||
| - | 3 : HTRIAD | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 \ Send a top of page command to printer. | ||
| - | 8 : FFEED | ||
| - | | ||
| - | 10 | ||
| - | 11 \ Print screens | ||
| - | 12 : DOC ( first last -- ) | ||
| - | 13 1+ SWAP DO I HTRIAD FFEED 3 +LOOP ; | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 30 not modified | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 31 not modified | ||
| - | 0 \ Polygon Area - 1 | ||
| - | 1 CREATE X 102 ALLOT \ Array for x coordinates | ||
| - | 2 CREATE Y 102 ALLOT \ Array for y coordinates | ||
| - | 3 VARIABLE | ||
| - | 4 VARIABLE | ||
| - | 5 \ Compute address of ith component. | ||
| - | 6 : II ( i adr adr{i} ) | ||
| - | | ||
| - | 8 \ Fetch ith x component. | ||
| - | 9 : X@ ( i x{i} ) X II @ ; | ||
| - | 10 \ Fetch ith y component. | ||
| - | 11 : Y@ ( i y{i} ) Y II @ ; | ||
| - | 12 \ Store ith x component. | ||
| - | 13 : X! ( x i -- ) X II ! ; | ||
| - | 14 \ Store ith y component. | ||
| - | 15 : Y! ( y i -- ) Y II ! ; | ||
| - | |||
| - | |||
| - | Screen 32 not modified | ||
| - | 0 \ Polygon area - 2 | ||
| - | 1 \ Move to the next tab stop. | ||
| - | 2 : TAB ( -- -- ) | ||
| - | | ||
| - | | ||
| - | | ||
| - | 6 \ Get number from keyboard. | ||
| - | 7 : GET# ( -- n ) | ||
| - | | ||
| - | 9 \ Prompt and fetch number of data points. | ||
| - | 10 : GET_# | ||
| - | 11 | ||
| - | 12 CR ." Enter number of data points. " | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 33 not modified | ||
| - | 0 \ Polygon area - 3 | ||
| - | 1 \ Prompt and fetch all data points. | ||
| - | 2 : GET_DATA | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 \ Sum data points. | ||
| - | 8 : SUM_DATA | ||
| - | | ||
| - | 10 # | ||
| - | 11 DO I X@ I 1- Y@ * ( X{i}*Y{i-1} ) | ||
| - | 12 I X@ I 1+ Y@ * ( X{i}*Y{i+1} ) | ||
| - | 13 - SUM +! | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | |||
| - | Screen 34 not modified | ||
| - | 0 \ Polygon area - 4 | ||
| - | 1 \ Display computed area. | ||
| - | 2 : PUT_AREA | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | 7 \ Compute area of polygon. | ||
| - | 8 : AREA_POLY | ||
| - | | ||
| - | 10 | ||
| - | 11 | ||
| - | 12 | ||
| - | 13 | ||
| - | 14 | ||
| - | 15 | ||
| - | |||
| - | </ | ||
papierkorb/sample4.blk.1755359401.txt.gz · Zuletzt geändert: 2025-08-16 17:50 von mka