Author Topic: 64bit atoqw or qwtoa in any library  (Read 2971 times)

jj2007

  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: 64bit atoqw or qwtoa in any library
« Reply #15 on: May 21, 2015, 06:55:25 AM »
Batch processing a whole lot of string numbers (reading a large data file full of integer number strings)

How big? Can you post an example file? It could be a candidate for StringToArray():

include \masm32\MasmBasic\MasmBasic.inc      ; download
.data
txtData      db "12.34 56.78 90.12 34.56 78.90 12.34 $FF", 13, 10
      db "-12.34 -56.78 -90.12 -34.56 -78.90 -12.34 0xFF 1111b 1.234e56", 0      ; see Val

  Init
  Dim MyData() As REAL8      ; could also be WORD, DWORD, QWORD, REAL4, REAL10
  StringToArray offset txtData, MyData()      ; do the conversion from text to binary
  For_ ecx=0 To eax
      Print Str$("%i\t", ecx), Str$("%4f\n", MyData(ecx))
  Next
  Inkey Str$("%i elements found", ecx)
  Exit
end start


Output:
Code: [Select]
0       12.34
1       56.78
2       90.12
3       34.56
4       78.90
5       12.34
6       255.0
7       -12.34
8       -56.78
9       -90.12
10      -34.56
11      -78.90
12      -12.34
13      255.0
14      15.00
15      1.234e+56
16 elements found

P.S.: StringToArray FileRead$("Data.txt"), MyData() is also valid syntax.

K_F

  • Member
  • *****
  • Posts: 1291
  • Anybody out there?
Re: 64bit atoqw or qwtoa in any library
« Reply #16 on: May 21, 2015, 03:12:57 PM »
Batch processing a whole lot of string numbers (reading a large data file full of integer number strings)
How big?
I'm thinking of anywhere from 1K to 64Ks worth of just numbers
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: 64bit atoqw or qwtoa in any library
« Reply #17 on: May 21, 2015, 04:34:45 PM »
64k will take about one millisecond with StringToArray.

K_F

  • Member
  • *****
  • Posts: 1291
  • Anybody out there?
Re: 64bit atoqw or qwtoa in any library
« Reply #18 on: May 21, 2015, 04:46:09 PM »
Interesting...Is StringToArray available for perusal  :biggrin:

I might add that I'm looking at converting to/from a text file, (un)signed integers 8/16/32/64bits and floats (Real-4/8&10)
 :t
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: 64bit atoqw or qwtoa in any library
« Reply #19 on: May 21, 2015, 04:49:23 PM »
Sure, just install MB, the link is below.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Dim MyData() As REAL8      ; could also be WORD, DWORD, QWORD, REAL4, REAL10
  StringToArray FileRead$("DataBig.txt"), MyData(), staHasText
  For_ ecx=0 To eax
      .if !(ecx & 15)
            Print Str$("\n%__i\t", ecx)
      .endif
      Print Str$("%4f\t", MyData(ecx))
  Next
  Inkey Str$("\n%i elements found", ecx)
  Exit
end start

dedndave

  • Member
  • *****
  • Posts: 8748
  • Still using Abacus 2.0
    • DednDave
Re: 64bit atoqw or qwtoa in any library
« Reply #20 on: May 21, 2015, 08:17:47 PM »
i don't think that's what he meant - lol