Instruction Syntax

The grammar used when coding desired CPU actions (Opcode), and where those actions should be applied.
Let's look at the MOV instruction. It moves a value FROM a location, TO a location.
it's sytax would be: MOV TO, FROM
General syntax for any opcode is: Opcode Target, Source

In your source code, you can include a comment on any line by using a semi-colon ( ; ).
Anything on a line, AFTER a semi-colon is ignored by the compiler.
I shoud mention, every line of source can hold only ONE instruction, optionally preceded by a LABEL and followed by a COMMENT.

LABEL: Opcode Target, Source       ;Here's a comment

I prefer to put labels a line above the instruction, it's all preference though. A label is like a place marker in your source code. Use it to reference that point for Jumps or to access the data there (variables).


Back to the MOV instruction. MOV moves a value from a location, to a location. Those locations are specified by an instruction's Operands (called such, because they are part of the CPU Operation). There are three classes of Operands. They are:
1) Immediate: This operand is a value coded into the instruction itself, and is read with it's parent instruction by the CPU. It can be though of as a 'constant'.
2) Register: When an operand is a regster, the CPU gets/places the value in the specified CPU Register. See Registers.
3) Memory: This kind of operand is a value which is used as a pointer to a location in RAM memory.

The value used as a Memory Operand can be an immediate or a register or both.

MOV AX, 100         ; move Immediate into Register - AX regiser will hold the value 100
MOV AX, [100]         ; move data in Memory into Register - Value at ram address 100 will be stored in AX register

MOV SI, AX         ; move data in AX Register into SI Register
MOV [SI], AX         ; move data in AX register into Memory, memory address used is held in SI



A Segment value and an Offset value are needed to calculate the Effective Address. So where is the Segment value in:
MOV AX, [100]

Whenever memory is being addressed by the cpu, the default segment value used is the value in the DS (Data Segment) register.
The following code accesses the same locations:
mov ax, [si]         ; TASM or NASM
mov ax, ds:[si]         ; TASM syntax
mov ax, [ds:si]         ; NASM syntax

This tutorial cover two assembliers. Tasm and Nasm. Any differences in syntax will be noted.