int 21h/ah=09h string output

Thread Solved

Join Date: Dec 2008
Posts: 29
Reputation: brando|away is an unknown quantity at this point 
Solved Threads: 0
brando|away brando|away is offline Offline
Light Poster

int 21h/ah=09h string output

 
0
  #1
17 Days Ago
im using fasm (flat assembler 1.68), and im trying to output a string with int21h/ah=09h

  1. jmp main
  2. msg db "hello world$"
  3. main:
  4. mov dx, msg
  5. mov ah, 09
  6. int 21h

this code outputs "hello world", but it outputs some control characters before it ([SOME WEIRD CONTROL CHARACTERS]hello world)

so how can i fix this?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 33
Reputation: dan63043 is an unknown quantity at this point 
Solved Threads: 4
dan63043 dan63043 is offline Offline
Light Poster
 
0
  #2
17 Days Ago
Strange.

Presumably DOS, or you'd get nothing.

I notice the lack of a return statement. The control chars may appear at the beginning of the line, but that doesn't mean they were printed before your message. You might be running past the end of your program, and hitting something that moves the cursor, then prints who-knows-what.

Also, I don't see any segment setup, so this is a com program?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 29
Reputation: brando|away is an unknown quantity at this point 
Solved Threads: 0
brando|away brando|away is offline Offline
Light Poster
 
0
  #3
17 Days Ago
Originally Posted by dan63043 View Post
Strange.

Presumably DOS, or you'd get nothing.

I notice the lack of a return statement. The control chars may appear at the beginning of the line, but that doesn't mean they were printed before your message. You might be running past the end of your program, and hitting something that moves the cursor, then prints who-knows-what.

Also, I don't see any segment setup, so this is a com program?
yes its DOS, and yes its a com program. And that was only part of the program.

even if i put
  1. mov ah, 4Ch
  2. int 21h
or 'ret'

i still see control characters before my message
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 33
Reputation: dan63043 is an unknown quantity at this point 
Solved Threads: 4
dan63043 dan63043 is offline Offline
Light Poster
 
0
  #4
17 Days Ago
Hmmm... not a fasm user, so just some other observations. No org statement, or use 16 statement. Thought fasm syntax was a dollar symbol before hex numbers, but that may be optional. Some assemblers need exe2bin to fix linkage of programs. Maybe give us the whole program and the process you follow and it could attract a solution.

Actually, it's so short, a dir listing of executable (so we see file size) and use debug to dump the contents, and post it here.
Last edited by dan63043; 17 Days Ago at 2:54 am. Reason: Add request for debug output
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 29
Reputation: brando|away is an unknown quantity at this point 
Solved Threads: 0
brando|away brando|away is offline Offline
Light Poster
 
0
  #5
16 Days Ago
Originally Posted by dan63043 View Post
Hmmm... not a fasm user, so just some other observations. No org statement, or use 16 statement. Thought fasm syntax was a dollar symbol before hex numbers, but that may be optional. Some assemblers need exe2bin to fix linkage of programs. Maybe give us the whole program and the process you follow and it could attract a solution.

Actually, it's so short, a dir listing of executable (so we see file size) and use debug to dump the contents, and post it here.
Heres the disassembly:

  1. 1462:0100 EB0C JMP 010E
  2. 1462:0102 68 DB 68
  3. 1462:0103 65 DB 65
  4. 1462:0104 6C DB 6C
  5. 1462:0105 6C DB 6C
  6. 1462:0106 6F DB 6F
  7. 1462:0107 20776F AND [BX+6F],DH
  8. 1462:010A 726C JB 0178
  9. 1462:010C 64 DB 64
  10. 1462:010D 24BA AND AL,BA
  11. 1462:010F 0200 ADD AL,[BX+SI]
  12. 1462:0111 B409 MOV AH,09
  13. 1462:0113 CD21 INT 21
  14. 1462:0115 B44C MOV AH,4C
  15. 1462:0117 CD21 INT 21
  16. 1462:0119 0200 ADD AL,[BX+SI]
  17. 1462:011B B409 MOV AH,09
  18. 1462:011D CD21 INT 21
  19. 1462:011F B44C MOV AH,4C
  20. -u
  21. 1462:0121 CD21 INT 21
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 33
Reputation: dan63043 is an unknown quantity at this point 
Solved Threads: 4
dan63043 dan63043 is offline Offline
Light Poster
 
0
  #6
16 Days Ago
Ha! Isn't funny how we overlook the obvious? When you pointed DX at 0002, you forgot that your program actually loads at 0100. Just change
  1. MOV DX,0002
to
  1. MOV DX,0102

BTW, here's how to use debug to get a decent listing (ok, pathetic listing, but we're using "debug")

  1. -u100,101
  2. 139A:0100 EB0C JMP 010E
  3. -d102,10d
  4. 139A:0100 68 65 6C 6C 6F 20-77 6F 72 6C 64 24 hello world$
  5. -u10e,122
  6. 139A:010E BA0200 MOV DX,0002
  7. 139A:0111 B409 MOV AH,09
  8. 139A:0113 CD21 INT 21
  9. 139A:0115 B44C MOV AH,4C
  10. 139A:0117 CD21 INT 21
  11. 139A:0119 0200 ADD AL,[BX+SI]
  12. 139A:011B B409 MOV AH,09
  13. 139A:011D CD21 INT 21
  14. 139A:011F B44C MOV AH,4C
  15. 139A:0121 CD21 INT 21
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 29
Reputation: brando|away is an unknown quantity at this point 
Solved Threads: 0
brando|away brando|away is offline Offline
Light Poster
 
0
  #7
16 Days Ago
thanks, turns out i should of had an org statement in the first place
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