|
Forum Index : Microcontroller and PC projects : string array csub/cfunction generator
| Author | Message | ||||
| Nathan Regular Member Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi, I have written a small exe(win10) file, which generates cfunctions/csubs based on a simple text(ascii) input file. The program is in an early stage and everyone, who helps to debug is welcome. Please run a visrus scan on it, before you use it. 2017-11-27_012413_stringArrayFunGen.zip I'm really looking for feedback. Is the executable running on your system? (MinGW, gcc was used and I'm not sue if the executable need some libs of MinGW) (powershell?) Now the details: stringArrayFunGen.exe generates a Csub or Cfunction basic block, which can be included into your program. The input is a simple ASCII text file. Every line generates a new array entry, wich can be accessed by user index entry. There are up to 6 replacement entries possible. The following entries are used as repleament sequence specifiers within yout text: @0 @1 @2 @3 @4 @5 1.) Example: test.txt This is the first line This is the secondline stringArrayFunGen.exe -t test.txt -p test.bas generate the following output file test.bas: 'constString (index,outString) CSub constString integer string 0000000C 'getFPCx 27BDFFE8 10800003 AFBF0014 10000005 03E41023 3C049D00 24840024 0411FFF8 00000000 8FBF0014 03E00008 27BD0018 'm 27BDFFE0 AFBF001C AFB10018 AFB00014 00808021 00A08821 00002021 0411FFEC 00000000 3C039D00 246300D0 00621021 12000016 94430000 16200003 8E040000 10000012 AE030000 24840001 0083282B 0085180B 00031840 00431821 94630000 00431821 90650000 00052882 00001021 8C640000 AE240000 24420001 24630004 00A2202B 1080FFFA 26310004 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 '.rodata 00080002 00000020 69685416 73692073 65687420 72696620 6C207473 00656E69 69685416 73692073 65687420 63657320 6C646E6F 00656E69 End CSub Example usage: DIM my$ constString(0,my$) print my$ constString(1,my$) print my$ ------------------------------------------------------------------------------ 2.) Example: test.txt This is the first line This is the secondline stringArrayFunGen.exe -t test.txt -p testFunction.bas -cfunction generates the following output file testFunction.bas: 'outString = constString (index) CFunction constString (integer) string 0000000C 'getFPCx 27BDFFE8 10800003 AFBF0014 10000005 03E41023 3C049D00 24840024 0411FFF8 00000000 8FBF0014 03E00008 27BD0018 'm 27BDFFE0 AFBF001C AFB10018 AFB00014 00808021 00002021 0411FFED 00000000 3C119D00 263100EC 02228821 1200001D 96220000 8E030000 24630001 0043202B 10800004 00031840 AE020000 00401821 00031840 02231821 94620000 02228821 92300000 00108082 3C029D00 8C420040 0040F809 24040100 00402021 00001821 8E250000 AC850000 24630001 26310004 0203282B 10A0FFFA 24840004 10000003 8FBF001C 00001021 8FBF001C 8FB10018 8FB00014 03E00008 27BD0020 '.rodata 00080002 00000020 69685416 73692073 65687420 72696620 6C207473 00656E69 69685416 73692073 65687420 63657320 6C646E6F 00656E69 End CFunction Example usage: DIM my$ my$ = constString(0) print my$ my$ = constString(1) print my$ -------------------------------------------------------------------------------------- 1.) Example: test.txt This @0 the @1 line This @0 the @1 line Generation flow is the same as above. The generated functions are a little bit different Example usage(csub): DIM my$ constString(0,my$,"is","first") print my$ constString(1,my$,"was","last") print my$ Example usage (cfunction): DIM my$ my$ = constString(0,"is","first") print my$ my$ = constString(1,"was","last") print my$ The followings shows the help page of the program >stringArrayFunGen.exe stringArrayFunGen.exe V0.9 Copyright 2017 by Nathan WARNING: ***** unstable evaluation version ***** Usage: stringArrayFunGen.exe <-textin <file>> <-progout <file>> [-cfunction] [-help] -(t)extin <file> read ascii input file -(p)rogout <file> write basic function file -cfunction create cfunction instead of csub -help show this page .abnormal end |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hi Nathan, NEAT! Thanks a lot. I've tested the first example with Win 7 and I get the identical result. I will further examine ... I think this can be a useful replacement for the time and space-consuming DATA-READ procedure in Basic be. Regards Michael causality ≠ correlation ≠ coincidence |
||||
| Nathan Regular Member Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi Michael, Hallo Michael, thanks for the test. danke fuer den Test. What do you think does it make sense to implement something similar for integer input? Was meinst Du macht es Sinn etwas aehnliches fuer Integer zu integrieren? At the moment I'm thinking about the following: Im Moment denke ich ueber folgendes nach: :<identifier> -- start of new data segement ":" <identifier> <b> byte, <s> short_16, <i> int_32, <l> int_64 :<s> 122, 33, 44, 56, 554, 666, 777, 888, 8888 ... :<b> 56, 445, 77, 88, 99, 99, @0, @2, ... The data would be copied into an c%-array. Die Daten wuerden dann in ein c%-Array kopiert. Does this make sense? Macht das Sinn? Nathan |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hi Nathan, there is no need to translate to german! Thanks anyway! Yes, I didn't dare to ask for it! If you store numbers into a cfunction you can save a lot of memory! Espacially the different number formats are a very good idea. :<b> 56, 445, 77, 88, 99, 99, @0, @2, ... What stands the "@" for? hmm (superior attitude) "445" would not fit into a byte. Why not implement a binary number format too? causality ≠ correlation ≠ coincidence |
||||
| Nathan Regular Member Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi Michael, >hmm (superior attitude) >"445" would not fit into a byte. you haven't seen my bytes Of course that's an mistake in specification. Say someone: I'm a typical german The @ is a place holder with an index, similar is already available for the strings (please take a look ono the end of the first blog entry). For Example: :<s> 1, 2, 3, @0, @1, 3, 2, 1 The cfunction/csub have the following additional fields: cfunction ..., @0, @1, @2, @3, @4, @5 so in total 6 values can be inserted automatically. cfunction ..., 99, 300 would generate the following 1, 2, 3, 99, 300, 3, 2, 1 If the specification was: :<s> 1, 2, 3, @0, @1, @0, 2, 1 then you would get: 1, 2, 3, 99, 300, 99, 2, 1 Nathan |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hmm, I understand but I see a lot of problems about the error handling. What's happened if the numbers not fit for that number format? I'm not sure if this is a desirable feature for numbers. For strings it makes sense. But it's of course your decision. causality ≠ correlation ≠ coincidence |
||||
| Nathan Regular Member Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi Michael, >I'm not sure if this is a desirable feature for numbers. For strings it makes sense. >But it's of course your decision. I have some RS232 modules, which requires embeded controls inside of the send data. >Hmm, I understand but I see a lot of problems about the error handling. >What's happened if the numbers not fit for that number format? Good point, I thought already about it, but did not found a good solution. I will need some additional information - endian.., split number ... The C-Code will get to big and this is my problem at the moment. So any implementation idea is welcome. First implementation will be without @. Nathan |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Hi Nathan, did you see my edit above? This could be useful for example for a signal generator or to control output pins etc. I see, accepted! causality ≠ correlation ≠ coincidence |
||||
| Nathan Regular Member Joined: 10/01/2016 Location: GermanyPosts: 49 |
Hi, sorry I was offline over the week. I'm still coding. The following number format will be supported: Positiv numbers 0b00000111111 - binary 0x000000000ff - hex 03 - octal number starts with 0 32222 - normal integer negative numbers -0b0000001111 -0xfff0000000 -03 -322222 At the moment I'm in trouble with the following numbers 0xffffffffffffffff 0x7fffffffffffffff So it will take a little bit till a test version will be available. Nathan |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |