News:

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

Main Menu

Can't seem to get the addressing right.

Started by GuruSR, October 23, 2016, 06:31:21 AM

Previous topic - Next topic

GuruSR

Quote from: jj2007 on October 24, 2016, 08:50:47 AM
Quote from: GuruSR on October 24, 2016, 07:50:50 AMBuuut, Mov Bl, [Edi +2]  does not

I've tested it: mov bl, [edi+2] works fine with ML 6.15, 8.0, 10.0 at least, plus JWasm, HJWasm and AsmC. None of them requires the byte ptr.

Alright, it didn't, but it is now.  Only thing I can think of is the line had a ctrl code stuck in there somewhere somehow that was causing it to not compile, kept giving me a syntax error on that line, but after I re-wrote the entry from the Mov onward, using the Byte Ptr [Edi+2] it worked, so I'm thinking a ctrl code got in there somehow.

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.

rrr314159

Quote from: GuruSR on October 24, 2016, 12:20:01 PMOnly thing I can think of is the line had a ctrl code stuck in there somewhere somehow that was causing it to not compile, kept giving me a syntax error on that line, but after I re-wrote the entry from the Mov onward, using the Byte Ptr [Edi+2] it worked, so I'm thinking a ctrl code got in there somehow.

Yes, that can happen. One way it can occur, copying and pasting from a rich-text file or similar can introduce an invisible control code. If you'd known for certain the line was supposed to work you would have quickly realized it. But when you're not certain, something like that can easily put you on the wrong track
I am NaN ;)

jj2007

Quote from: rrr314159 on October 24, 2016, 12:30:25 PMcopying and pasting from a rich-text file or similar can introduce an invisible control code.

Yes, that can happen. For this scenario, the developers of assemblers have introduced "error messages" some time ago:

  mov bl, [edi+1] ; OK
  mov bl, [edi+1] ; [edi+hiddentext+1]: Error A2102: Symbol not defined : hiddentext
  and [edi+2], 0 ; ML: error A2070:invalid instruction operands
  and [edi+2], 0 ; HJWasm: Warning A4073: Size not specified, assuming: BYTE

GuruSR

Well, the error it was giving me was Syntax, which made no sense, which is why I was wondering what I didn't have right (syntax basically means the format of how it works and when you get an error, means you didn't format it correctly).


Mov Edi, DWord Ptr [SecOne] ; Ready output.
Mov Ecx, 00H ; Length of Section.
Cmp Edi, Ecx
Je NoOne


And another weirdness, it crashed, I debugged and I looked at the Edi and Ecx, both had 0's in them (Edi went to 1 after the Stosb, which caused the crash), but that Je never went to NoOne, passed it by.  ZF should have been 1 in that situation and the two should have matched and Je should have bypassed the writing of section 1 because the storage for that section was invalid.

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.

jj2007

Quote from: GuruSR on October 24, 2016, 11:18:34 PM

Mov Edi, DWord Ptr [SecOne] ; Ready output.
Mov Ecx, 00H ; Length of Section.
Cmp Edi, Ecx
Je NoOne


And another weirdness, it crashed, I debugged and I looked at the Edi and Ecx, both had 0's in them (Edi went to 1 after the Stosb, which caused the crash)

Nope, edi can't go to one using a stosb. Check it in the debugger:
  xor edi, edi   ; set to zero
  int 3
  stosb


Btw:
   Mov Edi, DWord Ptr [SecOne]   ; Ready output.
   Mov Edi, SecOne         ; the assembler knows that edi is dword sized, and that SecOne is a memory location
   Mov Ecx, 00H         ; Length of Section.
   xor ecx, ecx         ; same effect, 2 bytes instead of 5

Similar:
  mov SecOne, 0  ; 10 bytes
  and SecOne, 0  ; 7 bytes, same effect

GuruSR

Quote from: jj2007 on October 24, 2016, 11:25:55 PM
Nope, edi can't go to one using a stosb. Check it in the debugger:
  xor edi, edi   ; set to zero
  int 3
  stosb


Btw:
   Mov Edi, DWord Ptr [SecOne]   ; Ready output.
   Mov Edi, SecOne         ; the assembler knows that edi is dword sized, and that SecOne is a memory location
   Mov Ecx, 00H         ; Length of Section.
   xor ecx, ecx         ; same effect, 2 bytes instead of 5

Similar:
  mov SecOne, 0  ; 10 bytes
  and SecOne, 0  ; 7 bytes, same effect

I tracked that 1 down to a null I was using, apparently it was... 1!  So that include had a null set to 1, so I fixed it, solved the issue.

SecOne is the memory pointer to a buffer space, Ecx checks against the length of that (pre-supplied value of the length), just used to seeing the Mov dest, Dword Ptr [source] and figured since most were doing that, that it meant it was the best way to accomplish it.

I know about the xor trick, I use it elsewhere, but where I was doing that, I wanted to visually see what it was.  I know the xor is faster and smaller, I actually haven't streamlined the code much, wasn't sure if there was anything out there to offer such.  I remember doing it manually on my CRC library.

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.