--- title: "Timex Logic, Part 3" type: "article" slug: "timex-logic-part-3-2" url: "http://localhost/article/timex-logic-part-3-2/" markdown_url: "http://localhost/article/timex-logic-part-3-2.md" published_at: "2022-10-07T12:25:41+00:00" modified_at: "2026-08-04T14:18:55+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "It has been said here before that the computer is a number oriented machine. Every thing that it does, it does by the manipulation of numbers. Basic is a language akin to English, devised solely for the benefit of us humans. The computer itself doesn't need Basic, and early models of computers did not have…" category: - name: "LISTing Newsletter" slug: "listing-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/listing-newsletter/" post_tag: - name: "Best of Timex/Sinclair 1000 Articles and Documents" slug: "ts1000best" taxonomy: "post_tag" url: "http://localhost/tag/ts1000best/" - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Warren Fricke" slug: "warren-fricke" taxonomy: "indiv" url: "http://localhost/indiv/warren-fricke/" publication_r: id: 38992 title: "LISTing Newsletter" type: "periodical" url: "http://localhost/periodical/listing-newsletter/" authors: "Warren Fricke" authors_r: - name: "Warren Fricke" slug: "warren-fricke" taxonomy: "indiv" url: "http://localhost/indiv/warren-fricke/" issues_articles: - id: 40152 title: "LISTing Newsletter January 1991" type: "issue" url: "http://localhost/issue/listing-newsletter-january-1991/" pages: "10-11" pubdate: "January 1991" related_articles: - id: 45841 title: "Timex Logic, Part 1" type: "article" url: "http://localhost/article/timex-logic-part-1/" - id: 45842 title: "Timex Logic, Part 2" type: "article" url: "http://localhost/article/timex-logic-part-2/" archive_link: false --- # Timex Logic, Part 3 It has been said here before that the computer is a number oriented machine. Every thing that it does, it does by the manipulation of numbers. Basic is a language akin to English, devised solely for the benefit of us humans. The computer itself doesn’t need Basic, and early models of computers did not have it. All of the Basic commands, operations, symbols, etc, used by programmers are converted immediately into code numbers by the computer for its own use. Then to communicate back to us, the computer kindly replaces the numbers with a language that we can more readily understand. In an 8-bit computer such as the Timex, there are only 256 distinct numbers in a byte, from 0 to 255, but these numbers have different meanings to the computer, depending upon how and where they are used. That’s why, for example, the number 201 can represent RETURN in a machine code instruction, and the symbol `<>` used in a logic condition of Basic. That’s why 0 in logic is set aside to mean FALSE, and any other number in similar circumstances signifies TRUE. Another computer trait we wish to emphasize again is the way it responds to priority. Priorities are listed on page 228 of the manual. Add parentheses, priority 16, to this list. Every thing that the computer does, it does in the order dictated by priority, highest first, then the next highest, until all operations are considered. Let’s put these two logic considerations to a test with the following short program….. ``` 5 LET Y=2 10 PRINT 5 + Y*6 ``` Look at line 10. It doesn’t contain a logic condition, but priority is needed to perform the mathematics at the proper time. The `*` symbol has priorty higher than the `+` symbol, so the computer does the multiplication first, and then adds the result to 5. The answer, 17, will appear if you RUN the program. Next substitute an `=` mark for the `+` sign in line 10….. ``` 5 LET Y=2 10 PRINT 5 + Y=6 ``` Now there is a logic condition in line 10, but the `+` sign has a higher priorty than the equal symbol, so the computer adds 5 to 2 and gets 7. Then it looks at the condition 7=6. It compares the two numbers and finds that they are not equal. So it prints out a 0, the logic value of a FALSE condition. Change the 6 in line 10 to a 7 and RUN the program again. You will now get a printout of 1, indicating that the logic value of 7=7 is 1, indicating a TRUE condition. Consider the manner in which the Timex computer evaluates or alters the value of a variable. Seemingly this construction may look like a departure from the priority rule. Enter the following lines….. ``` 5 LET T = 5 10 LET T = T+3 15 PRINT T ``` Meeting this for the first time, one might conclude that this is arithmetically incorrect. How can a number be equal to itself plus 3? Here literal meaning gives way to computer talk, and it means change T to be equal to itself plus 3. In this situation the `=` mark is an “assignment operator”, having a priority of 1, placing it at the very bottom of the priority scale. In another sense LET T= can be considered a syntax arrangement, a grouping of characters that perform a particular function last and independant of the other operations in the statement. Now change line 10 of this little program to read….. ``` 10 LET T = T = T ``` RUN it and the answer comes out 1. This is because the computer considers this line to be equivalent to… ``` 10 LET T = (T=T) ``` Now (T=T) is true for all values of T; so it has a logic value of 1. Hence T itself becomes 1. Go a step further and add another =T…. ``` 10 LET T = T = T = T ``` Run this and the answer comes up 0. This is because the computer evaluates line 10, in stages, as follows….. ``` 10 LET T=(T+T)=T, which is... 10 LET T=(1)=T, which is... 10 LET T=(1=T), which boils down to.... 10 LET T= 0 ``` And the final answer will be 0 no matter how many times we add an =T. LET appears in many lines containing logic conditions. Try the following in our little program…. ``` 10 LET T = T = 50 ``` Since T has a value of 5 before getting to this line, the condition T=50 becomes a logical 0 and T finalizes to a value of 0 also. If T had a value of 50 when the program got to this line, the condition would be TRUE, logic value 1, and T ends up with a value of 1 also. Thus the final value of T will be either 0 or 1 depending upon its prior value. Appropriate logic expressions enable the computer to make quick decisions with a paucity of words or characters. To the programmer this means less bytes are required, conserving RAM. Short, concise statements also RUN faster as a rule, another asset. Experienced programmers build up a repertoire of logic short cuts. Consider a situation where one might want to develop either a +1 or a -1, at random. Useful if back and forth, up and down motions are required. An expression like the following will do it…. ``` LET K = 1 - 2*(RND > .5) ``` The condition in parentheses will be TRUE half of the time and FALSE the other half. So it might have a logic value of 1 or 0. From here on the procedure is pure math. A logic value of 1 makes K = -1, and a logic value of 0 makes K = +1. By the way, did you notice that the parentheses are necessary? Otherwise the computer will consider the `*` operator before the `>` symbol. There are short cuts galore, especially in Timex logic; as we shall see. Consider an expression like IF B<>0…. It can be replaced simply by IF B. This is because any value that B would have other than 0 would be considered logical TRUE. The same goes for an expression like… ``` IF 17 * n <> 0, which is the same as... IF 17 * n IF TRUE.... (n<>0) ``` We can have other mixtures of arithmetic and logic operations and priority will decide the outcome. Consider this one…. ``` 5 LET D = 6: LET E = 5 10 PRINT D < 8 - E ``` Before you RUN this, take a try at the answer, remembering that the negative sign has a higher priority than the `<` mark causing the computer to consider the condition to be 8 – 5 or 3. As 3 is not larger than 6, the entire expression is FALSE. Hence a logic 0 will PRINT. In the fourth part of this series we will look at some logic expressions not available on other computers. Expressions that enable Timex programming to be more concise when the occasion arises, and they can be used.