Hey, Im learning assembler and have written as small test program.
the aim of the program is to take a char input from the keyboard and compare it wit "A". This section of the program works. At the start of the program I want to output a message just to prompt for the input, but when I execute the program there seems to be garbage in front of my message. Please help me on how to fix this.

.model small
.stack
.code

jmp start ; go to start of program
;_______________________________
;Variable declerations
message db "Enter Input:","$" ; $ to show end of string for subfunction 9
equal db "="    ;variable holding a =
exclaim db "!"
;_______________________________

start:
mov ah,09 ; for outputting a string and not a character
mov dx,offset message  ;dx point s to the adress of string
int 21h ;do it
input:
mov ah,08 ; 08 for keyboard input
int 21h
mov bl,al
cmp bl,65   ;compare bl with 65 which is A
jnz output_yes  ;there is a difference

output_no:  ;when theres no difference
mov dl,bl   ;move bl into dl for print
mov ah,02   ;print character
int 21h     ;do it
mov dl,equal
int 21h
mov dl,65
int 21h
jmp exit    ; to skip output_yes

output_yes: ;what to output when theres a difference
mov dl,bl
mov ah,02
int 21h
mov dl,exclaim
int 21h
mov dl,equal
int 21h
mov dl,65
int 21h

exit:
mov ah,04Ch ; exit function
mov al,00
int 21h

END

δ►ÉEnter Input:

My message is diplayed like this

Member Avatar for 1stDAN

I think .model small has .data segment where data is placed.

.model small
.stack
.data
message db "Enter Input:","$" ; $ to show end of string for subfunction 9

.code

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.