News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Array Play Time.

Started by hutch--, September 16, 2019, 06:52:28 PM

Previous topic - Next topic

hutch--

Just wanted to test an idea with an array of pointers to data where you only had to return one value for its address and get the member count.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .data
      @1 db "one",0
      @2 db "two",0
      @3 db "three",0
      @4 db "four",0
      @5 db "five",0
      @6 db "six",0
      @7 db "seven",0
      @8 db "eight",0
      align 8
      dq 8                                  ; array count
      parr1 dq @1,@2,@3,@4,@5,@6,@7,@8      ; pointer array

      ?1 db ".one",0
      ?2 db ".two",0
      ?3 db ".three",0
      ?4 db ".four",0
      ?5 db ".five",0
      ?6 db ".six",0
      ?7 db ".seven",0
      ?8 db ".eight",0
      align 8
      dq 8                                  ; array count
      parr2 dq ?1,?2,?3,?4,?5,?6,?7,?8      ; pointer array

      $1 db "-one",0
      $2 db "-two",0
      $3 db "-three",0
      $4 db "-four",0
      $5 db "-five",0
      $6 db "-six",0
      $7 db "-seven",0
      $8 db "-eight",0
      align 8
      dq 8                                  ; array count
      parr3 dq $1,$2,$3,$4,$5,$6,$7,$8      ; pointer array

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    USING r12,r13

    SaveRegs

  ; -----------------------------------------

    lea r12, parr1                          ; load the array address
    mov r13, [r12-8]                        ; get count from 8 bytes below parr1
  @@:
    conout QWORD PTR [r12],lf               ; loop through count of members
    add r12, 8
    sub r13, 1
    jnz @B

  ; -----------------------------------------

    lea r12, parr2                          ; load the array address
    mov r13, [r12-8]                        ; get count from 8 bytes below parr2
  @@:
    conout QWORD PTR [r12],lf               ; loop through count of members
    add r12, 8
    sub r13, 1
    jnz @B

  ; -----------------------------------------

    lea r12, parr3                          ; load the array address
    mov r13, [r12-8]                        ; get count from 8 bytes below parr3
  @@:
    conout QWORD PTR [r12],lf               ; loop through count of members
    add r12, 8
    sub r13, 1
    jnz @B

  ; -----------------------------------------

    waitkey
    RestoreRegs
    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

daydreamer

good :thumbsup: runs fast
array of pointers you see in some HLL searchtree practice
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding