-1

Hello guys. I am having a problem with the following code. When I try to run the program the instruction int 21 causes an access violation. Can someone tell me how to fix this problem?

.386
.model flat

.stack 100h

.data

message db 'Hello World', 13, 10, '$'

.code

_start: 

lea dx, message 

mov ah, 9h ; string output

int 21h ; display string

mov ax, 4c00h

int 21h

mov ah, 1h 

int 21h ; read character into al

mov dl, al 

mov ah, 2h 

int 21h ; display character in dl

mov ax, 4c00h 

int 21h

end _start
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by blerina12
0

Access violation is caused when a program attempts to
access memory reserved for the operating system.
I thought this could only happen in a windows program?

I assume your using MASM:

mov ax, seg message ; initialize the DS register so
mov ds, ax                  ; you can access variable 'message'
lea dx, message

Program flow stops before line 23, because you terminated
with 21/4C.

0

Access violation is caused when a program attempts to
access memory reserved for the operating system.
I thought this could only happen in a windows program?

I assume your using MASM:

mov ax, seg message ; initialize the DS register so
mov ds, ax                  ; you can access variable 'message'
lea dx, message

Program flow stops before line 23, because you terminated
with 21/4C.

Thanks a lot :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.