Close

First attempts at running machine-ish code

A project log for Vintage Z80 palmtop compy hackery (TI-86)

It even has a keyboard!

eric-hertzEric Hertz 05/15/2021 at 02:5713 Comments

So, the trick is that Z80 machine-code can be entered manually into a "Program" by simply entering the hex values in ASCII, which can easily be accomplished on the inbuilt keypad.

This experiment since I don't presently have the means to upload the assembler/IDE.

I got some machine code to invert the foreground/background colors from Zeda's Hex Codes, over at: https://www.ticalc.org/pub/text/z80/

E.g. This Program inverts the colors, another similar one puts them back.

Then, in a regular TI-BASIC program, these pseudo-binaries can be called by typing e.g. ":Asm(TI)"

Now, the key, here, is that compiled machine code can be called, from BASIC, in the same way as these tiny little pseudo-binaries... 

I'm not yet sure how, but my guess is that values can be sent-to/returned-from, as well. Prb a line like ":9", before the "Asm()" call, would store 9 in "Ans", which is probably just a register that could be accessed directly by the assembly program. And written back to, as well. So, the return-value of the assembly function would be stored back in Ans. That's my guess.

Thus, simple programs like the text-inverter could be written to allow e.g. "peak"/"poke" to be used within BASIC, which AFAIK doesn't have the ability to access memory addresses directly. Similar, maybe for port I/O.

It's not that I particularly want to use BASIC for the sort of stuff I'm ultimately interested in, but it sure could be handy to have around for quick tests and maybe also for others' use. These "binaries" can be entered in by hand to significantly increase BASIC's abilities.

I suppose such has been done, but I've not seen them. My guess is they're so simple they come with game-dev packages that do far more than I intend (sprites, etc.)

So, maybe 4 or 8 one-liners like the text-inverter to cover memory accesses and I/O, and then the Computer in the Calculator is BASIC's oyster, or something.

But, I'm not bouts to not only learn Z80 assembly (and this machine's register/memory/io mapping) AND figure out how to hand-compile it to hex values (or am I?). 

So, a smarter me would prb wait to continue the peek/poke-library path until I've got an assembler and header files at my fingertips... right...? Sheesh, I fear where this is going. Maybe my first peripheral add-on should be a friggin' paper-punch reader, eh? Or a bunch of toggle switches and LEDs...?

TRIGGER-WARNING:

Meanwhile, apparently the reason I'm so into this right now is because my engine dumps nearly all its coolant in less than a mile's drive. And, frankly, that is a pretty huge concern, being my home, and far beyond my aptitude to even think about, let alone diagnose, nevermind learn about the system in the first place, especially these days. I fed her 8 bucks worth of springwater the other day before calling it quits at 3AM. Just watch that temperature gauge closely, I guess. Long pauses between tiny trips. Not much different, really, than the past several months of white-knuckling after my ice-storm accident. Who the heck really believes flying across a road at 60MPH, and surrounded by others doing the same, could possibly be a good idea? Do you know how small that dowel is that prevents your car from splitting in half by one tire's veering left and the other veering right? Have you ever looked at the way they installed your ball joints? What engineer in their right mind would rest the weight of a car going over potholes on that tiny lip of metal?! And such tiny threads on a friggin hollow thin-walled cylinder?!

I guess I'm going back to my happy place where electrons can be directed from place to place without putting my life, or worse, into the reliability of thin pieces of metal.

Discussions

ziggurat29 wrote 05/19/2021 at 13:47 point

There are a couple undocumented pins in the (TI-85) schematic.  As to whether they are IORQ, I don't know.  I'm not too optimistic, since this was an ASIC.  There may only be the 8 special purpose ports.
What I didn't see were pins needed for the bank switching of the RAM (need 1) and ROM (need 2), but there are 6 unconnected pins on that schematic, so maybe some of those are they.
Also, apparently, there is an internal interrupt at something like 200/sec.
You might want to figure out that 'link' thing -- typing through the keyboard is going to get old fast!
I'm sure I'll probably not be able to resist doing some disassembly, but it will have to wait 'til Sat.
You have a fun toy.  I kinda wish I had one to hack.  Did you get it at a yard sale?

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 20:59 point

i grabbed it at a thriftstore... then a couple days later they had a TI-83+ for 7 bux... kinda debated it but decided against, since I already got this. But I think I heard that the 83+ is similar in its extra RAM and assembly functions. Really, I prb woulda liked messing with that more, since I'm familiar with the 82. This thing's slightly different menus and layout are annoying! Anyhow, that is to say I'm surprised these things don't show up more often... seems like they'd be in the millions each year in America!

Link port... well... the point is that these days compy-wise I really only have regular access to my phone and now this calculator... which is why I even bothered to think of it as anything /other/ than just a calculator... and thinking of it a bit more like a tiny portable all in one kaypro, then finding an oncalc assembler was pretty much the main selling point for my situation... though, after doing a little bit of BASIC, you're right about the kb and tiny screen, I'm not sure how far I'll have the patience for. On the plus side, I could enter raw text rather than have to go through menus, which i don't think i could on the TI-82...

