Arithmetic Operators |
Name |
Priority |
() |
Parentheses |
1 |
+ ,- |
Positive and Negative |
2 |
*,/ |
Multiplication, division |
3 |
MoD |
Modulo |
3 |
+ ,- |
Add and subtract |
4 |
Arithmetic Operator example:
; Test8_1.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codestart: printdec 7 + 3; 10 printdec 7-3; 4 printdec 7*3; 21 printdec 7/3; 2 printdec 7 mod 3; 1 printdec 7/3 + 4; 6 printdec 7/(3 + 4); 1 retend start
Example of Relational operators (EQ, NE, LT, le, GT, Ge:
; EQ: equal; ne: not equal to; lt: less than; Le: less than or equal to; GT: greater than; GE: greater than or equal to; test8_2.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codestart:; EQ: = printdec 2 EQ 1; 0 printdec 2 EQ 2;-1 printdec 2 EQ 3; 0; ne: printdec 2 ne 1;-1 printdec 2 ne 2; 0 printdec 2 ne 3;-1; lt: printdec 2 GT 1;-1 printdec 2 GT 2; 0 printdec 2 GT 3; 0; GE: >= printdec 2 Ge 1; -1 printdec 2 Ge 2;-1 printdec 2 Ge 3; 0 retend start
Example of logical operators (and, Or, XOR, and not:
; Test8_3.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codestart: printhex 0 blocks and 0ffff0000h; ffff0000 printhex 0 blocks or 0ffff0000h; ffffffff printhex 0 blocks XOR 0ffff0000h; 0000 FFFF printhex not 0ffff0000h; 0000 FFFF retend start
Examples of high, low, highword, and lowword separators:
; Test8_4.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codestart: printhex high 1122 h; 11 printhex low 1122 h; 22 printhex high 11223344 h; 33 printhex low 11223344 h; 44 printhex highword 11223344 h; 1122 printhex lowword 11223344 h; 3344 retend start
Example of Shift Operators (SHL and SHR:
; Test8_5.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codestart: printhex 12345678 h shl 4; 23456780 printhex 12345678 h shl 8; 34567800 printhex 12345678 h shr 4; 01234567 printhex 12345678 h shr 8; 00123456 retend start
The preceding operators (or pseudo-commands) have the same name as assembly (hard) commands, except that they are only used for constant expressions and output results during compilation.
Pseudoinstructions? (Hard) command?
The pseudo commands of MASM are provided by MASM, which tell you how to compile during the compilation period. They are used before the OBJ file is generated;
(Hard) commands are provided by the CPU and all have corresponding binary codes.ProgramRuntime.