Home > OS >  'Label' in assembly language - opcode
'Label' in assembly language - opcode

Time:05-06

I am currently learning to program in the 8085 microprocessor. Take a look at the program below:

LXI H, 2050
MOV B, M
INX H
MOV C, M
MVI A 00H
TOP: ADD B
DCR C
JNZ TOP
INX H
MOV M, A
HLT

This program multiplies two 8-bit numbers in the 8085 microprocessor. I know 'LXI H, 2050' has the hexadecimal operation code (opcode) '21, 50, 20'. In place of 'TOP: ADD B' and 'JNZ TOP', what opcode should I write, and what is the opcode for statements with labels in general?

CodePudding user response:

There is no opcode for a label itself. The assembler translates labels into addresses when you reference them from other places.

TOP: ADD B will be translated simply to 80, just as if the label wasn't there. The label address is the address where the 80 goes, the current position in the output for that line.

If, for example, this location is at address 1000H, JNZ TOP translates to C2 00 10.

  • Related