News:

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

using type of a byte register-

Started by Jimg, February 09, 2009, 02:09:25 AM

Previous topic - Next topic

Jimg

using type to find out the size of a register doesn't work in masm for byte sized registers.
here's the listing (output shifted one line from source, as usual in masm listings (it can't be that hard to output a listing, can it?))

0000065C  B8 00000024
mov eax,opattr(3)   ; immediate
00000661  B8 00000004 ;--------------
00000666  B8 00000004 mov eax,type ebx
0000066B  B8 00000004 mov eax,type eax
00000670  B8 00000004 mov eax,type edx
00000675  B8 00000004 mov eax,type ecx
0000067A  B8 00000004 mov eax,type esi
0000067F  B8 00000004 mov eax,type edi
00000684  B8 00000004 mov eax,type ebp
mov eax,type esp
00000689  B8 00000002 ;---------------
0000068E  B8 00000002 mov eax,type bx
00000693  B8 00000002 mov eax,type cx
00000698  B8 00000002 mov eax,type ax
0000069D  B8 00000002 mov eax,type dx
000006A2  B8 00000002 mov eax,type si
000006A7  B8 00000002 mov eax,type di
000006AC  B8 00000002 mov eax,type bp
mov eax,type sp
000006B1  B8 614E676F ;------
000006B6  B8 00000000 mov eax,type bl ;; these don't work
000006BB  B8 02120000 mov eax,type cl
000006C0  B8 00000000 mov eax,type dl
000006C5  B8 00000000 mov eax,type al
000006CA  B8 00000000 mov eax,type dh
000006CF  B8 61576E65 mov eax,type bh
000006D4  B8 00000000 mov eax,type ch
mov eax,type ah


Ist there some way to trick masm into giving the right values?





  It does work correctly in jwasm, even though the listing is a little strange-
00000660  B824000000       mov eax,opattr(3)   
00000665  B804000000       mov eax,type ebx
0000066A  B804000000       mov eax,type eax
0000066F  B804000000       mov eax,type edx
00000674  B804000000       mov eax,type ecx
00000679  B804000000       mov eax,type esi
0000067E  B804000000       mov eax,type edi
00000683  B804000000       mov eax,type ebp
00000688  B804000000       mov eax,type esp
0000068D  B802000000       mov eax,type bx
00000692  B802000000       mov eax,type cx
00000697  B802000000       mov eax,type ax
0000069C  B802000000       mov eax,type dx
000006A1  B802000000       mov eax,type si
000006A6  B802000000       mov eax,type di
000006AB  B802000000       mov eax,type bp
000006B0  B802000000       mov eax,type sp
000006B5  B801000000       mov eax,type bl
000006BA  B801000000       mov eax,type cl
000006BF  B801000000       mov eax,type dl
000006C4  B801000000       mov eax,type al
000006C9  B801000000       mov eax,type dh
000006CE  B801000000       mov eax,type bh
000006D3  B801000000       mov eax,type ch
000006D8  B801000000       mov eax,type ah


but I would like to have my code work in both.

dedndave

You might try "sizeof" or "lengthof" operators.
I don't have masm installed on this drive just yet, so I can't test it.

sinsi

No problems here...

Microsoft (R) Macro Assembler Version 6.15.8803     02/09/09 13:02:36
type.asm      Page 1 - 1


.386
.model flat,stdcall
option casemap:none
00000000 .code
00000000 start:
00000000  B8 00000024    mov eax,opattr(3)
00000005  B8 00000004    mov eax,type ebx
0000000A  B8 00000004    mov eax,type eax
0000000F  B8 00000004    mov eax,type edx
00000014  B8 00000004    mov eax,type ecx
00000019  B8 00000004    mov eax,type esi
0000001E  B8 00000004    mov eax,type edi
00000023  B8 00000004    mov eax,type ebp
00000028  B8 00000004    mov eax,type esp
0000002D  B8 00000002    mov eax,type bx
00000032  B8 00000002    mov eax,type cx
00000037  B8 00000002    mov eax,type ax
0000003C  B8 00000002    mov eax,type dx
00000041  B8 00000002    mov eax,type si
00000046  B8 00000002    mov eax,type di
0000004B  B8 00000002    mov eax,type bp
00000050  B8 00000002    mov eax,type sp
00000055  B8 00000001    mov eax,type bl
0000005A  B8 00000001    mov eax,type cl
0000005F  B8 00000001    mov eax,type dl
00000064  B8 00000001    mov eax,type al
00000069  B8 00000001    mov eax,type dh
0000006E  B8 00000001    mov eax,type bh
00000073  B8 00000001    mov eax,type ch
00000078  B8 00000001    mov eax,type ah
end start
Light travels faster than sound, that's why some people seem bright until you hear them.

PBrennick

Sinsi tested using v6.15, I tried v6.14 and it works as well.

Quote
            .386
            .model flat,stdcall
            option casemap:none
00000000         .code
00000000         start:
00000000  B8 00000024      mov eax,opattr(3)
00000005  B8 00000004      mov eax,type ebx
0000000A  B8 00000004      mov eax,type eax
0000000F  B8 00000004      mov eax,type edx
00000014  B8 00000004      mov eax,type ecx
00000019  B8 00000004      mov eax,type esi
0000001E  B8 00000004      mov eax,type edi
00000023  B8 00000004      mov eax,type ebp
00000028  B8 00000004      mov eax,type esp
0000002D  B8 00000002      mov eax,type bx
00000032  B8 00000002      mov eax,type cx
00000037  B8 00000002      mov eax,type ax
0000003C  B8 00000002      mov eax,type dx
00000041  B8 00000002      mov eax,type si
00000046  B8 00000002      mov eax,type di
0000004B  B8 00000002      mov eax,type bp
00000050  B8 00000002      mov eax,type sp
00000055  B8 00000001      mov eax,type bl
0000005A  B8 00000001      mov eax,type cl
0000005F  B8 00000001      mov eax,type dl
00000064  B8 00000001      mov eax,type al
00000069  B8 00000001      mov eax,type dh
0000006E  B8 00000001      mov eax,type bh
00000073  B8 00000001      mov eax,type ch
00000078  B8 00000001      mov eax,type ah
            end start

Paul

[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

Jimg

Now try including windows.inc before the code.

Microsoft (R) Macro Assembler Version 6.15.8803     02/08/09 19:19:11
F:\WinAsm\Progs\alltemps\types\tsttype.asm      Page 1 - 1


   .386
.model flat,stdcall
option casemap:none
; nolist to suppress listing of windows.inc
; there is an  "include windows.inc" after the nolist
.nolist
.list

00000000 .code
00000000 start:
00000000  B8 00000024    mov eax,opattr(3)
00000005  B8 00000004    mov eax,type ebx
0000000A  B8 00000004    mov eax,type eax
0000000F  B8 00000004    mov eax,type edx
00000014  B8 00000004    mov eax,type ecx
00000019  B8 00000004    mov eax,type esi
0000001E  B8 00000004    mov eax,type edi
00000023  B8 00000004    mov eax,type ebp
00000028  B8 00000004    mov eax,type esp
0000002D  B8 00000002    mov eax,type bx
00000032  B8 00000002    mov eax,type cx
00000037  B8 00000002    mov eax,type ax
0000003C  B8 00000002    mov eax,type dx
00000041  B8 00000002    mov eax,type si
00000046  B8 00000002    mov eax,type di
0000004B  B8 00000002    mov eax,type bp
00000050  B8 00000002    mov eax,type sp
00000055  B8 00000464    mov eax,type bl
0000005A  B8 00000001    mov eax,type cl
0000005F  B8 40000046    mov eax,type dl
00000064  B8 00000004    mov eax,type al
00000069  B8 40000027    mov eax,type dh
0000006E  B8 00000010    mov eax,type bh
00000073  B8 00000002    mov eax,type ch
00000078  B8 00004013    mov eax,type ah
0000007D  C3    ret
end start

sinsi

heh heh

00000055  B8 00000001    mov eax,type bl
0000005A  B8 0000006B    mov eax,type cl
0000005F  B8 00000001    mov eax,type dl
00000064  B8 00000100    mov eax,type al
00000069  B8 00000008    mov eax,type dh
0000006E  B8 00000192    mov eax,type bh
00000073  B8 00000064    mov eax,type ch
00000078  B8 0000002D    mov eax,type ah

a bit random too, compared with yours.
Light travels faster than sound, that's why some people seem bright until you hear them.

Jimg

I'm sure this is documented somewhere, it's a nasty bug for me. :dazzled:

PBrennick

Intersting to say the least and for me, bothersome. What is it about windows.inc that could cause this type of impact?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

sinsi

ml7 doesn't do it, because...

"include winextra.inc"
Quote
comment * ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

        winextra.inc is the second part of the windows.inc file that is
        called by an "include" directive at the end of windows.inc.

        This technique of splitting the windows.inc file is used to avoid
        the 32k line count limit in ML.EXE versions 6.14 and 6.15. The later
        32 bit versions of ML.EXE are not effected by this limit.

        This file is covered by the copyright in windows.inc.

        ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ *

Never actually had a look at windows.inc  :bdg
Light travels faster than sound, that's why some people seem bright until you hear them.

Jimg

I made a copy of windows.inc and stuck some code periodically.  Here's it working and not with just a few lines in between.   I don't see anything that should have affected bl.

      C .list
00000050  B8 00000001       C    mov eax,type bl
00000055  B8 00000001       C    mov eax,type cl
0000005A  B8 00000001       C    mov eax,type dl
0000005F  B8 00000001       C    mov eax,type al
00000064  B8 00000001       C    mov eax,type dh
00000069  B8 00000001       C    mov eax,type bh
0000006E  B8 00000001       C    mov eax,type ch
00000073  B8 00000001       C    mov eax,type ah
      C EDITWORDBREAKPROC           typedef DWORD
      C ENHMFENUMPROC               typedef DWORD
      C ENUMRESLANGPROC             typedef DWORD
      C ENUMRESNAMEPROC             typedef DWORD
      C ENUMRESTYPEPROC             typedef DWORD
      C FARPROC                     typedef DWORD
      C FILE_SEGMENT_ELEMENT        typedef DWORD
00000078  B8 0000FF06       C    mov eax,type bl
0000007D  B8 00000001       C    mov eax,type cl
00000082  B8 00000001       C    mov eax,type dl
00000087  B8 00000001       C    mov eax,type al
0000008C  B8 00000001       C    mov eax,type dh
00000091  B8 00000001       C    mov eax,type bh
00000096  B8 00000001       C    mov eax,type ch
0000009B  B8 00000001       C    mov eax,type ah


edit: no winextra in my windows.inc

PBrennick

just for grins I tried kernel32.inc and it fails, also. Just had to verify it is not a 'content' issue.

kernel32.inc, by the way, only has a little over 1200 lines, so .........

Paul
The GeneSys Project is available from:
The Repository or My crappy website

sinsi

ml7 and ml8 are correct, only ml6 has the problem.
Quoteavoid the 32k line count limit in ML.EXE versions 6.14 and 6.15.
Maybe he means the 32k filesize count?
Light travels faster than sound, that's why some people seem bright until you hear them.

GregL

Quoteml7 and ml8 are correct, only ml6 has the problem

Yeah, we ran into this before. Hutch wrote a nice macro that deals with the problem, it's called regsize and it's in macros.asm.


Paul,

Good to see you back.


Jimg

I had already written my own workaround-

  ;; note: arg = "xx reg" in my macro, that's why i'm looking at substr(arg,4)
            bcnt=4    ;; assume 4 bytes
            opxttr = opattr(@SubStr(arg,4))
            if opxttr eq 110000y ;; 30h a register
                if @SizeStr(@SubStr(arg,4)) eq 2
                    ifidni @SubStr(arg,5),<h>
                        bcnt=1   ;; a byte (ah,bh,ch,dh)
                    else
                        ifidni @SubStr(arg,5),<l>
                            bcnt=1  ;; a byte (al,bl,cl,dl)
                        else
                            bcnt=2    ; was a word (ax,bx,si, etc.)
                        endif
                    endif
                endif