But, if I finally dig out the link cable and a regular compy... well... a one-time deal is one thing but regular-usage isn't really a possibility in my situation. Which, again, is why this thing appealed.

IORQ... i mean, it's just ONE pin, heh! (Just looked up the Z80, thought it'd be several pins, before, IORD, IOWR). Almost seems absurd to think they wouldn't make it available. If it was an epoxy-blob, I could see it, but they used this in Many devices of varying configs. The only reason I could think they wouldn't've is maybe the address-decoding logic for the 8 internal ports was dramatically reduced by only paying attention to the three address bits... Guess all I need to check for it is a tiny (hand-enterable, even!) assembly program, and a logic probe...

Similarly, the port outputs for selecting banks... if this were an epoxyblob there'd've been little reason to make so many accessible, the first devices using this chip had nowhere near the memory... they obviously did some forward-thinking in designing this chip.

BTW, one of those documents claim direct 24-bit addressing is a thing, which kinda boggles my mind, unless it's via a callable routine...

Also, only 8 banks are used for RAM while 16 are used for ROM, suggesting there may be one more address/bank bit accessible. Further suggested by I think I read that selecting one of the higher RAM banks gives FF's or garbage, rather than repeating a previous bank... so the full 4bit bank address decoding logic is in there...

Oh, banks... hmm... I haven't opened it up yet, but you're right, that'd be a lot of pins that weren't on the TI-85 schematic... It looks like there's a separate CS for RAM vs ROM... but beyond that... hmm

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 21:11 point

wait a minute... the TI-85 allegedly has 128K ROM yet the chip shown only has 16 address bits. Something is missing, here...

  Are you sure? yes | no

ziggurat29 wrote 05/19/2021 at 22:30 point

I did see the 'direct 24-bit addressing' mentioned.  Erh, how?  It's a 16-bit machine.
Good spot on the 16-lines.  You know how Internet information goes; have to take it with a grain of salt.
I have to confess, I did start to disassemble.  I couldn't help myself.
I did find the bankswitching routines in Page0.  The gist seems to be that when you are executing user assembly, Page 13 (0x0d) is mapped into 4000, and that has essentially a bunch of jumps/calls into Page 0.  So Page 0x0d provides the stable API for user programs.  Page 0 provides a separate indirection, and knows how to map in the correct page for any given routine, but it can vary build-to-build without breaking the stable API that thunks over to it.
I have to do a loootttt of disassembly cleanup because they use a parameters-embedded-in-code technique which boggles the disassembler's mind.
Incidentally, you can freely map RAM into 4000 and ROM into 8000 if you really wanted to, but the firmware just doesn't out of convention.  P0 ROM is always at 0000, and P0 ram is always at C000
Why do I bother doing this stuff?  I don't know; I can't help myself....

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 23:31 point

LOL, I know that feeling... the last sentences "why do I...? I can't help myself..."... I was looking for the reply button, but the only one there was "report as inappropriate" which somehow seemed apropos :)

I have to give you props, your disassembly abilities astound!

Jump tables makes a bunch of sense, though all that bank switching might explain why this thing is so friggin slow... there's a vid of someone running the same tiny basic program, basically: "for i++, print i" on an 85 and 86 side by side, the 85 is twice as fast!

I'm not so certain it's just bank switching, though. The 82 used tokens, as I recall... e.g. "Disp" (display, a variable value) was a single element, you couldn't backspace to "Dis", nor could it be typed-out, which makes me think it didn't have to do nearly so much string parsing. The 85 may've been similar, as I think I read that the 86 introduced lowercase letter entry...

Looking forward to a Ziggurat29 disassembly comment-rush! Should you like to join again and enter log-entries?

  Are you sure? yes | no

ziggurat29 wrote 05/20/2021 at 08:48 point

haha; we know the weirdness of this site's reply capability.

For the 85 to be twice as fast, you're onto something.

For user assembly, you have to go through page 0x0d.  That's mostly a jump.  Then you have to go through page 0,  That incurs an overlay switch, which is quite spendy, and lest we forget this is a z80.

I haven't looked at the overlays themselves yet, but I'm sure they call directly into page 0.  But didn't the 85 also have banked memory?  Where in the 64k at any given moment was the ram and the rom?

  Are you sure? yes | no

ziggurat29 wrote 05/19/2021 at 01:13 point

perhaps one can write a short assembly program to dump the rom contents out the link port.  then fun with disassembly!

https://www.ticalc.org/archives/files/fileinfo/19/1992.html
https://www.ticalc.org/programming/columns/86-asm/el-helw/lesson1.html
https://jaymzroo.tripod.com/lessons/86ports.txt

opening:
http://richfiles.solarbotics.net/Turbo86.html

the following is for a TI-85, alas, but possibly gives some insight for the TI-86:
http://www.geocities.ws/SiliconValley/Lakes/5081/Schem85.gif
The CPU clearly has the LCD and keyboard driver integrated on-chip.  It seems the '86 uses the same ASIC-CPU as the '85, though I'm a bit confused how they would pull of the bank switching because the '85 doesn't seem to have any facility for such.
http://www.datamath.org/Graphing/TI-86.htm

