right I'm trying to clear some things from this example code:

DOSSEG
.MODEL SMALL
.STACK 200h
.DATA

OurString DB "This is a string of characters. "
DB "Do you lack imagination? Put something interesting here!$"

.CODE

START:
MOV AX, SEG OurString ; Move the segment where OurString is located
MOV DS, AX ; into AX, and now into DS

MOV DX, OFFSET OurString ; Offset of OurString -> DX
MOV AH, 9h ; Print string subfunction
INT 21h ; Generate interrupt 21h

MOV AX, 4C00h ; Exit to DOS sufunction
INT 21h ; Generate interrupt 21h
END START

1.first of where he creates OurString there's supposed to be just one DB "somestring$" right the second one is not correct?

2. When should I call INT 21h?

3. MOV AH, 9h - why do I call 9h (print) on AH (Accumulator High) and not AS?

hello sir please help!

> 2. When should I call INT 21h?
Whenever you want DOS to do something for you.

> 3. MOV AH, 9h - why do I call 9h (print) on AH (Accumulator High) and not AS?
Because that's what the manual says.
http://www.ctyme.com/intr/rb-2562.htm

> OurString there's supposed to be just one DB "somestring$" right the second one is not correct?
Why?
db "foo"
db "bar"
is just
db "foobar"
If you've got a few KB of text, it would be dumb to force you to write it all on one line.
So long as there's a $ (see previous point), the right thing will happen.

hi
-------------------------------------------Q3---------------------------------------
u know that Accumulator register (AX) consists of 16bit and divided into
|====AH====|====AL====
AH=8bit AL=8bit
in the the printing function of int21
AX=0900h
so when u use it u must put the variable in ur right position
if u divide Ax in Ah and Al u will find
AH=09h and Al=00h
or u can use AX =0900h
so that u use AH in printing fuction with int 21 ...
----------------------------------Q1------------------------------------------------
- all i know about string is to declar like u do in the first one
string DB "hello ufo$" ;OR
string DB "hello ufo" 0,
----------------------------------Q1------------------------------------------------
u use int21 is interupt which have parameters those parameters defined in AX registery the explain to the int21 which function will use
mov ax,0900h ;so printing function
OR
mov ah,4ch ;to return back to dos

take this link and discover all functions of INT21 :

http://heim.ifi.uio.no/~stanisls/helppc/int_21.html

bye

right I'm trying to clear some things from this example code:

1.first of where he creates OurString there's supposed to be just one DB "somestring$" right the second one is not correct?

2. When should I call INT 21h?

3. MOV AH, 9h - why do I call 9h (print) on AH (Accumulator High) and not AS?

Answer 1: What is meant here is that you could have a number of lines and just point to the beginning line and the print function will print everything from the start of the location you pointed to (OurString) in this case until it encounters a $, thus if you have a long message to be printed you can put them on different consecutive lines (for readability) and end the last entry with a $

Answer 2: DOS provides many functions and there are conventions. A group of functions are provided by INT 21h, another group of functions are provided by INT 10h and so on. Within each interrupt service ther are many sub functions that do specific things and the requirement is that you load certain registers with certain values before invoking the interrupt. So happens that print function is sub function 9 in the 21h interrupt family.

Answer 3: I think you meant AX rather than AS, there is no AS register. The AX, BX, DX, etc registers are 16 bit registers. Each has a corresponding high and low register, for example AH and AL. The print sub function 9 under INT 21h requires that the 9 be loaded into the AH regsiter.

----------------
| AH | AL |
------- -------
byte byte
----------------
16 bits

If you load AX with 9, then AH will have 0 and AL will have 9 as shown below

0000000010000001

which is not per specification for sub function 9 on INT 21h, hence you load AH with 9 and not AX.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.