Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7183591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:00:52+00:00 2026-05-28T18:00:52+00:00

I am currently playing around with x86 assembler since I wanted to refresh my

  • 0

I am currently playing around with x86 assembler since I wanted to refresh my skills for low level programming :-). For testing purposes I tried to write a function that just prints out a given string. The printing function itself works fine. In a further step I wanted to load a second assembler program from disk jump to it and just print out a text. Loading from disk at jump to the address works fine.

Here is the given scenario:

[... loading from disk etc ... program is loaded to 0x7e0:0001]

jmp 0x7e0:0001

[... context of other asm ...]

jmp Start
;data fields
msg db "Hello World!",0

Start:
     xor si, si     ; clear SI register
     mov si, msg    ; load message to SI register

     call Print

     cli
     hlt            ; halt the system

Print:
     .PrintLoop:
         lodsb                ; load byte from SI register
         or al, al            ; check if 0 byte
         jz short .PrintDone  ; if so - stop
         mov ah, 0Ah          ; function - print text to cursor
         int 0x10             ; BIOS interrupt

         jmp .PrintLoop       ; continue with next char
     .PrintDone:
         ret

All of this program is working fine. The only problem that I face is, that no text is printed. During debugging I saw that the print function immediately jumps to the .PrintDone label since there seems to be no data in SI and therefore lodsb loads nothing to al (besides null byte).

I was thinking about the fact, that there might be something wrong with the data segment.

Thus, I added the following line at the beginning of the Start-Routine:

xor ax, ax    ; clear ax register
mov ax, cs    
mov ds, ax    ; set data segment pointer

But this changed nothing regarding the programs behaviour. Nothing is printed.

Inspecting the CPU registers when execution reaches halt instruction, gives the following:

EAX=00000a00 EBX=00000000 ECX=00000002 EDX=00000000
ESI=00000026 EDI=00000000 EBP=00000000 ESP=0000ffff
EIP=00000036 EFL=00000046 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=1
ES =07e0 00007e00 0000ffff 00009300
CS =07e0 00007e00 0000ffff 00009b00
SS =9000 00090000 0000ffff 00009300
DS =07e0 00007e00 0000ffff 00009300

Do you have any clue what’s going on here?

[EDIT – PROBLEM RESOLVED]

Replacing:

mov ah, 0Ah -> mov ah, 0xE

fixes the problem!

Best
Sebastian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:00:53+00:00Added an answer on May 28, 2026 at 6:00 pm

    There are a few problems.

    First, you don’t properly set the registers for function 0Ah. You have to set bh to the page number (0), and cx to the repeat count (1).

    Second, this BIOS function doesn’t advance the cursor position and all characters get printed into the same location on the screen, overwriting each other, which should lead to only ‘!’ visible since it’s the last character.

    I advise to use function 0Eh instead.

    Third, you don’t initialize the direction flag (flags.df) which lodsb relies upon. You should use cld to reset df.

    Fourth, I don’t see all the code, but you should use the proper org directive to generate correct offsets for instructions and data.

    Also, NMIs and SMIs will cause hlt completion and the code that follows will execute (and what follows is your Print). You want to execute hlt in a loop.

    With these fixes we arrive at:

    bits 16
    org 1
    
    jmp Start
    ;data fields
    msg db "Hello World!",0
    
    Start:
         mov ax, cs    
         mov ds, ax    ; set data segment pointer
         cld
    
         mov si, msg    ; load message to SI register
    
         call Print
    
         cli
    .halt:
         hlt            ; halt the system
         jmp .halt
    
    Print:
         .PrintLoop:
             lodsb                ; load byte from SI register
             or al, al            ; check if 0 byte
             jz short .PrintDone  ; if so - stop
    ;         mov ah, 0Ah          ; function - print text to cursor
    ;         xor bh, bh
    ;         mov cx, 1
             mov ah, 0Eh          ; function - print text tty
    
             int 0x10             ; BIOS interrupt
    
             jmp .PrintLoop       ; continue with next char
         .PrintDone:
             ret
    

    The binary which you get by compiling the above with nasm blah.asm -f bin -o blah.bin should then be loaded at 0x7e0:0001 and jumped to with jmp 0x7e0:0001.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently playing around with the FileSystemWatcher class wanted to know how to
Programming newbie here, about a month in with Ruby. I'm currently playing around with
i`m currently playing around with WPF and now i wonder what would be the
I'm currently playing around with HTML_QuickForm for generating forms in PHP. It seems kind
Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility.
I am currently playing around with the HybridSessionBuilder class found on Jeffrey Palermo's blog
I am currently playing around with the Asp.Net mvc framework and loving it compared
I'm currently playing around with tipfy on Google's Appengine and just recently ran into
I've got a bit of fettish for language design and I'm currently playing around
I am currently learning about basic networking in java. I have been playing around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.