News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Byte count of registers or variables

Started by JK, May 31, 2020, 08:22:10 PM

Previous topic - Next topic

JK

@Hutch


i´m referring to this (http://masm32.com/board/index.php?topic=5568.msg59413#msg59413) post. How did you do it? There is no code or further explanation. Would you like to explain it or post the corresponding code/macro?

Thanks


JK

jj2007

Needs UAsm, AsmC or a MASM version above 8.0 (6.14 and 6.15 don't like the OWORD):

include \masm32\include\masm32rt.inc
.xmm

showbytes macro args:VARARG
Local tmp$, ta
  for arg, <args>
ta = type arg
tmp$ CATSTR <bytes &arg = >, %ta
% echo tmp$
  ENDM
ENDM

.data
MyArray dd 25, 18, 23, 17, 9, 2, 6
HelloW$ db "Hello World", 0
MyQ QWORD 12346578901234567890
MyO OWORD 12346578901234567890

.code
start:
  showbytes HelloW$, al, cx, eax, MyArray, MyQ, ST(0), xmm0, MyO, DWORD PTR MyO
  .err
  exit

end start

hutch--

JK,

Is this what you were after ? 64 bit MASM. Given its about 4 years ago, from memory I did it the hard way, kept testing until the results matched the input data sizes.

  ; -------------------------
  ; determine an operand type
  ; -------------------------
    op_type MACRO arg:REQ
      LOCAL result
      result = opattr(arg)
        IF result eq 37         ;; label, either local or global
          EXITM %1
        ELSEIF result eq 42     ;; GLOBAL var
          EXITM %2
        ELSEIF result eq 98     ;; LOCAL  var
          EXITM %3
        ELSEIF result eq 36     ;; immediate operand or constant
          EXITM %4
        ELSEIF result eq 48     ;; register
          EXITM %5
        ELSEIF result eq 805    ;; local procedure in code
          EXITM %6
        ELSEIF result eq 933    ;; external procedure or API call
          EXITM %7
        ENDIF
      EXITM %0                  ;; anything else
    ENDM