Author Topic: Array Play Time.  (Read 961 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8146
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Array Play Time.
« on: September 16, 2019, 06:52:28 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

daydreamer

  • Member
  • *****
  • Posts: 1511
  • building nextdoor
Re: Array Play Time.
« Reply #1 on: September 16, 2019, 10:47:37 PM »
good :thumbsup: runs fast
array of pointers you see in some HLL searchtree practice
SIMD fan and macro fan
Happy new year 2021 that can only turn out to become better than worse 2020 :)