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

  • SEARCH
  • Home
  • 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 7784135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:02:49+00:00 2026-06-01T20:02:49+00:00

I am using this code for a Hello world bootloader. Instead of printing out

  • 0

I am using this code for a Hello world bootloader. Instead of printing out “Hello world\n” it just prints out a ‘H’ and hangs. I have used loadsb print out the message successfully but I can’t understand why this approach won’t work as it seems equivalent.

[ORG 0x7c00]
[BITS 16]

    xor ax, ax  ;make it zero
    mov ds, ax

    mov ecx, msg
bios_print:
    mov al, [ecx]
    add ecx,1
    cmp al, 0  ;zero=end of str
    je hang    ;get out
    cmp al,100
    jge hang
    mov ah, 0x0E
    int 0x10
    jmp bios_print


hang:
    jmp hang

msg   db 'Hello World', 13, 10, 0






   times 510-($-$$) db 0
   db 0x55
   db 0xAA

Edit:
I changed the [BITS 64] to [BITS 16]

  • 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-06-01T20:02:49+00:00Added an answer on June 1, 2026 at 8:02 pm

    Your program is working exactly in a way you’ve coded it. The lower-case e in ASCII is represented as 65h, which equals 101 in decimal. Therefore, executing cmp al, 100 / jge hang if e (101) is in al results in a jump to the label hang. Everything’s alright. 🙂

    A solution to your problem would be simply deleting that line, since I don’t really see any purpose for it – seeing how you’ve got your string terminated by a \0, the loop will end when it reaches the end.

    Four extra tips, though :

    • Remember that the flags are set after (almost) every arithmetical and logical operation. Therefore, there’s really no need to do a cmp after an add, especially if the only condition of the jump can be represented by one of the flags. In this case, add ecx, 1 / cmp al, 0 / je hang can be replaced by a very simple add ecx, 1 / jz hang. This saves you two bytes, so valuable in those bootsector conditions.
    • You really do want to preserve the registers that you’re using in your application when calling a BIOS routine. BIOSes come from different vendors and some of them might not play nice and destroy what you have in your registers. The instruction pusha does just that. It’s generally a rule of thumb to preserve all the runtime information when calling any piece of code you haven’t written yourself (though this may sound extreme in more “civilized” environments – but BIOS and general real mode code isn’t one).
    • When the computer boots up, it’s in real mode. The default operand and address size in this mode is 16 bits (addresses are artificially extended by segmentation to 20 bits). You can, of course, use the 32-bit parts of the registers, but a operand size prefix must be generated before the instruction for that to happen. This is another byte, and you’ve got only 510 of them now. 🙂 Therefore, mov ecx, msg is simply redundant – the offset part of the address will never be longer than 16 bits. Same goes for add ecx, 1. Just replace ecx with cx in both those cases.
    • Use the hlt instruction. It makes your CPU’s blood pressure much lower, and there’s really no use in stressing it all over the place. Simply add hlt after the hang label and before the jump.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: char* hello = Hello World; std::cout << Pointer value =
This code: #include <iostream> using namespace std; int main() { cout << Hello world!\n;
Consider this code: #include <iostream> using namespace std; class hello{ public: void f(){ cout<<f<<endl;
I just created a HTTP server using this code fro the documentation: var sys
Using this code to zip a folder and it works perfect on small files
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
Using This code: I am tring to fill the page with the data and
Im using this code for mysql connection $con = mysql_connect(localhost:/var/lib/mysql/mysql.sock, abc , xyz); if
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1

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.