1

Why is that instruction 109 appears to be executed even if it doesn't actually reach by the instruction pointer when run. As far as I know(C++ background), the processor process instructions 1 at a time and in an orderly fashion. Address 100,102,105, and 107 are executed first, and so how come INT 21 can display the contents of memory location 109 prior to being the next line (not yet declared)?

(suppose we enter these instructions on debug)

100 MOV AH,09
102 Dx,109
105 INT 21
107 JMP 100
109 DB 'Hello World', '$' <Enter> <Enter> 

2 Answers 2

6

DB is not an instruction, it is a pseudo instruction aka assembler directive. It tells the assembler to store the following data bytes at the current address.

Sign up to request clarification or add additional context in comments.

2 Comments

so youre telling me that, when im using debug.exe from command prompt, and type something like, -100 A db 'My name is Paul R', '$' ,,, then as soon as I hit enter, it automatically updates the address 100 and put my string there?
Pretty much, yes - it's just doing the same thing that an assembler would do.
2

When the program is assembled, the assembler will put your string at the right address. The processor can read from addresses it is not executing. The instruction pointer is only one pointer, you can read from addresses larger than the instruction pointer without issues. The memory is "random-accessible" after all.

There is no "declaration". There is only addresses. Some assembly programs have labels, but those labels are translated by the assembler to addresses upon assembly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.