Timex Tips

Authors

Chuck Dawson

Publication

Publication Details

Volume: 4 Issue: 8

Date

August 1987

Pages

8-9

Here is something that puzzles me. I understand most of the terms in machine code, but what does SET do? When would we use it?

Each location in memory can hold a number from 0 to 255. When we PEEK a location, the computer gives us the number stored in that location. What is really there, of course, is а series of eight digits, either one or zero. So, if we see 255 printed on the screen, it is actually 11111111. In plain English, SET means ‘make it 1’ and RESET means ‘make it O’. If we RESET BIT 0 in the above example, we would get 11111110 and when we PEEKed that location, we would see 254. It would be just as easy to POKE the location with 254. The trouble is, these numbers get harder to figure if we get away from 255. Who can figure what 10110010 is in their head?

When do we use something like this? Well, to save space, computer programmers sometimes use the bits of a given location to mean store ‘on-off’ type information. For example, we have a CAPS LOCK that is either on or off. The status of CAPS LOCK is stored as bit three of location 23658. Other information could be stored in the other bits, so figuring what number to РОКЕ would involve determining the status of those other bits. However, we can SET or RESET the one bit, leaving the others alone, and only the CAPS LOCK status is affected. Another place this is used is in the display file. In this case, the ones or zeros become ink or paper colored dots on the screen. Thus, if we SET a bit, we get a dot on the screen; if we RESET it, the dot goes away. The dots around it do not change.

What do you use the RST command for? Is it restore? Restore what?

No, it not restore; it is RESTART. A restart is the same as a CALL except that it takes fewer machine cycles to execute. The programmers that write the ROM routines always put routines that are used a lot (like reading the keyboard or sending output to the screen) at these restart locations to speed things up. А restart routine must start at one of eight locations: 0, 8, 16, 24, 32, 40, 48, or 60.

How do I pass parameters between Basic and Machine Code?

One way is to POKE an unused location with a value, then the machine code routine can LD the number into the accumulator and use it. The reverse can be used to get the number back to BASIC with a PEEK. Also, if you start the routine with something like LET X = USR 32443, and have the result of the machine code routine moved to the BC register, then when control іs returned to BASIC, X will contain that BC value. (In the TS-1000, use the HL register instead.)

Products

 

Downloadable Media

 
Scroll to Top