NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: ramosaurio on February 05, 2019, 08:20:15 PM
-
Hello everyone, i just started to learn programming with nasm. I'm doing a little program to verify the Bios interrupt set.
I have experience programming with ARM, but now i'm stuck with the 0x10 interruption. I did a simple "Hello" to print it with the 0X0E mode.
[BITS 16]
org 0x7c00
mov ah, 0x0e
mov al, 'H'
int 0x10
mov al, 'E'
int 0x10
mov al, 'L'
int 0x10
int 0x10
mov al, 'O'
int 0x10
jmp $
times 510 - ($-$$) db 0
dw 0xaa55
I take this example from this Bootloader project https://github.com/cfenollosa/os-tutorial/tree/master/02-bootsector-print (https://github.com/cfenollosa/os-tutorial/tree/master/02-bootsector-print)
The problem is that when i mount it in my VM it only prints the first lettler but not the others letters.
Thank's in advantage.
PD. I think that i post it in the correct section, sorry if there are any problem.
-
Hi ramosaurio,
Welcome to the Forum.
I would expect your code to work on real hardware. Who knows what a VM might do? Try reloading ah with 0x0E before each interrupt.
Best,
Frank
-
With a properly written IBM compatible BIOS that should work. Can you use a debugger to single step through the code while in the VM, to see if it is changing any registers?
-
Try this:
bits 16
jmp 0x7c0:_start ; I prefeer to use smaller offsets!
_start:
push cs
pop ds
cld
lea si,[msg]
.loop:
mov ah,0x0e
lodsb
test al,al
jz _exit
mov bx,7 ; page 0, white foreground.
int 0x10 ; probably int 0x10 destroys AX...
jmp .loop
_exit:
hlt
jmp _exit
msg: db `Hello!!!\0`
times 510-($-$$) db 0
dw 0xaa55
-
Hi ramosaurio,
Welcome to the Forum.
I would expect your code to work on real hardware. Who knows what a VM might do? Try reloading ah with 0x0E before each interrupt.
Best,
Frank
I tried reloading 0X0E before each interrupt and i have the same problem.
Anyway thank's i'm going to try it on real hardware because i didn't know that the VM could give me so many problems.
With a properly written IBM compatible BIOS that should work. Can you use a debugger to single step through the code while in the VM, to see if it is changing any registers?
Okay, i'm not using any debugger for the VM, could you recommend me some free debugger? (i heard from one called IDA, but i got it and the free version doesn't support x64 architectures.
Thank's
-
Try this:
bits 16
jmp 0x7c0:_start ; I prefeer to use smaller offsets!
_start:
push cs
pop ds
cld
lea si,[msg]
.loop:
mov ah,0x0e
lodsb
test al,al
jz _exit
mov bx,7 ; page 0, white foreground.
int 0x10 ; probably int 0x10 destroys AX...
jmp .loop
_exit:
hlt
jmp _exit
msg: db `Hello!!!\0`
times 510-($-$$) db 0
dw 0xaa55
Hello fredericopissarra i tried your code and in this case the program does nothing, only display the cursor blinking. I tried changing some things of your code, removing the halt instruction and changing the offset. But it gives the same result, the cursor blinking.
Anyway thanks for the answer.
Right now, i think that the best possible solution is try it in real hardware.
-
$ ls -l
total 4
-rw-r--r-- 1 frederico frederico 308 fev 6 19:48 boot.asm
$ nasm -f bin boot.asm -o boot.bin
$ qemu-system-i386 boot.bin
Image attached...