PokeMon wrote:zx81user wrote:I wanted to use the keyboard to set the time for my clock (using 0 - 9, and some letters for setting hours, minutes etc). However, while programming this, I realized the program was never going to fit within 1k no more so I abandoned the idea and went for a simple basic solution (INPUT A$) and read A$ within the assembly program. This solution was only like 30 bytes in total or something like that.
Michel
No I don't think that this hits 1k. It's more complex in BASIC, creating variables, line numbers, line lenght, decimals (integers) coded as both ASCII and floating point.
For reading 0-9 you just need two IN instructions for both "half-rows" 0-4 and 5-9.
I think you maybe choosed an EXPANDED display file which takes about 800 bytes in general without any code.
In the ZX-IDE you can set DFILE to either EXPANDED or COLLAPSED.
For the 1k you should always use collapsed.
I am only guessing but you can code much in 1k assembler.
Sure that is true, but if I would do everything in the clock software itself, there is a lot more that needs to be done. For example, I need to press a button and set the clock into settings mode, blinking the hours, then I need to read the keyboard, convert the numbers into a BCD code, store it somewhere, advance to the next item (minutes), blink the minutes, stop the seconds, read keyboard etc etc until finally someone presses the button to "start the clock". It's not only just reading a few digits, it's all the other bits and pieces that make setting the clock that way work.
Now I just do a read a$ in BASIC which is 8 bytes; then it needs some storage for the variable (7 bytes) to read 4 numbers (HHMM), then I read this in assembly and move it to my own buffer substracting the number 28 (22 bytes), then convert it into BCD (26 bytes). Total requires 63 bytes (ok, I was a bit too optimistic with my 30 bytes though
). I could probably combine the move/substract routine and BCD conversion into 1 routine saving a few bytes. Anyway, now try to write a time set routine that can do all that in assembler in less than 63 bytes. I don't think it can be done.
Michel