int 21 causes an access violation

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2007
Posts: 13
Reputation: blerina12 is an unknown quantity at this point 
Solved Threads: 0
blerina12 blerina12 is offline Offline
Newbie Poster

int 21 causes an access violation

 
-1
  #1
Sep 26th, 2009
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?

  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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 137
Reputation: NotNull is an unknown quantity at this point 
Solved Threads: 14
NotNull's Avatar
NotNull NotNull is offline Offline
Junior Poster

Re: int 21 causes an access violation

 
0
  #2
Sep 26th, 2009
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:
  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.
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 13
Reputation: blerina12 is an unknown quantity at this point 
Solved Threads: 0
blerina12 blerina12 is offline Offline
Newbie Poster

Re: int 21 causes an access violation

 
0
  #3
Sep 27th, 2009
Originally Posted by NotNull View Post
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:
  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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC