News:

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

Main Menu

When should arguments be declared as pointers?

Started by kkurkiewicz, July 06, 2024, 03:55:21 AM

Previous topic - Next topic

jj2007

Quote from: NoCforMe on July 06, 2024, 08:35:53 AMThere's not even any distinction, type-wise, between signed and unsigned variables

Quote from: NoCforMe on July 06, 2024, 09:47:26 AMWell, there is if you use macros

You know why there is the "M" in "MASM", right? Calling .if a "macro" is absurd. Be careful what you write in The Campus.

_japheth

Quote from: kkurkiewicz on July 06, 2024, 04:09:12 AMSo it is just a matter of personal preference, isn't it?

It depends. If you need to debug your code, using PTR combined with a type can greatly simplify the task. That's because the codeview debug information has all type information included that the debugger needs to know. So, for example, if the argument is a pointer to a STRUCT, the debugger will allow you'll to watch all members of that struct inside the PROC.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

NoCforMe

Which debugger? Certainly not Olly, I don't think.
Assembly language programming should be fun. That's why I do it.

_japheth

Quote from: NoCforMe on July 06, 2024, 06:22:01 PMWhich debugger? Certainly not Olly, I don't think.

never used OllyDbg. But all debuggers based on the MS Debug Engine should be ok. Even the ancient CodeView for DOS had that capability.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

Greenhorn

Quote from: _japheth on July 06, 2024, 06:18:55 PM
Quote from: kkurkiewicz on July 06, 2024, 04:09:12 AMSo it is just a matter of personal preference, isn't it?

It depends. If you need to debug your code, using PTR combined with a type can greatly simplify the task. That's because the codeview debug information has all type information included that the debugger needs to know. So, for example, if the argument is a pointer to a STRUCT, the debugger will allow you'll to watch all members of that struct inside the PROC.


Quote from: _japheth on July 06, 2024, 06:51:10 PM
Quote from: NoCforMe on July 06, 2024, 06:22:01 PMWhich debugger? Certainly not Olly, I don't think.

never used OllyDbg. But all debuggers based on the MS Debug Engine should be ok. Even the ancient CodeView for DOS had that capability.

I can confirm this.
With VS Debugger it's very useful and comfortable. WinDbg should also do the job.
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

daydreamer

I gonna try to random shuffle dword pointers for my card game than complete data for each card must become faster
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

jj2007

include \masm32\include\masm32rt.inc
.code
MyTest proc arg1
Local rc:RECT
Local prc:PTR RECT
  mov rc.left, 111h
  mov rc.top, 222h
  mov rc.right, 333h
  mov rc.bottom, 444h
  lea eax, rc
  int 3
  mov prc, eax
  ret
MyTest endp
start:
  invoke MyTest, 55555555h
  exit
end start



NoCforMe

Quote from: jj2007 on July 07, 2024, 10:21:52 AM
1. What debugger is that? Olly?

2. You don't need to declare anything as a PTR to do that, correct? Just right-click and choose "Decode as structure" anywhere in the data, yes?

Nice to be able to do that, for sure.
Assembly language programming should be fun. That's why I do it.

zedd151

Ventanas diez es el mejor.  :azn:

jj2007

Quote from: zedd151 on July 07, 2024, 10:30:20 AMLooks like olly...  :biggrin: but I have never seen that option. Using a plugin??

That's Olly indeed, and not a plugin.

The choice of structures is limited. I've checked the whole Olly folder to find out where this info is stored, no luck.

TimoVJL

poide + poasm
;include \masm32\include\masm32rt.inc

RECT STRUC
left sdword ?
top sdword ?
right sdword ?
bottom sdword ?
RECT ENDS

.code
MyTest proc arg1
Local rc:RECT
Local prc:PTR RECT
  mov rc.left, 111h
  mov rc.top, 222h
  mov rc.right, 333h
  mov rc.bottom, 444h
  lea eax, rc
  int 3
  mov prc, eax
  ret
MyTest endp
start:
  invoke MyTest, 55555555h
  ret
end start

May the source be with you

kkurkiewicz

I think I understand, thank you.
I just got confused by the _PTR suffix in the name of the type.
Kamil

Greenhorn

Quote from: kkurkiewicz on July 09, 2024, 02:17:08 AMI think I understand, thank you.
I just got confused by the _PTR suffix in the name of the type.


The _PTR sais that this type always has the size of a Pointer, which means in x86 4 bytes and in x64 8 bytes.

ifdef _WIN64
INT_PTR            typedef sqword
UINT_PTR        typedef qword
LONG_PTR        typedef sqword
ULONG_PTR        typedef qword
else
INT_PTR            typedef sdword
UINT_PTR        typedef dword
LONG_PTR        typedef sdword
ULONG_PTR        typedef dword
endif
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.