Implied: operands are specified implicitly in the definition of instruction. Examples: CLA
,CME
,INP
.
It is mainly used for Zero-address (STACK-organized) and One-address (ACCUMULATOR-organized) instructions.
Immediate: operand is specified in the instruction itself and mainly for constants . Example: ADD R1,#3
,MUL R1,R2,#7
but the question comes how to check the instruction:
1) PUSH 3
and
2)LD 7
First one is a zero address instruction (Stack based) and the second is an accumulator instruction. In both instructions the operand is defined in the instruction itself. Which addressing mode is preferred, or best describes them?
How to check whether the instruction is implied or immediate?
Further examples of implicit operands on x86: SAHF
, LAHF
, and CPUID
.
source: https://en.wikipedia.org/wiki/CPUID
In assembly language the CPUID instruction takes no explicit parameters as CPUID implicitly uses the EAX register (and sometimes ECX) to determine the information returned in EAX,EBX,ECX, and EDX.
source: http://www.felixcloutier.com/x86/LAHF.html
LAHF — Load Status Flags into AH Register
This instruction executes as described above in compatibility mode and legacy mode. It is valid in 64-bit mode only if CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1.
source: http://www.felixcloutier.com/x86/SAHF.html
SAHF — Store AH into Flags
Loads the SF, ZF, AF, PF, and CF flags of the EFLAGS register with values from the corresponding bits in the AH register (bits 7, 6, 4, 2, and 0, respectively). Bits 1, 3, and 5 of register AH are ignored; the corresponding reserved bits (1, 3, and 5) in the EFLAGS register remain as shown in the “Operation” section below.
This instruction executes as described above in compatibility mode and legacy mode. It is valid in 64-bit mode only if CPUID.80000001H:ECX.LAHF-SAHF[bit 0] = 1.
usage example: (source: https://www.slideshare.net/rbtaccess/flag-control )
MOV AH, 25H ; immediate source operand
SAHF ; implicit operands
more examples include CLC
, STC
, and CMC
, which clear, set, or flip the carry flag CF respectively. (CF is a bit in FLAGS, not a whole register.)
PUSH r/m32
is one opcode, and the addressing mode selects between memory or register source. – Peter CordesPUSH A
the operand is in memory then is it implied mode because the operand is not the ACTUAL OPERAND ? – Kamal Pratap