Shop OBEX P1 Docs P2 Docs Learn Events
Playing with Sinclair ZX81 / Timex Sinclair 1000 / Timex Sinclair 1500 — Parallax Forums

Playing with Sinclair ZX81 / Timex Sinclair 1000 / Timex Sinclair 1500

BeanBean Posts: 8,129
edited 2015-11-25 13:55 in General Discussion
I saw my old Timex Sinclair 1500 and decided to hook it up and do some Z80 assembly language programming.
I was surprised how many of the opcodes I remembered by heart.
The ZX81 is terribly slow at printing values, so I wrote a routine to print integer values quickly.
First I had to convert the floating point format to integer, then print the integer values.

It took a couple days (maybe 4-5 hours all together), but the routine is 10 times faster than BASIC.

Just for the heck of it here is the routine:
'ZX81 Print Integer Value
  LD HL,(VARS)        2A 10 40   ' Point to first variable
  INC HL              23         ' Skip variable name
  INC HL              23         ' Point to MSB value byte
  LD B,(HL)           46         ' Get MSB
  BIT 7,B             CB 78      ' Is value positive (>=0) ?
  JZ Positive         28 03      ' Yes, jump ahead
  LD A,"-"            3E 16      ' No, print a "-" character
  RST 10              D7
Positive:
  SET 7,B             CB F8      ' Set implied bit
  DEC HL              2B         ' Point to exponent value byte
  LD A,145d           3E 91      ' Prepare to do 145-Exponent
  SUB (HL)            96         ' Subtract exponent
  INC HL              23         ' Point to LSB value byte
  INC HL              23
  LD C,(HL)           4E         ' Get LSB
  JR Skip             18 04      ' Rotate value A-1 Times
Again:
  SRL B               CB 38      ' Shift 16 bit value in BC right (/2)
  RR C                CB 19
Skip:
  DEC A               3D         ' Adjust counter
  JNZ Again           20 F9      ' If not done, rotate again
  PUSH BC             C5         ' Move BC to HL
  POP HL              E1
  LD E,0              1E 00      ' Zero digit sum
                                 ' If E is zero the digit will not print 
                                 ' because it is a leading zero
  LD BC,-10000        01 F0 D8   ' Do 10,000s digit
  CALL Digit          CD C2 40
  LD BC,-1000         01 18 FC   ' Do 1,000s digit
  CALL Digit          CD C2 40
  LD BC,-100          01 9C FF   ' Do 100s digit
  CALL Digit          CD C2 40
  LD BC,-10           01 F6 FF   ' Do 10s digit
  CALL Digit          CD C2 40
  LD A,"0"            3E 1C      ' Do 1s digit with simple addition
  ADD A,L             85
  RST 10              D7
  RET                 C9         ' Done

Digit:
  LD A,"0"            3E 1C      ' Set digit to 0
IncDigit:
  INC A               3C         ' Assume next digit
  INC E               1C         ' Adjust digit sum
  ADD HL,BC           09         ' Next digit again ?
  JC IncDigit         38 FB      ' Yes, jump
  DEC A               3D         ' Undo assumed increment
  SBC HL,BC           ED 42      ' Restore value to previous
  DEC E               1D         ' Undo assumed increment
  RETZ                C8         ' If digit sum is zero, done (leading zero)
  RST 10              D7         ' Print digit
  RET                 C9         ' Done

78 bytes

The Timex Sinclair 1000 was my first computer and I've owned several of them, but the keyboard makes me want to shove an ice pick in my eye.
I just can't stand it. So when I saw a Timex 1500 on ebay a couple years about I got it and it is MUCH nicer to type on.

