ASHU AHIRE
ASHU AHIRE

Reputation: 11

Can anyone explain this DOS hello world for emu8086?

.Model Small
.STACK

.DATA
      MSG1 DB \"HELLO! How r u?$\"

.CODE

   MOV AX,@DATA
   MOV DS,AX

   lea dx,MSG1
   mov ah,09h
   int 21h

   mov ah,4ch
   int 21h

END

Upvotes: 0

Views: 860

Answers (1)

Sep Roland
Sep Roland

Reputation: 39691

What it means.

.Model Small

The program conforms to the small memory model where the code and data segments are different and don't overlap. The program can have no more than 65536 bytes of code and no more than 65536 bytes of data and stack. The program uses near pointers.

.STACK

Nothing was mentioned here and so the stack assumes a default size. You can look it up in the emu8086 manual.

.DATA
MSG1 DB \"HELLO! How r u?$\"

This .DATA section contains a single string HELLO! How r u?$

.CODE
MOV AX,@DATA
MOV DS,AX

These instructions make the DS segment register point to the .DATA section of your program thereby allowing access to that single string.

lea dx,MSG1
mov ah,09h
int 21h

The offset address of that one string is loaded in the DX register. Then a DOS api call is made to display the characters of the string on the screen. The $ character serves as an end-of-string indicator and is not shown on the screen.

mov ah,4ch
int 21h

This DOS api call terminates the program.

END

Just a syntax requirement.

Upvotes: 3

Related Questions