Reputation: 109
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
Upvotes: 1
Views: 491
Reputation: 46998
db
allocates a byte of memory and sets the symbol to be the address of that memory (hence the need to dereference it).
If you just want a symbolic name for a constant value, use equ
:
Color equ 0001b
...
mov bl, Color
...
Upvotes: 1
Reputation: 150
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:
mov bl, [Color]
Check out Effective Addresses in the NASM manual for more information.
Upvotes: 1