Excuse me but isn't this program going to display "1" on the screen?
Thank you very much!

.8086
DATA SEGMENT
CHAR DB 31H
DATA ENDS

STACK SEGMENT STACK
STACK ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
;---------------------------------
START:
MOV DL,CHAR
MOV AH,2
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

Recommended Answers

All 3 Replies

mov dl, 0x31
mov ah, 0x2
int 0x21

^----Should display a '1'

Maybe it is about where you defined your stack, and your
memory variable got overwritten when external interrupts
needed the stack...

On top of this, I do not see a value defining the size of the stack
in bytes???

MS-DOS sets the SS register to the paragraph aligned segment address
of the start of any segment declaced with STACK, and SP to the offset
of the byte immediately after the STACK.
Hence if you have defined a stack you shouldn't have to initialize SS : SP

Thank you very much! And I just found out that I've also got the "start" label in the wrong place.

Oh, I missed that.
The start label was after the

MOV AX, DATA 
MOV DS, AX

and was never executed, hence DS still pointed to the
PSP and not the segment containing the memory variable
'char'.
On entry ES and DS will contain the segment address
of the PSP, so you can save a pointer to the PSP to
access it later.

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.