943,864 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Marked Solved
  • Views: 1050
  • Assembly RSS
Sep 26th, 2009
-1

int 21 causes an access violation

Expand Post »
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?

Assembly Syntax (Toggle Plain Text)
  1. .386
  2. .model flat
  3.  
  4. .stack 100h
  5.  
  6. .data
  7.  
  8. message db 'Hello World', 13, 10, '$'
  9.  
  10. .code
  11.  
  12. _start:
  13.  
  14. lea dx, message
  15.  
  16. mov ah, 9h ; string output
  17.  
  18. int 21h ; display string
  19.  
  20. mov ax, 4c00h
  21.  
  22. int 21h
  23.  
  24. mov ah, 1h
  25.  
  26. int 21h ; read character into al
  27.  
  28. mov dl, al
  29.  
  30. mov ah, 2h
  31.  
  32. int 21h ; display character in dl
  33.  
  34. mov ax, 4c00h
  35.  
  36. int 21h
  37.  
  38. end _start
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blerina12 is offline Offline
22 posts
since Jan 2007
Sep 26th, 2009
0

Re: int 21 causes an access violation

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:
Assembly Syntax (Toggle Plain Text)
  1. mov ax, seg message ; initialize the DS register so
  2. mov ds, ax ; you can access variable 'message'
  3. lea dx, message

Program flow stops before line 23, because you terminated
with 21/4C.
Reputation Points: 36
Solved Threads: 19
Junior Poster
NotNull is offline Offline
198 posts
since Oct 2008
Sep 27th, 2009
0

Re: int 21 causes an access violation

Click to Expand / Collapse  Quote originally posted by NotNull ...
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:
Assembly Syntax (Toggle Plain Text)
  1. mov ax, seg message ; initialize the DS register so
  2. mov ds, ax ; you can access variable 'message'
  3. lea dx, message

Program flow stops before line 23, because you terminated
with 21/4C.
Thanks a lot
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blerina12 is offline Offline
22 posts
since Jan 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: need coding assembly ic 8051
Next Thread in Assembly Forum Timeline: Who Here Uses MASM





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC