cant get ah = 0ah to work!

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

Join Date: Aug 2009
Posts: 7
Reputation: xellos is an unknown quantity at this point 
Solved Threads: 0
xellos xellos is offline Offline
Newbie Poster

cant get ah = 0ah to work!

 
0
  #1
Aug 25th, 2009
whats wrong with my code?

.model small
.stack
.data

buffer db 10,?, 10 dup(' ')

.code

main proc

mov dx, offset buffer
mov ah, 0ah
int 21h

xor bx,bx

mov bl, buffer[1]
mov buffer[bx+2], '$'
mov dx, offset buffer + 2
mov ah,09
int 21h
ret

mov ah,4ch
int 21h

main endp
end main
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: cant get ah = 0ah to work!

 
1
  #2
Aug 25th, 2009
You aren't saying what's happening, and you aren't mentioning your toolset.

See if <buffer> is in its own segment or sitting at 0100h in the code instruction pointer path!

  1. buffer db 10,?, 10 dup(' ')
  2.  
  3. ; Get Buffered Keyboard input
  4. mov dx, offset buffer
  5. mov ah, 0ah ; Command Buffered Keyboard Input
  6. int 21h ; DOS interrupt
  7. ; 0:bufsize, 1:char count, 2...N buffer
  8.  
  9. xor bx,bx
  10. mov bl, buffer[1]
  11.  
  12. ; mov buffer[bx+2], '$'
  13. mov buffer[bx+1], '$' ; Replace carriage return with terminator
  14.  
  15. mov dx, offset buffer + 2
  16. mov ah,09
  17. int 21h
  18. ;;;; ret
  19.  
  20. mov ah,4ch
  21. int 21h
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 7
Reputation: xellos is an unknown quantity at this point 
Solved Threads: 0
xellos xellos is offline Offline
Newbie Poster

Re: cant get ah = 0ah to work!

 
0
  #3
Aug 25th, 2009
sorry im using masm32 ml to asamble link16 to link

i can type something but when i hit enter the proc exits and does not
show the typed text
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 179
Reputation: Nathan Campos is an unknown quantity at this point 
Solved Threads: 6
Nathan Campos's Avatar
Nathan Campos Nathan Campos is offline Offline
Junior Poster

Re: cant get ah = 0ah to work!

 
0
  #4
Aug 25th, 2009
Hello xelos,
Please, surround your code with the code tags, like this: [ code=asm ] [ /code ] , but without the spaces.
This is just to understand better your code, put highlighting and be more organized.

Thanks,
Nathan Paulino Campos
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: cant get ah = 0ah to work!

 
0
  #5
Aug 25th, 2009
Just to be safe, move the data below the code! You're using the newer MASM32 (which I don't like, I still use MASM) with a 16-bit linker which implies you're making 16-bit Real Mode code.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 7
Reputation: kevincarroll is an unknown quantity at this point 
Solved Threads: 0
kevincarroll kevincarroll is offline Offline
Newbie Poster

Re: cant get ah = 0ah to work!

 
0
  #6
Sep 3rd, 2009
I've used masm32 only for debugin stuff, I usually assemble my own code so I can have it be more efficient, even though its a time waster.

I looked at what you got, there's nothing wrong with it, so i debugged it, and I saw that the values of the DS and CS when the program was loaded are different, and when I assembled it with the linker, it sticks both the code section and the data section together, so the address being loaded into the DX register was pointing to the wrong data,

Try sticking this in before you start:
  1. mov ax,cs
  2. mov ds,ax

also, it looks like you are not giving your program a time where it will wait to show you the result, you might want to add a keyboard wait after you have the string displayed back like:

  1. mov ah,00h
  2. int 16h

I tried it, it worked, but it may look like it doesn't do any thing, because the string that is typed into the buffer is cleared from the screen after it is inputted, so it looks as though nothing really happens, but its working.
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 online now Online
Junior Poster

Re: cant get ah = 0ah to work!

 
0
  #7
Sep 6th, 2009
  1. bits 16
  2. org 100h
  3.  
  4. jmp start
  5. buf db 32,0
  6. times 32 db 0
  7. start:
  8. mov dx,buf
  9. mov ah,0ah ;you called function 0ah correctly
  10. int 21h
  11. ;you terminated the string and used function 09h correctly
  12. mov bl,[buf+1]
  13. xor bh,bh
  14. mov byte [bx+buf+2],24h
  15. mov dx,buf+2
  16. mov ah,09
  17. int 21h
  18. int 20h
Last edited by NotNull; Sep 6th, 2009 at 2:24 pm.
----------------------------------------------------------
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  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC