Author Topic: Example INT 0x10 AH 0x0E in Bios  (Read 407 times)

Offline ramosaurio

  • Jr. Member
  • *
  • Posts: 3
  • Country: es
Example INT 0x10 AH 0x0E in Bios
« 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.
Code: [Select]
[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

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.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2361
  • Country: us
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #1 on: February 05, 2019, 09:38:49 PM »
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


Offline debs3759

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 54
  • Country: gb
    • GPUZoo
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #2 on: February 05, 2019, 11:21:29 PM »
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?
My graphics card database: www.gpuzoo.com

Offline fredericopissarra

  • Jr. Member
  • *
  • Posts: 45
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #3 on: February 06, 2019, 10:10:55 AM »
Try this:

Code: [Select]
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
« Last Edit: February 06, 2019, 10:13:09 AM by fredericopissarra »

Offline ramosaurio

  • Jr. Member
  • *
  • Posts: 3
  • Country: es
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #4 on: February 06, 2019, 04:53:26 PM »
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

Offline ramosaurio

  • Jr. Member
  • *
  • Posts: 3
  • Country: es
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #5 on: February 06, 2019, 06:11:10 PM »
Try this:

Code: [Select]
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.

Offline fredericopissarra

  • Jr. Member
  • *
  • Posts: 45
Re: Example INT 0x10 AH 0x0E in Bios
« Reply #6 on: February 06, 2019, 09:51:59 PM »
Code: [Select]
$ 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...