943,982 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Marked Solved
  • Views: 6369
  • Assembly RSS
Nov 6th, 2009
0

int 21h/ah=09h string output

Expand Post »
im using fasm (flat assembler 1.68), and im trying to output a string with int21h/ah=09h

Assembly Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
brando|away is offline Offline
32 posts
since Dec 2008
Nov 6th, 2009
0
Re: int 21h/ah=09h string output
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?
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Nov 6th, 2009
0
Re: int 21h/ah=09h string output
Click to Expand / Collapse  Quote originally posted by dan63043 ...
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
Assembly Syntax (Toggle Plain Text)
  1. mov ah, 4Ch
  2. int 21h
or 'ret'

i still see control characters before my message
Reputation Points: 10
Solved Threads: 0
Light Poster
brando|away is offline Offline
32 posts
since Dec 2008
Nov 7th, 2009
0
Re: int 21h/ah=09h string output
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; Nov 7th, 2009 at 2:54 am. Reason: Add request for debug output
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Nov 7th, 2009
0
Re: int 21h/ah=09h string output
Click to Expand / Collapse  Quote originally posted by dan63043 ...
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:

Assembly Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Light Poster
brando|away is offline Offline
32 posts
since Dec 2008
Nov 7th, 2009
0
Re: int 21h/ah=09h string output
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
Assembly Syntax (Toggle Plain Text)
  1. MOV DX,0002
to
Assembly Syntax (Toggle Plain Text)
  1. MOV DX,0102

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

Assembly Syntax (Toggle Plain Text)
  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
Reputation Points: 12
Solved Threads: 5
Light Poster
dan63043 is offline Offline
36 posts
since Dec 2007
Nov 8th, 2009
0
Re: int 21h/ah=09h string output
thanks, turns out i should of had an org statement in the first place
Reputation Points: 10
Solved Threads: 0
Light Poster
brando|away is offline Offline
32 posts
since Dec 2008
Jun 18th, 2010
0
Re: int 21h/ah=09h string output
need code snake game
run emu8086
Reputation Points: 10
Solved Threads: 0
Newbie Poster
skyir is offline Offline
5 posts
since Jun 2010
Nov 7th, 2010
0
Re: int 21h/ah=09h string output
Hi, I'm trying to print the $ character. I tried putting a "\" but it didnt work..
Any idea??
Reputation Points: 10
Solved Threads: 1
Newbie Poster
davibq is offline Offline
5 posts
since May 2010

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: Help with assembly 8086
Next Thread in Assembly Forum Timeline: what is wrong with this!!!





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


Follow us on Twitter


© 2011 DaniWeb® LLC