0

I was trying to make an OS and started learning x86 assembly language. I learnt some basics of BIOS and 16-bit mode. Although the issue I am facing right now is that when I load the .bin file in qemu emulator, it only prints "Hello, World!". If I change the string only it does not appear on screen. Let me share code and Screenshots here. Thanks in advance. Screenshot of Hello World

[org 0x07c00]
string: DB "Hello, World!", 0
MOV ah, 0x0e
MOV bx, string

_start:
    MOV al, [bx]
    INC bx
    INT 0x10
    cmp al, 0
    jne _start

inp:
    MOV ah, 0x00
    INT 0x16
    MOV ah, 0x0e
    INT 0x10
    cmp al, 0x10
    jne inp

jmp $
times 510 - ($ - $$) db 0
db 0x55, 0xaa

Changed String With "Username"

[org 0x07c00]
string: DB "Username: ", 0
MOV ah, 0x0e
MOV bx, string

_start:
    MOV al, [bx]
    INC bx
    INT 0x10
    cmp al, 0
    jne _start

inp:
    MOV ah, 0x00
    INT 0x16
    MOV ah, 0x0e
    INT 0x10
    cmp al, 0x10
    jne inp

jmp $
times 510 - ($ - $$) db 0
db 0x55, 0xaa

I tried figuring out why this happens but I could not find any resource so, I thought I should share my problem here.

ecm
  • 2,583
  • 4
  • 21
  • 29
  • Your data is in the path of execution. Move it elsewhere. – ecm Mar 26 '22 at 15:06
  • 1
    It's surprising your first version worked at all! That Hello string decodes and executes as a bunch of instructions including some I/O to ports that depend on initial register state: `dec ax` / `gs insb` `insb` / `outsw` / `sub al,0x20` / `push di` / `outsw` / `jc 0x77` / `and [fs:bx+si],ax`. That `jc` would jump past all your printing code if taken, so I guess it's not. And apparently the memory accesses don't overwrite anything important. I used `ndisasm foo` to disassemble the boot sector. – Peter Cordes Mar 26 '22 at 19:04

0 Answers0