News:

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

Main Menu

registers as pointer q

Started by dc, September 08, 2023, 04:00:09 AM

Previous topic - Next topic

NoCforMe

No; you only need to specify the size (WORD, DWORD) if it's not clear otherwise from the context, specifically when you use an immediate constant for the bit number and an ambiguous memory-based first operand (like [EDX], which could be a pointer to anything, byte, word, doubleword, quadword ...):

    BT    DWORD PTR [EDX], 5

You don't need the size spec if you use a register for that operand, or a register or a sized variable for the first operand:

    BT    [EDX], EAX
    BT    EDX, 5
    BT    dwordSizedVar, 5
Assembly language programming should be fun. That's why I do it.

zedd151

Thank you NoCforMe for the detailed response. I am certain that the OP, dc, will understand better from the examples shown as well.

NoCforMe

Just to clarify and summarize, the fact that the ambiguous cases (like BT [reg], imm) are flagged as errors by ML is appropriate. What is dumb, as JJ pointed out, is the exact error message ("invalid instruction operand"). There's nothing "invalid" about it; it's just ambiguous.
Assembly language programming should be fun. That's why I do it.

zedd151

Ambiguous code leads to ambiguous error messages?  :joking:
Sounds like an issue to be taken up with Microsoft.  :biggrin:

NoCforMe

#19
Quote from: zedd151 on September 09, 2023, 10:20:17 AMSounds like an issue to be taken up with Microsoft.  :biggrin:

Yes, I'm sure Micro$oft is very committed to making improvements to ml.exe:

Copyright (C) Microsoft Corp 1981-1997

We'll have to get Raymond Chen to weigh in on this.
Assembly language programming should be fun. That's why I do it.

dc

oooooo....
preliminarily...this seems to be working!
xor dword ptr pbrd[esi],1crap.... got ahead of myself, it doesn't
NEVERMIND!!! IT DOES WORK.... WOOHOO!!!!

dc

oooops it doesn't...
that way uses memory after the label... in tester
pbrd            dd ?
tester          dd 50 dup (?)

zedd151

#22
Hi dc, could you post some more code. Just a line or two isn't really telling us what it is, that you now are trying to do. With a more complete piece of code, we will be able to help you better. Full source preferred, but a more complete snippet may be enough. We don't know what is in pbrd or in esi, or how they got there, or the result that you are expecting. Help us to help you.
Describe at least, what you want to do, with the last code that you posted, preferably with more complete code.

Edit for completeness and clarity.

dc

i want to access allocated memory with an index like an array
i don't see why nobody understands my question
is it just not done?
also:
if i just put it in the inc file like:
board  dd 0100000h dup (?)
it works fine but takes a while to assemble

HSE

Quote from: dc on September 12, 2023, 12:50:29 AMi don't see why nobody understands my question

Where is your code?
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on September 12, 2023, 12:58:05 AM
Quote from: dc on September 12, 2023, 12:50:29 AMi don't see why nobody understands my question

Where is your code?

HSE, what's wrong with your crystal ball, it's not working?

dc, it's considered bad practice to post snippets, thus assuming that older members love spending their precious time adding headers, includes etc.

If you want help, zip all necessary files, especially the complete *.asm source, and attach it here. Otherwise all your questions will be happily ignored. Please confirm arrival of the message.

jj2007

Quote from: dc on September 12, 2023, 12:50:29 AMif i just put it in the inc file like:
board  dd 0100000h dup (?)
it works fine but takes a while to assemble
That's a known MASM bug. You can use UAsm instead, it's a perfect MASM clone with less bugs.

NoCforMe

Quote from: dc on September 11, 2023, 06:52:36 AMoooooo....
preliminarily...this seems to be working!
xor dword ptr pbrd[esi],1crap.... got ahead of myself, it doesn't
NEVERMIND!!! IT DOES WORK.... WOOHOO!!!!
Quote from: dc on September 11, 2023, 11:38:49 PMoooops it doesn't...
that way uses memory after the label... in tester
pbrd            dd ?
tester          dd 50 dup (?)

OK, trying to bring this discussion back down to earth (and Zedd, back off on your net-nanny politeness campaign, please: JJ was just expressing a little irritation back there. Remember: moderation in moderation.)

First thing: if you code

pbrd            dd ?

xor dword ptr pbrd[esi],1

you don't need the dword ptr precautionary label, because you've clearly defined that variable as a doubleword, which the assembler, as dumb as it may be, knows about. So just use

xor pbrd[esi],1

instead.
Assembly language programming should be fun. That's why I do it.

dc

that's not using allocated memory...
can allocated memory be used as an array?

Caché GB

Hi dc

Yes, allocated memory can be used as an array.
Caché GB's 1 and 0-nly language:MASM