Bean

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-07-28 17:18
    Bean wrote: »
    The Timex Sinclair 1000 was my first computer and I've owned several of them, but the keyboard makes me want to shove an ice pick in my eye.

    LOL,

    I had one around 1982 (and a portable 5" TV). Think I gave it all to a pirate ... arrgh ;-)
  • Heater.Heater. Posts: 21,230
    edited 2014-07-28 17:41
    All hail Sir Clive!

    A classic machine that got many a youngster into electrical or software engineering careers.

    However, I suspect the best thing to do now is put it in your family heir loom display cabinet and play with ZiCog or qz80 on the Propeller when you need that Z80 assembler coding fix.
  • GadgetmanGadgetman Posts: 2,436
    edited 2014-07-28 22:03
    Nice code.

    The original code may have been written more for compactness than for speed. After all, they did have to squeeze in a complete BASIC interpreter into 16K ROM.

    Here's a listing of the ZX81 ROM:
    http://www.wearmouth.demon.co.uk/zx81.htm
    (The TS 1000 may be slightly different, though)
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2014-07-28 22:07
    Not sure how much of this is accurate, but it's an interesting look at the Sinclair. Possible PG-13 for language IIRC
  • Heater.Heater. Posts: 21,230
    edited 2014-07-28 22:24
    OBC,

    I just discovered Micro Men recently, brilliant movie. From my recollection, having been following Clive Sinclair since the days of the matchbox sized Micromatic pocket radio, and then Acorn with the advent of the microprocessor era, it all seemed remarkably authentic. Including the famous bar brawl between Sinclair and Chris Curry which was head line news at the time.

    As teenagers we called Sinclair "Uncle Clive", that was years before the computer business. It was as if he was our crazy genius eccentric uncle that kept coming up with these fantastically clever inventions and solutions to problems but the products themselves were pretty much universally Smile. His scientific calculator was a huge break through on size and price but the accuracy was generally worse than using log tables. (Yes we used log tables in school about that time).

    Anyway I don't recall that MicroMen makes much of a point about how those geeks hurriedly finishing the BBC computer were the ones who created the ARM processor leading to the mobile world we have today.
  • LeonLeon Posts: 7,620
    edited 2014-07-29 01:33
    Does anyone remember the Sinclair watch? A colleague of mine at Xerox Research in Milton Keynes who sometimes used a micro-densitometer which had a photo-multiplier in it had one. Whenever he used the system, his Sinclair watch malfunctioned because of the high voltage supply to the photo-multiplier.

    Another colleague of mine bought a Sinclair audio amp. He found that he could get acceptable audio quality out of it at low power levels, but there was horrendous distortion at the rated power output. He phoned Sinclair about it. I can't remember the response, but he could hear a baby crying in the background. He must have been talking to Sinclair himself, who was running his business from home at the time and had a young family.
  • Heater.Heater. Posts: 21,230
    edited 2014-07-29 02:06
    Ah the Black Watch. Famed for it's inaccuracy, unreliability and short battery life. I don't recall ever seeing one. By then I had already had a LED watch, rather more like the one James Bond had in Live and Let Die.

    I had a Sinclair Audio amp as a teenager. The "Project 80" twenty five watt stereo kit. It was great, with its scratchy, wobbly pots and all. I don't recall any distortion issues but then I could never play it very loud at home. The best part was that when I got to university it made an excellent receiver for the campus radio station!
  • BeanBean Posts: 8,129
    edited 2014-07-29 04:21
    Gadgetman wrote: »
    Nice code.
    The original code may have been written more for compactness than for speed. After all, they did have to squeeze in a complete BASIC interpreter into 16K ROM.

    Thanks, but my code only displays integers from -65535 to +65535 stored in the first variable defined.
    I could make it much faster by not using the ROM "RST 10" instruction to print a character by instead just poking it into screen memory, but then it wouldn't work if you had less that 4K of RAM or if you use the SCROLL command.
    Both of these produce a "collapsed" display memory map. Which must be expanded before a character is poked into screen memory.

    Bean
  • blittledblittled Posts: 681
    edited 2014-07-29 05:09
    I have a working TS1000 but it took 2 trips to the Salvation Army to find a tv that worked with it since they "cheated" on the TV out with no back porch. New TVs don't work well without it. I found a person in Germany that made a retro kit and bought one. It has a circuit to add a back porch, onboard 16K rather than a ram pack and the option for micro- pushbuttons for the keyboard. I'm using that instead since it does have a better keyboard and features.

    I plan to use it to interface to a Propeller since all the parts are easily replaceable in case I release the magic smoke. In fact I built a circuit with the Propeller that reads "P" files off a SD card and translates that to the audio input for the TS1000 loading circuit.
  • stamptrolstamptrol Posts: 1,731
    edited 2014-07-29 05:53
    Hi Bean,

    Always nice to see someone still working with the Timex Sinclair's.

    One of the first projects I did with micros was a cable assembly tester for a military contractor. Still tickles me when I see one of those multi-million dollar ships, knowing all the electrical cable assemblies were tested and documented with a Sinclair-based test system.

    Code on!

    Cheers,
  • Heater.Heater. Posts: 21,230
    edited 2014-07-29 06:48
    stamptrol,

    Oh, yes, I have seen BBC Micro Computers in the test rigs of fly by wire systems for the Air Bus. Many, many years after the "beeb" dropped into the history books.
  • ercoerco Posts: 20,256
    edited 2014-07-29 07:04
    Love the old Timex Sinclair. I almost used one in my very first robot for the first Trinity Home Firefighting Robot Contest back in 1994. But I saw the BASIC Stamp in Nuts & Volts and used that instead. First place with a BS1, beat MIT's David Otten and some other robot whiz kids. I have some video on VHS somewhere. One of the many things I intend to Youtube.

    http://articles.courant.com/1994-04-18/news/9404180144_1_robots-hot-wheels-maze
  • GadgetmanGadgetman Posts: 2,436
    edited 2014-07-29 07:54
    What comes round, goes around it seems...

    Notice the last line in that article?

    And now a robot vacuum is a favorite robot base by many.

    The Sinclair ZX80, ZX81, ZX Spectrum all had their entire data and signal busses exposed on an edge connector. That made it very easy to adapt for HW control purposes.
  • BeanBean Posts: 8,129
    edited 2014-07-29 18:40
    The Timex Sinclair 1500 fixes the back porch problem.
    You can use a very simple 1 transistor circuit to convert them to composite video output.
    The contrast isn't great, but it's much better than the channel 2 or 2 picture.

    If you want to play around with a Sinclair machine I high recommend finding a TS1500.
    It has a usable keyboard, 16K built-in, and if you have the 16K ram pack it will have 32K (the internal RAM moves when the RAM pack is plugged in).

    Has anyone used the ZXPand device ? I was going to get one, but they don't work with the TS1500 because it blocks the power and cassette ports on the back.

    Bean
  • blittledblittled Posts: 681
    edited 2014-07-29 19:30
    I believe tdg8934 has a ZXPand but I haven't seen him on the forum here or at Sinclair ZX World http:// http://www.sinclairzxworld.com/index.php recently
  • WhitWhit Posts: 4,191
    edited 2014-07-29 19:53
    Thanks for posting Bean. I bought mine at Drug Store in town. They were an authorized dealer (i guess because they sold Timex watches).Wish I still had mine...
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-07-29 22:58
    I had a Timex Sinclair ... I opted for the kit that you could build your own for $99 as opposed to the pre assembled and tested Computer for $199. At about the same time I had an Atari 400, I used both of them all of the time, but what really opened the door for me was when I figured out how to programmatically change the joystick ports on the Atari so that they worked as outputs. By default they are inputs. <-- THIS was my BASIC stamp at 12 years old (33 years ago). Now I could control the "outside world" with a program!!! :-)
  • BeanBean Posts: 8,129
    edited 2014-07-30 03:25
    Beau, for me it was when I purchased a sound module called "Blippo". It would latch a value poked to the ROM addresses.
    Once I discovered this I was hooked as I could actually control things with my Timex Sinclair 1000.

    Bean
  • trookstrooks Posts: 228
    edited 2014-07-30 04:08

    This has nothing to do with computers or electronics but I met Sir Clive several times over a span of thirty or so years.

    We both belonged to the same organization and he was much sought after as a speaker at conventions.

    Meeting with our group was likely a side trip to other much more serious business that brought him to the colonies.

    The one thing he and I had in common was an appreciation for a well planned and executed party. Not once in all those years did anything to do with electronics or business come into our conversations. It was always a delight to have him seated at the table.


  • blittledblittled Posts: 681
    edited 2014-07-30 05:01
    Whit,

    The Timex Sinclair 1000 was my first computer and my parents bought it at a local grocery store. It came with the 16K ram pack and was $100 with receipts showing you spent $100 at the store in the past month.
Sign In or Register to comment.