https://jaymzroo.tripod.com/lessons/Z80ti864.txt

The RAM
https://pdf1.alldatasheet.com/datasheet-pdf/view/31695/TOSHIBA/TC551001.html

just found this about how to dump rom:
https://www.ticalc.org/programming/emulators/romdump.html

Oh.:
https://tiroms.weebly.com/

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 02:43 point

Great info, Thankya! Here are some thoughts on the links, intended to be roughly in order, more maybe to come:

https://www.ticalc.org/archives/files/fileinfo/19/1992.html

Am a bit confused, doesn't TI supply this, being asm86, to assemble from DOS/Windows?

This seems to be the "updated zip" which is mentioned in the readme as missing several directories, specifically includes(?).

The header file seems really quite bare, basically just buttons and some minimal strings/graphics.

https://www.ticalc.org/programming/columns/86-asm/el-helw/lesson1.html

Ahh, the former may be an archive of TI's asm86 III (still, missing .inc files?!)

This is a getting-started for assembly in TI's asm86 III

https://tiroms.weebly.com/

Hah! Ask and ye shall receive! Wonder how long that'll last...

Confusing: this seems to be for some emulator, which implies someone basically already knows the entire schematic/addressing all the way down to internals of the proc, bank switching, and video, etc.

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 02:56 point

https://jaymzroo.tripod.com/lessons/86ports.txt

This is mostly about the z80 I/O ports, which are used for memory bank switching, video, and the user port/graphlink... 8 ports, all pretty much filled. Also most of the memory banks are occupied, but a few seem unoccupied, i wonder if the necessary pins are accessible. Aside from extra RAM/FLASH, this could allow for memory-mapped I/O devices.

See also:

https://www.ticalc.org/pub/text/calcinfo/ti-ports.txt

And the file 86port4.txt linked in another comment

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 02:59 point

http://richfiles.solarbotics.net/Turbo86.html

Internal photos, rather limited... mostly about overclocking

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 03:16 point

http://www.datamath.org/Graphing/TI-86.htm

A lot of info and internal photos...

Interestingly, the TI-81 used the same ASIC CPU at some point(?!)

Also, apparently mine is ROM version 1.2, which is older than the first at that site (1.4). Also, apparently most TI-86's have OTP ROM chips or even masked-ROM as opposed to EEPROM/FLASH.... so firmware can't be upgraded! I haven't opened this to check.

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 03:23 point

https://jaymzroo.tripod.com/lessons/Z80ti864.txt

Ahh, memory mapping bank switching in detail!

16 banks of 16kb of ROM, 256k, and 8 banks of 16kb of RAM, 128k... (8 extra banks unused? Note: of all devices listed at the former link as using the same cpu asic the TI-86 has the most inbuilt RAM, that extra bank address bit may not be accessible. Also interesting: the PS-6600 has a 32x6 display, 192 characters vs the TI-86's 168... pretty sure I saw mention of a larger screensize setting in the Ports document, so there may be vid-mem that isn't used/displayed? As far as hackery is concerned: it's *plausible* if, say, a wider but *equal-height* display was configurable, the display itself would handle the different input by just showing the first pixels of each row... hackery with a shiftregister could tap the remaining pixels for Ouputs... hmmmmm).

(Tripod and geocities still exist?!)

Mention of different display settings:

https://www.ticalc.org/pub/text/calcinfo/86port4.zip

Ramblings on tapping into displays for extra outputs:

https://hackaday.io/project/8146-ridiculous-lcd-display-hacks/log/193007-extra-pixels-as-outputs-or-display-doubling

  Are you sure? yes | no

Eric Hertz wrote 05/19/2021 at 07:44 point

Ahh, z80 can have up to 256 I/O ports (and 256 banks of 256, allegedly via the B register's being output to the upper address lines by default during an in/out?!) And, stupidly, I hadn't figured the Z80 had separate instructions for I/O ports vs memory, so thought the "ports" were merely an 8 bit register at some memory address... So, then, all it is is a matter of IOWR, etc., being available external to the chip, and, frankly, since they're already used internally, it'd be utterly stupid to design a chip like that (used in many calculators and even an early PDA) without making those signals available at pins.... There appear to be a few unused and unknown pins in the reverse-engineered TI-85 schematic... I bet that's them. So, then, basically the entire bus should be accessible... right?

Was there any somewhat standard bus interface for z80 peripherals? And/or standardish such peripherals to be found? (Though, ISA sans interrupts/DMA shouldn't be a stretch)

Anyhow, just more hypothesizing about what sortsa things can be done with this...

...

https://www.eevblog.com/forum/beginners/z80-io-port-address-decoding/

STD-Bus, and yes, cards and backplanes can be bought on ebay... looks like mostly for memory, uarts, and robots... which, of course, can mostly be done better cheaper faster smaller with today's tech. Not sure what I'm digging for, here...

  Are you sure? yes | no