I’ve compiled this with nasm, and i’m running it through bochs. In my mind the 2 colour variable should make it print the 2 lines in blue. It actually prints one brown and one white. I cannot figure it out though. Any help immensely appreciated
[BITS 16]
[ORG 0x7C00]
main:
;set video mode
mov ah,0x00 ;function ref
mov al,0x10 ;param - video mode
int 0x10
mov si, TestString
mov bl,Color ; Normal text attribute
call PutStr
mov si, TestString
mov bl,Color2 ; Normal text attribute
call PutStr
jmp $
;-------------------------------- End of running code
PutStr:
; Set up the registers for the interrupt call
mov ah,0x0E ; The function to display a chacter (teletype)
mov bh,0x00 ; Page number
.nextchar:
lodsb ; load string byte from SI into AL and increments SI
or al,al ; check for end of string
jz .endofstring ; jump to end if null
int 0x10 ; Run the BIOS video interrupt
jmp .nextchar ; Loop back round to the top
.endofstring:
ret
Color db 0001b
Color2 db 0001b
TestString db 'Hello world',13,10,0,0
times 510-($-$$) db 0 ; Fill the rest of the sector with zero's
dw 0xAA55 ; Add the boot loader signature to the end
The problem is actually with the usage of the Color and Color2 identifier. You need to “dereference” them to get the actual value of what they “point” to:
Check out Effective Addresses in the NASM manual for more information.