News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

array problems

Started by petezl, January 23, 2005, 12:02:00 PM

Previous topic - Next topic

petezl

I half completed this a couple of years ago but lost what I had done. Basically this is what I was trying to do.
1) Start with a comma delimited txt file consisting of 5 numbers on each line, Ie. five columns of numbers, none exceeding 999:
123,222,245,62,577,
178,649,34,36,296,
etc
etc...
These files won't exceed much more than about 1kb (it's the hardcopy output from a data logger).

2) read the file in it's entirity into an array (GlobalAlloc perhaps).
3) Copy the contents of this array into a dword array [5][length of column] maybe HeapAlloc.
4) Now I want to read this new array to draw 5 lines (plots) in a window.
Question:
Is this the best way to do it?
I can achieve 1,2, probably 4, stuck with 3.
I need eventually to read the array several times at differing speeds, I'm not interested too much about optomisation, more a case of getting it to work and understand whats happening.
Any help appreciated.
Peter.
Cats and women do as they please
Dogs and men should realise it.

hutch--

Peter,

There are a couple of approaches that should do the job, you can just read it into a buffer and work on it any way you like or read t into a buffer then copy it into an existing array that is addressed in whatever way you like. To read it in there is a proc in the MASM32 library that wil split up each line into seperate arguments so it may be worth trying it out. The proc is,

parse_line proc src:DWORD,array:DWORD
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

petezl

Thanks Hutch, I 'll play around with it and see what I can do.
Peter.
Cats and women do as they please
Dogs and men should realise it.

petezl

Hutch,
I'm having trouble locating that proceedure. I have the latest Masm download installed. Can you confirm that the "parse_line proc"  name ia correct?
Peter.
Cats and women do as they please
Dogs and men should realise it.

pbrennick

petezl,
It is contained in parsline.asm which is in the m32lib folder.  You can invoke it after you include masm32.inc and its library.
Paul

petezl

Thanks Paul. I'll check it out!
Peter.
Cats and women do as they please
Dogs and men should realise it.

petezl

Hi Paul, It isn't in there! Ive just downloade d fresh package and installed it and no Parseline anything can be found anywhere...
The nearest thing to it is the two qsorts which are also itemised in the help files.
Peter.
Cats and women do as they please
Dogs and men should realise it.

pbrennick

RU looking in \masm32\m32lib ?  It is in my folder.
Paul

pbrennick

petezl,

Anyway, this is the function:


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                      ; force 32 bit code
    .model flat, stdcall      ; memory model & calling convention
    option casemap :none      ; case sensitive

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

.data
  align 4
  ctbl \
    db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0
    db 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
    db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    db 1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1
    db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    db 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

    ;   allowable character range
    ;   -------------------------
    ;   upper & lower case characters
    ;   numbers
    ;   " "           ; quotation marks
    ;   [ ]           ; address enclosure
    ;   + - *         ; displacement and multiplier calculation
    ;   :             ; label identification

.code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

align 4

parse_line proc src:DWORD,array:DWORD

    push esi
    push edi

    mov esi, src                        ; line in ESI
    mov edi, array                      ; word array in EDI
    mov ecx, [edi]                      ; 1st array member address in ECX
    xor eax, eax                        ; clear EAX
    xor edx, edx                        ; set arg counter to zero

  ; ----------------------------------
  align 4
  badchar:
    mov al, [esi]
    add esi, 1
    test al, al                         ; test if byte is terminator
    jz gaout
    cmp BYTE PTR [eax+ctbl], 1          ; is it a good char ?
    jne badchar
    add edx, 1                          ; add to arg counter
    jmp writechar
  goodchar:
    mov al, [esi]
    add esi, 1
    test al, al                         ; test if byte is terminator
    jz gaout
    cmp BYTE PTR [eax+ctbl], 0          ; is it a bad char ?
    je reindex
  writechar:
    cmp al, "["                         ; test for opening square bracket
    je wsqb                             ; branch to handler if it is
    cmp al, 34                          ; test for opening quotation
    je preq                             ; branch to quote handler if it is
    mov [ecx], al                       ; write byte to buffer
    add ecx, 1
    jmp goodchar
  ; ----------------------------------
  align 4
  reindex:
    mov BYTE PTR [ecx], 0               ; write terminator to array member
    add edi, 4                          ; index to next array member
    mov ecx, [edi]                      ; put its address in ECX
    jmp badchar
  ; ----------------------------------
  align 4
  preq:
    mov [ecx], al                       ; write byte to buffer
    add ecx, 1
  quotes:                               ; quotation handler
    mov al, [esi]
    add esi, 1
    test al, al                         ; test if byte is terminator
    jz qterror                          ; jump to quotation error
    cmp al, 32
    je quotes
  wqot:
    mov [ecx], al                       ; write byte to buffer
    add ecx, 1
    cmp al, 34                          ; test for closing quote
    je reindex
    jmp quotes

  align 4
  squareb:                              ; square bracket handler
    mov al, [esi]
    add esi, 1
    test al, al                         ; test if byte is terminator
    jz sberror                          ; jump to square bracket error
    cmp al, 32
    je squareb
  wsqb:
    mov [ecx], al                       ; write byte to buffer
    add ecx, 1
    cmp al, "]"
    je reindex
    jmp squareb
  ; ----------------------------------
  align 4
  qterror:                              ; quotation error
    mov ecx, 2                          ; set ECX as 2
    jmp gaquit                          ; no closing quoation

  align 4
  sberror:                              ; square bracket error
    mov ecx, 1                          ; set ECX to 1
    jmp gaquit                          ; no closing square bracket

  align 4
  gaout:
    mov BYTE PTR [ecx], 0               ; terminate last buffer written to.
    add edi, 4
    mov ecx, [edi]
    mov BYTE PTR [ecx], 0               ; set next buffer with leading zero
    xor ecx, ecx                        ; ECX set to zero is NO ERROR
  gaquit:
    mov eax, edx                        ; return arg count

    pop edi
    pop esi

    ret

parse_line endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end


Paul

petezl

Paul, Yes , I'm looking in the right folder, this is so strange. Anyway, Thanks for the copy.

Peter.
Cats and women do as they please
Dogs and men should realise it.

pbrennick

petezl,
Send a message to Hutch with the download version information and report the problem.  These things can happen with such a large bundle of programs.

Paul

petezl

Paul, Hutch,
The package in question was download direct from Hutches site at the weekend so is the latest version v8.2 which unzipped and installed without problems. I'll zip and send the m32lib if it helps!
Peter.
Cats and women do as they please
Dogs and men should realise it.

hutch--

Peter,

Go to the forum web site and get the service pack for version 8.2, I forget off the top of my head when I added it but the service pack had some new stuff in it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

petezl

Thanks Hutch,
I've just downloaded it, will have to boot into widows to install it so will get back to you later.
Peter.
Cats and women do as they please
Dogs and men should realise it.

petezl

Hutch,
Everything is ok now that sp1 is installed, I'm so impetuous, should have scrolled to the bottom of the download page.
Peter.
Cats and women do as they please
Dogs and men should realise it.