0
votes

I would like to know the difference between the assembly code when using operands for addressing modes. Example mov ax, 25 // where 25 is considered as a constant mov ax, [1000] // [1000] is considered as a memory location

My question is, are the difference between constants and memory location because of the square bracket[1000] or is there something else. And is mov(opcode) a part of the cpu instruction set? Will be grateful for some answers. Thank you!

1

1 Answers

1
votes

Depending on your assembler you have to use the appropriate syntax so it can differentiate between a constant and a memory location. Some assemblers use the syntax you showed, some assemblers require $ prefix for immediates, some assemblers use ptr, etc. Consult your assembler's documentation.

mov is a mnemonic, which has different machine code representations depending on the operands. For example the the mov ax, 25 that you used is actually mov r16, imm16 having opcode B8. The mov ax, [1000] can be mov ax, moffs16 having opcode A1. See the instruction set reference.