Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'Label' in assembly language – opcode

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading