Closed Thread
Results 1 to 2 of 2

Thread: Can anyone tell why this doesn't work?

  1. #1
    Join Date
    Apr 2008
    Posts
    789
    Blog Entries
    5
    Rep Power
    24

    Can anyone tell why this doesn't work?

    Okay, so I have some real-mode code that displays characters on the screen. It should work, but doesn't.
    Code:
    [BITS 16]
    [ORG 1000h]
    hello:
    	mov BYTE al,[string]
    	call charout
    	call charout
    .end	jmp .end
    ; outputs the character in al.
    charout: 
    	mov ah,0x0E
    	mov bh,0x00
    	mov bl,0x06
    	int 0x10
    	ret
    
    string: db "HELLO WORLD",10,13,0 ; message to display
    times (512*2)-($-$$) db 0		;512 bytes to a sector
    It's really weird, becauseit works if I put a inline value into al, but not if I read from string.
    Last edited by Aereshaa; 06-22-2009 at 12:42 PM.
    Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
    "When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    outsid3r's Avatar
    outsid3r is offline Programming God
    Join Date
    Jul 2008
    Posts
    621
    Rep Power
    18

    Re: Can anyone tell why this doesn't work?

    You're calling a bios function what writes a character in teletype mode, so following the logic of your program, it should put the first 2 characters from your string, the thing is, you're not moving the pointer to string so it always prints the first character. You're passing the value of the first character from your string to al, but u must instead pass the reference (remove the brackets) to a register like SI, DI, AX, BX, DX, ... and increment your pointer using INC instruction. Make a loop in a new function that iterates through the string until it finds a 0 (null).
    I can help you with that if you need.

    Check this reference: Interrupt Services DOS/BIOS/EMS/Mouse

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Work with Web cam
    By Abbath1349 in forum C# Programming
    Replies: 1
    Last Post: 07-05-2011, 12:29 PM
  2. How does CGI work, actually?
    By totonex in forum Perl
    Replies: 7
    Last Post: 03-21-2011, 03:03 AM
  3. why does this work, why would you do it.
    By zeroradius in forum General Programming
    Replies: 6
    Last Post: 09-27-2010, 09:57 AM
  4. Why doesn't this work?
    By JaseR33 in forum Java Help
    Replies: 3
    Last Post: 08-08-2010, 11:16 PM
  5. How does CPM work?
    By Masterguns in forum Business and Legal
    Replies: 5
    Last Post: 09-08-2007, 09:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts