Author Topic: My code isnt doing what its suppozed to do  (Read 9857 times)

Offline computertrick

  • Jr. Member
  • *
  • Posts: 4
My code isnt doing what its suppozed to do
« on: February 17, 2010, 05:52:43 PM »
ok in this code contains the code to turn text white but it isnt changeing the colour can you tell me what ive done wrong

im trying to make it turn the t white only

code:
Code: [Select]
[BITS 16]
[ORG 0x7c00]

        mov ah, 0eh
        xor bl, bl
            


     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h
     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

     mov al, 0x0D
       int 10h
     mov al, 0x0A
         int 10h

  
        mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h

 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h
 mov al, ' '
        int 10h


mov bl,0x07
mov al, 't'
int 10h
int 0x10

int 10h
mov al, 'S'
 int 10h
mov al, 'o'
 int 10h
mov al, 'l'
int 10h
mov al, 'a'
int 10h
mov al, 'r'

int 10h
je repeat
jmp shutdown

shutdown:
  
JMP 0FFFFh:0000h ; reboots system

      repeat:
          jmp repeat

times 512 - ($ - $$) db 0


Theirs a lot of errors in my code so far it only prints solar and it isnt white


ok so can someone fix this code then send it in a reply thanks alot :)

Edit: Please use code blocks instead of quote blocks for code.
« Last Edit: February 17, 2010, 06:53:44 PM by Keith Kanios »

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: My code isnt doing what its suppozed to do
« Reply #1 on: February 17, 2010, 07:24:23 PM »
As per Int 10/AH=0Eh, you haven't specified the page number in BX, in which should be zero in this case.

Also, it isn't safe to assume that the BIOS won't trash any particular registers. They shouldn't if they aren't supposed to, but with a PC history riddled with buggy BIOS implementations, it is better to be safe than sorry. The following is an example of safer encapsulation:

Code: [Select]
[BITS 16]
[ORG 0x7c00]

     mov al, 0x0D
     call print_chr

;... more printing...

je repeat
jmp shutdown

print_chr:
        mov ah, 0eh
        xor bh, bh
        int 10h
        ret

shutdown:
 
JMP 0FFFFh:0000h ; reboots system

      repeat:
          jmp repeat

times 512 - ($ - $$) db 0

Overall, a better and more efficient implementation would utilize Int 10/AH=13h (write string) instead.

As for the rest, here are some questions for you:

1.) Do you know where your stack is?
2.) Do you know what's in the segment registers?
3.) Is this code being used as a MBR?
4.) What's the purpose of je repeat?

That should be enough questions for a start :)