The MASM Forum

Microsoft 64 bit MASM => Reference => Topic started by: Player1UK on May 30, 2021, 12:11:27 AM

Title: MASM64 grammar reference
Post by: Player1UK on May 30, 2021, 12:11:27 AM
I've created a complete grammar reference document for MASM64:
https://onedrive.live.com/view.aspx?ithint=file,pdf&resid=2C18DFD7C47CC9A7%21622&authkey=%21AAPQgLTI4FlEL04 (https://onedrive.live.com/view.aspx?ithint=file,pdf&resid=2C18DFD7C47CC9A7%21622&authkey=%21AAPQgLTI4FlEL04)

Any corrections would be greatly appreciated.
Title: Re: MASM64 grammar reference
Post by: hutch-- on May 30, 2021, 12:21:00 AM
Looks like you have done a lot of work there.  :thup:
Title: Re: MASM64 grammar reference
Post by: Player1UK on May 30, 2021, 12:33:03 AM
Thank you (and thank you for all your hard work, I started out learning assembly language using masm32 way back in 2000).

I posted a link because the document itself is continuously being updated, whilst I'm using it to create a visual development environment.

The next big change will be the gradual inclusion of all the 64-bit mnemonics.
Title: Re: MASM64 grammar reference
Post by: hutch-- on May 30, 2021, 11:58:20 AM
The mnemonic list will be appreciated by many people. One suggestion, try and bundle them as families as scouring through the Intel manuals is hard work for folks who are not used to them.
Title: Re: MASM64 grammar reference
Post by: Player1UK on May 30, 2021, 08:14:55 PM
x86-64 Instruction Set reference:
https://onedrive.live.com/view.aspx?ithint=file,pdf&resid=2C18DFD7C47CC9A7%21624&authkey=%21ANTJqFkX5v3hdno (https://onedrive.live.com/view.aspx?ithint=file,pdf&resid=2C18DFD7C47CC9A7%21624&authkey=%21ANTJqFkX5v3hdno)

This contains all the general-purpose 64-bit instructions, excluding Cache, FPU, SIMD (MMX, SSE, AVX), FMA, and BMI instructions.
I have a separate document for Cache instructions, and a much larger (471 pages) document for all the 64-bit FPU MMX SSE AVX FMA BMI instructions.
Title: Re: MASM64 grammar reference
Post by: ahsat on April 08, 2024, 09:47:02 AM
Thank you. I need that.
Title: Re: MASM64 grammar reference
Post by: jj2007 on April 08, 2024, 11:05:28 AM
Try this one (open with WordPad, MS Word or RichMasm)
Title: Re: MASM64 grammar reference
Post by: ahsat on April 08, 2024, 12:46:12 PM
Quote from: jj2007 on April 08, 2024, 11:05:28 AMTry this one (open with WordPad, MS Word or RichMasm)

I will, thank you.
Title: Re: MASM64 grammar reference
Post by: ahsat on April 08, 2024, 10:06:32 PM
Quote from: jj2007 on April 08, 2024, 11:05:28 AMTry this one (open with WordPad, MS Word or RichMasm)

When I try to unzip the file I get "need PK compat. v6.3 (can do v2.1)" from command line unzip. I can't remember when or where I got my zip/unzip from. I get the below if I just execute unzip. I will try to find a newer version later this morning. This is the first time I have had a problem with this one.

UnZip 5.51 of 22 May 2004, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment
  -x  exclude files that follow (in xlist)   -d  extract files into exdir

modifiers:                                   -q  quiet mode (-qq => quieter)
  -n  never overwrite existing files         -a  auto-convert any text files
  -o  overwrite files WITHOUT prompting      -aa treat ALL files as text
  -j  junk paths (do not make directories)   -v  be verbose/print version info
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -$  label removables (-$$ => fixed disks)  -V  retain VMS version numbers
  -X  restore ACLs (-XX => use privileges)   -s  spaces in filenames => '_'
                                             -M  pipe through "more" pager
Examples (see unzip.txt for more info):
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
Title: Re: MASM64 grammar reference
Post by: ahsat on April 08, 2024, 11:48:06 PM
Quote from: jj2007 on April 08, 2024, 11:05:28 AMTry this one (open with WordPad, MS Word or RichMasm)
Sorry about that. Until just now, I didn't know that 7z would also unzip.

None of the links in the document seem to be valid anymore.
Title: Re: MASM64 grammar reference
Post by: jj2007 on April 09, 2024, 12:09:34 AM
Quote from: ahsat on April 08, 2024, 11:48:06 PMNone of the links in the document seem to be valid anymore.

Strange. For me, they work:

These are all SSE2 - for other versions, see Streaming SIMD Extensions (http://softpixel.com/~cwright/programming/simd/sse2.php) (SSE2), SSE3 (https://softpixel.com/~cwright/programming/simd/sse3.php) and SSE4 (https://softpixel.com/~cwright/programming/simd/sse4.php), x86 complete 2014 (http://ftp.neutrino.es/x86InstructionSet/)
SOF: What are the best instruction sequences to generate vector constants on the fly? (https://stackoverflow.com/questions/35085059/what-are-the-best-instruction-sequences-to-generate-vector-constants-on-the-fly?noredirect=1&lq=1) (packuswb pabsb psubb packsswb pmovzx...)
About Instruction Sets
Title: Re: MASM64 grammar reference
Post by: ahsat on April 09, 2024, 04:53:26 AM
Quote from: jj2007 on April 09, 2024, 12:09:34 AMFor me, they work:
Thank you. The links in your post work fine. In the document, when I click on a line, or copy and past the url, I have problem. The very first link is:

http://developer.intel.com/products/processor/manuals/index.htm

You can try it, and you may see what I am seeing.
Title: Re: MASM64 grammar reference
Post by: sudoku on April 09, 2024, 05:24:23 AM
Try this https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html

Googling the link in your post, led me there, ahsat
Going to that link from your post, --> Page not found error
Title: Re: MASM64 grammar reference
Post by: ahsat on April 09, 2024, 07:42:14 AM
Quote from: sudoku on April 09, 2024, 05:24:23 AMTry this
Thank you. That is a large amount of documentation, more than I am use to. Hide a book in a library, type of documentation, it seems at a glance.
Title: Re: MASM64 grammar reference
Post by: sudoku on April 09, 2024, 07:49:26 AM
Quote from: ahsat on April 09, 2024, 07:42:14 AM... Hide a book in a library, type of documentation, it seems at a glance.
Definitely.
Title: Re: MASM64 grammar reference
Post by: jj2007 on April 09, 2024, 08:52:01 AM
Quote from: ahsat on April 09, 2024, 04:53:26 AMIn the document, when I click on a line, or copy and past the url, I have problem

Sorry - the reason is that the document was written in RTF format, so you can read it with WordPad or MS Word; however, the internal format of links is {url="http://http..."}sometext{/url} (with squared brackets) for compatibility with the Masm32 forum. Only RichMasm (https://masm32.com/board/index.php?board=57.0) will interpret these links correctly.

Here is a list of the 260+ instructions covered in the doc:

AAA--ASCII Adjust After Addition/?
AAD--ASCII Adjust AX Before Division/?
AAM--ASCII Adjust AX After Multiply/?
AAS--ASCII Adjust AL After Subtraction/?
ADC--Add with Carry/?
ADD--Add/?
ADDPD--Packed Double-Precision Floating-Point Add/?
ADDPS--Packed Single-Precision Floating-Point Add/?
ADDSD--Scalar Double-Precision Floating-Point Add/?
ADDSS--Scalar Single-Precision Floating-Point Add/?
AND--Logical AND/?
ANDNPS--Bit-wise Logical And Not For Single-FP/?
ARPL--Adjust RPL Field of Segment Selector/?
BOUND--Check Array Index Against Bounds/?
BSF--Bit Scan Forward/?
BSR--Bit Scan Reverse/?
MOVBE--Move Data After Swapping Bytes (Atom & Haswell+)/?
BSWAP--Byte Swap/?
BT--Bit Test/?
BTC--Bit Test and Complement/?
BTR--Bit Test and Reset/?
BTS--Bit Test and Set/?
CALL--Call Procedure/?
CBW/CWDE--Convert Byte to Word/Convert Word to Doubleword/?
CLC--Clear Carry Flag/?
CLD--Clear Direction Flag/?
CLFLUSH--Cache Line Flush/?
CLI--Clear Interrupt Flag/?
CLTS--Clear Task-Switched Flag in CR0/?
CMC--Complement Carry Flag/?
CMOVcc--Conditional Move/?
CMP--Compare Two Operands/?
CMPPD--Compare Packed Double-Precision Floating-Point Values/?
CMPPS--Compare Packed Single-Precision Floating-Point Values/?
CMPS/CMPSB/CMPSW/CMPSD--Compare String Operands/?
CMPSD--Compare Scalar Double-Precision Floating-Point Value/?
CMPSS--Compare Scalar Single-Precision Floating-Point Values/?
CMPXCHG--Compare and Exchange/?
CMPXCHG8B--Compare and Exchange 8 Bytes/?
CPUID--CPU Identification/?
DAA--Decimal Adjust AL after Addition/?
DAS--Decimal Adjust AL after Subtraction/?
DEC--Decrement by 1/?
DIV--Unsigned Divide/?
DIVPD--Packed Double-Precision Floating-Point Divide/?
DIVPS--Packed Single-Precision Floating-Point Divide/?
DIVSD--Scalar Double-Precision Floating-Point Divide/?
DIVSS--Scalar Single-Precision Floating-Point Divide/?
EMMS--Empty MMX™ Technology State/?
ENTER--Make Stack Frame for Procedure Parameters/?
F2XM1--Compute 2x-1/?
FABS--Absolute Value/?
FADD/FADDP/FIADD--Add/?
FBLD--Load Binary Coded Decimal/?
FBSTP--Store BCD Integer and Pop/?
FCHS--Change Sign/?
FCLEX/FNCLEX--Clear Exceptions/?
FCMOVcc--Floating-Point Conditional Move/?
FCOM/FCOMP/FCOMPP--Compare Real/?
FCOS--Cosine/?
FDECSTP--Decrement Stack-Top Pointer/?
FDIV/FDIVP/FIDIV--Divide/?
FDIVR/FDIVRP/FIDIVR--Reverse Divide/?
FFREE--Free Floating-Point Register/?
FICOM/FICOMP--Compare Integer/?
FILD--Load Integer/?
FINCSTP--Increment Stack-Top Pointer/?
FINIT/FNINIT--Initialize Floating-Point Unit/?
FIST/FISTP--Store Integer/?
FLD--Load Real/?
FLDCW--Load x87 FPU Control Word/?
FLDENV--Load x87 FPU Environment/?
FMUL/FMULP/FIMUL--Multiply/?
FNOP--No Operation/?
FPATAN--Partial Arctangent/?
FPREM--Partial Remainder/?
FPREM1--Partial Remainder/?
FPTAN--Partial Tangent/?
FRNDINT--Round to Integer/?
FRSTOR--Restore x87 FPU State/?
FSAVE/FNSAVE--Store x87 FPU State/?
FSCALE--Scale/?
FSIN--Sine/?
FSINCOS--Sine and Cosine/?
FSQRT--Square Root/?
FST/FSTP--Store Real/?
FSTCW/FNSTCW--Store x87 FPU Control Word/?
FSTENV/FNSTENV--Store x87 FPU Environment/?
FSTSW/FNSTSW--Store x87 FPU Status Word/?
FSUB/FSUBP/FISUB--Subtract/?
FSUBR/FSUBRP/FISUBR--Reverse Subtract/?
FTST--TEST/?
FUCOM/FUCOMP/FUCOMPP--Unordered Compare Real/?
FXAM--Examine/?
FXCH--Exchange Register Contents/?
FXTRACT--Extract Exponent and Significand/?
FYL2X--Compute y * log2x/?
FYL2XP1--Compute y * log2(x +1)/?
HLT--Halt/?
IDIV--Signed Divide/?
IMUL--Signed Multiply/?
IN--Input from Port/?
INC--Increment by 1/?
INS/INSB/INSW/INSD--Input from Port to String/?
INT n/INTO/INT 3--Call to Interrupt Procedure/?
INVD--Invalidate Internal Caches/?
INVLPG--Invalidate TLB Entry/?
IRET/IRETD--Interrupt Return/?
Jcc--Jump if Condition Is Met/?
JMP--Jump/?
LAHF--Load Status Flags into AH Register/?
LAR--Load Access Rights Byte/?
LDMXCSR--Load Streaming SIMD Extension Control/Status/?
LDS/LES/LFS/LGS/LSS--Load Far Pointer/?
LEA--Load Effective Address/?
LEAVE--High Level Procedure Exit/?
LFENCE--Load Fence/?
LGDT/LIDT--Load Global/Interrupt Descriptor Table Register/?
LLDT--Load Local Descriptor Table Register/?
LMSW--Load Machine Status Word/?
LOCK--Assert LOCK# Signal Prefix/?
LODS/LODSB/LODSW/LODSD--Load String/?
LOOP/LOOPcc--Loop According to ECX Counter/?
LSL--Load Segment Limit/?
LTR--Load Task Register/?
MASKMOVDQU--Mask Move of Double Quadword Unaligned/?
MASKMOVQ--Mask Move of Quadword/?
MAXPD--Maximum Packed Double-Precision Floating-Point Values/?
MAXPS--Maxiumum Packed Single-Precision Floating-Point Values/?
MAXSD--Maximum Scalar Double-Precision Floating-Point Value/?
MAXSS--Maximum Scalar Single-Precision Floating-Point Value/?
MFENCE--Memory Fence/?
MINPD--Packed Double-Precision Floating-Point Minimum/?
MINPS--Minimum Packed Single-Precision Floating-Point Values/?
MINSD--Minimum Scalar Double-Precision Floating-Point Value/?
MINSS--Minimum Scalar Single-Precision Floating-Point Value/?
MOV--Move/?
MOV--Move to/from Control Registers/?
MOV--Move to/from Debug Registers/?
MOVD--Move Doubleword/?
MOVHPD--Move High Packed Double-Precision Floating-Point Value/?
MOVHPS--Move High Packed Single-Precision Floating-Point Values/?
MOVLPD--Move Low Packed Double-Precision Floating-Point Value/?
MOVLPS--Move Low Packed Single-Precision Floating-Point Values/?
MOVNTPS--Move Aligned Four Packed Single-FP Non Temporal/?
MOVNTQ--Move Quadword Non-Temporal/?
MOVQ--Move Quadword/?
MOVQ2DQ--Move Quadword/?
MOVS/MOVSB/MOVSW/MOVSD--Move Data from String to String/?
MOVSD--Move Scalar Double-Precision Floating-Point Value/?
MOVSS--Move Scalar Single-Precision Floating-Point Values/?
MOVSX--Move with Sign-Extension/?
MOVZX--Move with Zero-Extend/?
MUL--Unsigned Multiply/?
MULPD--Packed Double-Precision Floating-Point Multiply/?
MULPS--Packed Single-Precision Floating-Point Multiply/?
MULSD--Scalar Double-Precision Floating-Point Multiply/?
MULSS--Scalar Single-FP Multiply/?
NEG--Two's Complement Negation/?
NOP--No Operation/?
NOT--One's Complement Negation/?
OR--Logical Inclusive OR/?
ORPD--Bitwise Logical OR of Double-Precision Floating-Point Values/?
ORPS--Bitwise Logical OR of Single-Precision Floating-Point Values/?
OUT--Output to Port/?
OUTS/OUTSB/OUTSW/OUTSD--Output String to Port/?
PACKSSWB/PACKSSDW--Pack with Signed Saturation/?
PACKUSWB--Pack with Unsigned Saturation/?
PADDB/PADDW/PADDD--Packed Add/?
PADDQ--Packed Quadword Add/?
PADDSB/PADDSW--Packed Add with Saturation/?
PADDUSB/PADDUSW--Packed Add Unsigned with Saturation/?
PAND--Logical AND/?
PANDN--Logical AND NOT/?
PAUSE--Pause For Preset Amount of Time/?
PAVGB/PAVGW--Packed Average/?
PCMPEQB/PCMPEQW/PCMPEQD--Packed Compare for Equal/?
PCMPGTB/PCMPGTW/PCMPGTD/PCMPGTQ--Packed Compare for Greater Than/?
PEXTRW--Extract Word/?
PINSRW--Insert Word/?
PMADDWD--Packed Multiply and Add/?
PMAXSW--Packed Signed Integer Word Maximum/?
PMAXUB--Packed Unsigned Integer Byte Maximum/?
PMINSW--Packed Signed Integer Word Minimum/?
PMINUB--Packed Unsigned Integer Byte Minimum/?
PMOVMSKB--Move Byte Mask to General-Purpose Register/?
PMULHUW--Packed Multiply High Unsigned/?
PMULHW--Packed Multiply High Signed/?
PMULLW--Packed Multiply Low Signed/?
PMULUDQ--Packed Multiply Doubleword Unsigned/?
POP--Pop a Value from the Stack/?
POPA/POPAD--Pop All General-Purpose Registers/?
POPF/POPFD--Pop Stack into EFLAGS Register/?
POR--Bitwise Logical OR/?
PREFETCHh--Prefetch Data Into Caches/?
PSADBW--Packed Sum of Absolute Differences/?
PSHUFD--Packed Shuffle Doublewords/?
PSHUFHW--Packed Shuffle High Words/?
PSHUFLW--Packed Shuffle Low Words/?
PSHUFW--Packed Shuffle Words/?
PSHUFB--Packed Shuffle Bytes/?
PSLLDQ--Packed Shift Left Logical Double Quadword (bytes)/?
PSLLW/PSLLD/PSLLQ--Packed Shift Left Logical (bits)/?
PSRAW/PSRAD--Packed Shift Right Arithmetic (bits)/?
PSRLDQ--Packed Shift Right Logical Double Quadword (bytes)/?
PSRLW/PSRLD/PSRLQ--Packed Shift Right Logical (bits)/?
PSUBB/PSUBW/PSUBD--Packed Subtract/?
PSUBQ--Packed Subtract Quadword/?
PSUBSB/PSUBSW--Packed Subtract with Saturation/?
PSUBUSB/PSUBUSW--Packed Subtract Unsigned with Saturation/?
PUSH--Push Word or Doubleword Onto the Stack/?
PUSHA/PUSHAD--Push All General-Purpose Registers/?
PUSHF/PUSHFD--Push EFLAGS Register onto the Stack/?
PXOR--Logical Exclusive OR/?
RCL/RCR/ROL/ROR---Rotate/?
RCPPS--Packed Single-Precision Floating-Point Reciprocal/?
RCPSS--Scalar Single-Precision Floating-Point Reciprocal/?
RDMSR--Read from Model Specific Register/?
RDPMC--Read Performance-Monitoring Counters/?
RDTSC--Read Time-Stamp Counter/?
REP/REPE/REPZ/REPNE /REPNZ--Repeat String Operation Prefix/?
RET--Return from Procedure/?
RSM--Resume from System Management Mode/?
SAHF--Store AH into Flags/?
SAL/SAR/SHL/SHR--Shift/?
SBB--Integer Subtraction with Borrow/?
SCAS/SCASB/SCASW/SCASD--Scan String/?
SETcc--Set Byte on Condition/?
SFENCE--Store Fence/?
SGDT/SIDT--Store Global/Interrupt Descriptor Table Register/?
SHLD--Double Precision Shift Left (bits)/?
SHRD--Double Precision Shift Right (bits)/?
SHUFPD--Shuffle Double-Precision Floating-Point Values/?
SHUFPS--Shuffle Single-Precision Floating-Point Values/?
SLDT--Store Local Descriptor Table Register/?
SMSW--Store Machine Status Word/?
SQRTPD--Packed Double-Precision Floating-Point Square Root/?
SQRTPS--Packed Single-Precision Floating-Point Square Root/?
SQRTSD--Scalar Double-Precision Floating-Point Square Root/?
SQRTSS--Scalar Single-Precision Floating-Point Square Root/?
STC--Set Carry Flag/?
STD--Set Direction Flag/?
STI--Set Interrupt Flag/?
STOS/STOSB/STOSW/STOSD--Store String/?
STR--Store Task Register/?
SUB--Subtract/?
SUBPD--Packed Double-Precision Floating-Point Subtract/?
SUBPS--Packed Single-Precision Floating-Point Subtract/?
SUBSD--Scalar Double-Precision Floating-Point Subtract/?
SUBSS--Scalar Single-FP Subtract/?
SYSENTER--Fast Transition to System Call Entry Point/?
SYSEXIT--Fast Transition from System Call Entry Point/?
TEST--Logical Compare/?
UD2--Undefined Instruction/?
VERR, VERW--Verify a Segment for Reading or Writing/?
WAIT/FWAIT--Wait/?
WBINVD--Write Back and Invalidate Cache/?
WRMSR--Write to Model Specific Register/?