943,648 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2189
  • Assembly RSS
Aug 25th, 2009
0

cant get ah = 0ah to work!

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xellos is offline Offline
11 posts
since Aug 2009
Aug 25th, 2009
1

Re: cant get ah = 0ah to work!

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!

Assembly Syntax (Toggle Plain Text)
  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
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Aug 25th, 2009
0

Re: cant get ah = 0ah to work!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
xellos is offline Offline
11 posts
since Aug 2009
Aug 25th, 2009
0

Re: cant get ah = 0ah to work!

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
Reputation Points: 33
Solved Threads: 6
Junior Poster
Nathan Campos is offline Offline
190 posts
since Jul 2009
Aug 25th, 2009
0

Re: cant get ah = 0ah to work!

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.
Reputation Points: 546
Solved Threads: 99
Practically a Posting Shark
wildgoose is offline Offline
891 posts
since Jun 2009
Sep 3rd, 2009
0

Re: cant get ah = 0ah to work!

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:
Assembly Syntax (Toggle Plain Text)
  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:

Assembly Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kevincarroll is offline Offline
7 posts
since Sep 2009
Sep 6th, 2009
0

Re: cant get ah = 0ah to work!

Assembly Syntax (Toggle Plain Text)
  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.
Reputation Points: 36
Solved Threads: 19
Junior Poster
NotNull is offline Offline
198 posts
since Oct 2008

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: Input Characters
Next Thread in Assembly Forum Timeline: Writing *.bin Files To Floppy in Windows





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


Follow us on Twitter


© 2011 DaniWeb® LLC