News:

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

Main Menu

Question about TYPEDEF in masm

Started by StillLearningMasm, April 13, 2019, 07:48:31 PM

Previous topic - Next topic

LiaoMi

Quote from: AW on May 07, 2019, 02:37:16 PM
Quote
We've got a fix for this and I expect it to ship in the 16.2 release.

:t

Thank you! Is this https://developercommunity.visualstudio.com/content/problem/508122/masm-invoke-with-a-3-byte-struct.html the last bug that remains to be fixed? Nidud also follows the news  :P

aw27

Quote from: LiaoMi on May 07, 2019, 05:42:53 PM
Thank you! Is this https://developercommunity.visualstudio.com/content/problem/508122/masm-invoke-with-a-3-byte-struct.html the last bug that remains to be fixed? Nidud also follows the news  :P

Yes, Mark Gardner is also with that one. After that, MASM will be 100% bug free.  :badgrin:

StillLearningMasm

AW,
I thought I had a understanding of the TYPEDEF instruction when I examined you sample code. I attempted to change your sample code to the enclosed listing.
However I am getting the following errors from the assembler:

Lines  26,27,30 and 31 Invalid use of register


.486

.model medium,stdcall

printf proto near C :ptr, :vararg
ExitProcess proto near :dword

label1 typedef ptr proc
label2 typedef proc

.data
msg db "Hello from called function",10,0

.code

myFunc proc near
invoke printf, addr msg
ret
myFunc endp

main proc near
mov esi, myFunc
call esi
call label1 ptr esi
call label2 ptr esi
lea esi, myFunc
call esi
call label1 ptr esi
call label2 ptr esi

push 0
call ExitProcess
main endp
End


Output:
end


I noticed that Label1 is always a far ptr even though I never defined it that way. I also did not find any way to make it a near ptr.
As you can see I am trying to make it a near subroutine not a far subroutine. What am I doing wrong? Is PROC a distance or a size for the pointer?

Thank you for your help.

aw27

Quote from: StillLearningMasm on May 09, 2019, 06:32:18 AM
AW,
I thought I had a understanding of the TYPEDEF instruction when I examined you sample code. I attempted to change your sample code to the enclosed listing.
However I am getting the following errors from the assembler:

Lines  26,27,30 and 31 Invalid use of register


.486

.model medium,stdcall

printf proto near C :ptr, :vararg
ExitProcess proto near :dword

label1 typedef ptr proc
label2 typedef proc

.data
msg db "Hello from called function",10,0

.code

myFunc proc near
invoke printf, addr msg
ret
myFunc endp

main proc near
mov esi, myFunc
call esi
call label1 ptr esi
call label2 ptr esi
lea esi, myFunc
call esi
call label1 ptr esi
call label2 ptr esi

push 0
call ExitProcess
main endp
End


Output:
end


I noticed that Label1 is always a far ptr even though I never defined it that way. I also did not find any way to make it a near ptr.
As you can see I am trying to make it a near subroutine not a far subroutine. What am I doing wrong? Is PROC a distance or a size for the pointer?

Thank you for your help.

Have a look at the previous thread, http://masm32.com/board/index.php?topic=7837.msg85924#msg85924

And in the 32-bit flat model there is no difference between near and far procedure calls. They are all the same, you don't it to qualify calls with near or far.

StillLearningMasm

AW,
Thank you for the reply. I looked at that link but I still do not understand why I am getting those error messages. What do I need to do to fix them?

Thank you for your help.

StillLearningMasm

AW,
You have in your code the instruction:

call label1 ptr esi

I have not seen a ptr register combination after a call instruction (I did not even know that it was possible). Where do I find information on this?

Thank you

aw27

Quote from: StillLearningMasm on May 09, 2019, 08:14:44 AM
AW,
Thank you for the reply. I looked at that link but I still do not understand why I am getting those error messages. What do I need to do to fix them?

Thank you for your help.

Model is FLAT not Medium. In 32-bit and 64 bit Windows the only model is FLAT.

aw27

Quote from: LiaoMi on May 07, 2019, 05:42:53 PM
Quote from: AW on May 07, 2019, 02:37:16 PM
Quote
We've got a fix for this and I expect it to ship in the 16.2 release.

:t

Thank you! Is this https://developercommunity.visualstudio.com/content/problem/508122/masm-invoke-with-a-3-byte-struct.html the last bug that remains to be fixed? Nidud also follows the news  :P

The 3 BYTE STRUCT bug will be fixed in VS 2019 release 16.3. Now we are at 16.1

hutch--

StillLearningMasm,

There is an inherent problem in the questions you ask in that have not explained what OS you are targeting and what version of MASM reference material you are using. You have kept using MS-DOS notation while trying to use 32 bit registers and combinations of this type simply do not work. If you want to write 16 bit DOS code, we have a sub forum for that but if you want to write 32 or 64 bit code you need to change the reference material you are using to properly address the OS version that support 32 and 64 bit code.

This is the bare minimum to write 32 bit MASM code.

      .486                                      ; create 32 bit code
      .model flat, stdcall                      ; 32 bit memory model
      option casemap :none                      ; case sensitive

If you are trying to write modern 32 bit code you would use,

      .686p                                     ; create 32 bit code
      .MMX
      .XMM
      .model flat, stdcall                      ; 32 bit memory model
      option casemap :none                      ; case sensitive

LiaoMi

Quote from: AW on June 03, 2019, 03:46:14 AM
Quote from: LiaoMi on May 07, 2019, 05:42:53 PM
Quote from: AW on May 07, 2019, 02:37:16 PM
Quote
We've got a fix for this and I expect it to ship in the 16.2 release.

:t

Thank you! Is this https://developercommunity.visualstudio.com/content/problem/508122/masm-invoke-with-a-3-byte-struct.html the last bug that remains to be fixed? Nidud also follows the news  :P

The 3 BYTE STRUCT bug will be fixed in VS 2019 release 16.3. Now we are at 16.1

Hi AW,

good news  :thup:, I hope they will not postpone the release for half a year, as they like to do, because most recently versions have already been updated to the new number 14.21.27702 ..

aw27

Hi LiaoMi,

Since they had nothing new to show for a long time, I am expecting these bug fixes will change significantly the release numbers.  :badgrin:

aw27

VS 2019 16.2 is out, apparently the bug is fixed.
This one: https://developercommunity.visualstudio.com/content/problem/537068/masm-buffer-overflow-with-variable-named-as-fake-t.html