News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Several variables in Data Segment

Started by hywum, December 25, 2011, 10:16:35 PM

Previous topic - Next topic

hywum

Hi,

I'm a beginner of 16-bit programming and have a problem that I'm not able to give account.
There are no errors, but there is alway printed "You pressed 'i'.".
This is my code:

DATA SEGMENT
Message db "You pressed 'i'.", "$"
Message2 db "You didn't press 'i'", "$"
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
start:

mov ah, 0
int 16h ; al = pressed key

cmp al, 'i'
jne ng

g:
mov dx, offset Message
mov ah, 9
int 21h
jmp _end
ng:
mov dx, offset Message2
mov ah, 9
int 21h
jmp start
_end:
mov ah, 0
int 16h

mov ah, 4Ch
int 21h
CODE ENDS
END start



Thx for your replies

jj2007

Assume is not sufficient - you need to load the register.

start:
  mov ax, @DATA ; set the DS register to DGROUP
  mov ds, ax ; for ds:si (lods)


Check also the macros included in DosBasic.

hywum

Wow, this is great, it works fine. :)
Thank you very much!  :U