Timeline for What's the origin of terminating strings by setting the high bit of the last character?
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 31, 2021 at 9:27 | comment | added | supercat | @tofro: Indeed. My point was that there are many other situations where one needs a list of strings, and if one uses a byte to track starting offset, one wouldn't need to keep track of length. As for memory efficiency in non-speed-critical uses, one could cut memory usage to two bytes every three characters pretty easily if that was the goal. | |
| Jul 31, 2021 at 8:53 | comment | added | tofro | @supercat Except that nobody in their right mind would have wasted yet another byte per string for a pointer (or offset) - Typically, the token space was searched linearly to find the proper token - The user waiting didn't cost any ROM space. | |
| Jul 27, 2021 at 21:58 | comment | added | supercat | The approach only really saves a byte per string in cases where one finds the Nth string by scanning through and counting until one has found N bytes with the high bit set. Otherwise, if one has a table of offsets for strings which are stored in order, the length of each string would be the difference between its offset and the next one. | |
| Jul 22, 2021 at 18:48 | comment | added | Peter Cordes | @DrSheldon: Yes, exactly. Or on a 386, btr ax, 7 to clear bit #7 of AL/AX and set CF according to the old value. Else you need to copy or reload the value from memory at the bottom of the loop, after printing it or whatever. | |
| Jul 22, 2021 at 18:12 | comment | added | DrSheldon | @PeterCordes: Good point, but then you would need to AND 7fh instead. | |
| Jul 22, 2021 at 17:47 | comment | added | Peter Cordes | @DrSheldon: If you need to clear the high bit before storing in video RAM or whatever other use, you would need to AND away the high bit. So you do need an extra AND vs. 0-terminated strings, but it's for recovering the 7-bit ASCII characters, not for testing for termination. | |
| S Jul 22, 2021 at 16:55 | history | suggested | vonbrand | CC BY-SA 4.0 | The "length + string" format is called Pascal style. |
| Jul 22, 2021 at 15:55 | review | Suggested edits | |||
| S Jul 22, 2021 at 16:55 | |||||
| Jul 22, 2021 at 15:46 | comment | added | DrSheldon | No need for an AND 80h; most 8-bit processors had conditional branches on the sign bit. | |
| Jul 22, 2021 at 5:43 | history | answered | Martin Maly | CC BY-SA 4.0 |