goldenmean
goldenmean

Reputation: 18966

Intel x86 assembly code behavior question

I have a Intel assembly x86(16 bit version) assembly code as below which prints the message fine. Using flat assembler to assemble on Win-7 32 bit.

ORG 100h
USE16

        mov ah, 09
        mov dx, message
        jmp  Displayit  ;unconditional jump

        mov ah,01
        int 21h

        mov ah,4ch
        int 21h

Displayit:
        int 21h

message db 'Testing assembly jump instruction', 0Ah, '$'
  1. If I move the string definition of message(in code below), at the beginning, it does not print that string? What is the reason?

  2. Also, although I have the instruction mov ah, 01, int 21h to keep the output command prompt/console from closing, it does not work. The console just closes before I can see the message is printed or not?

.

ORG 100h
USE16
message db 'Testing assembly jump instruction', 0Ah, '$'

mov ah, 09
mov dx, message
jmp  Displayit  ;unconditional jump

mov ah,01
int 21h
mov ah,4ch
int 21h

Displayit:
    int 21h

Upvotes: 1

Views: 529

Answers (1)

Gunther Piez
Gunther Piez

Reputation: 30439

  1. If you define the string at the beginning, it will be executed as code. This leads to a crash or all kinds of undefined behaviour.

  2. The instruction sequence beginning with mov ah,1 is never executed, you jump over it.

Upvotes: 6

Related Questions