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 7569781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:15:09+00:00 2026-05-30T15:15:09+00:00

I have these two files myboot.asm and theirboot.asm (listed respectively): ;———————————————————————- ; A Simple

  • 0

I have these two files myboot.asm and theirboot.asm (listed respectively):

;----------------------------------------------------------------------
; A Simple boot program that prints the string 'Hello World'
; Author: Matthew Hoggan 2012
;----------------------------------------------------------------------
Output db 'Hello',0x00            ; Output string for bios

org 0x7c00                              ; This is where BIOS loads the bootloader

entry:                                  ; Label to Signify entry to program
    jmp short begin                     ; Jump over the DOS boot record data

; --------------------------------------------
;  Boot program code begins here
; --------------------------------------------
begin:                                  ; Label to Signify entry to program
mov si, Output                          ; Get pointer to string
loop:                                   ; Top of loop to iterate over string
    mov al, [si]                        ; Move contents of pointer to al
    or al, al                           ; Check if character pointed to is Zero
    jz hang                             ; Zero signifies end of string
    call print_char                     ; Print current char in al
    jmp loop                            ; Repeat

; --------------------------------------------
; Function to print char
; assume caller has placed char in al
; --------------------------------------------
print_char:
    mov ah, 0x0e                        ; Function to print a character to the screen
    mov bl, 7                           ; color/style to use for the character
    int 0x10                            ; print the character

hang:
        jmp     hang                    ; just loop forever.

;---------------------------------------------
; Write Zeros up to end of program - 2 then boot signature
;---------------------------------------------
size    equ     $ - entry
        times   (512 - size - 2) db 0
        db      0x55, 0xAA              ;2  byte boot signature

;----------------------------------------------------------------------
; A Simple boot program that prints the string 'Hello World'
;----------------------------------------------------------------------
org 0x7c00                              ; This is where BIOS loads the bootloader

entry:                                  ; Label to Signify entry to program
    jmp short begin                     ; Jump over the DOS boot record data
; --------------------------------------------
;  Boot program code begins here
; --------------------------------------------
begin:                                  ; Label to Signify entry to program
    xor ax, ax                          ; Zero out ax
    mov ds, ax                          ; Set data segment to base of RAM
    mov si, msg                         ; Get pointer to string
    call putstr                         ; Print the message
    jmp hang                            ; Go to infinite loop

msg db 'Hello, World',0x00

putstr:                                 ; Function to print the string
    lodsb                               ; al = [DS:SI]
    or al, al                           ; Set zero flag if al = 0
    jz ret                              ; Jump to end of function if al = 0
    mov ah, 0x0e                        ; Video function 0Eh (print char)
    mov bx, 0x0007                      ; Color
    int 0x10
    jmp putstr
ret:
    retn

hang:
        jmp     hang                    ; just loop forever.

;---------------------------------------------
; Write Zeros up to end of program - 2 then boot signature
;---------------------------------------------
size    equ     $ - entry
        times   (512 - size - 2) db 0
        db      0x55, 0xAA              ;2  byte boot signature

Building both of these files running hexdump on them and listing the files in the directory to see their size reveals:

mehoggan@mehoggan-laptop:~/Code/play/asm$ nasm myboot.asm -f bin -o boot.bin && hexdump boot.bin && ls -l && echo "------" && nasm bootloader1.asm -f bin -o boot.bin && hexdump boot.bin && ls -l
0000000 6548 6c6c 006f 00eb 00be 8a7c 0804 74c0
0000010 e80c 0003 f4e9 b4ff b30e cd07 e910 fffd
0000020 0000 0000 0000 0000 0000 0000 0000 0000
*
0000200 0000 0000 aa55                         
0000206
total 20
-rw-r--r-- 1 mehoggan mehoggan  518 2012-02-29 21:57 boot.bin
-rw-r--r-- 1 mehoggan mehoggan 2290 2012-02-29 20:23 bootloader0.asm
-rw-r--r-- 1 mehoggan mehoggan 1661 2012-02-29 21:55 bootloader1.asm
-rw-r--r-- 1 mehoggan mehoggan 1786 2012-02-29 21:49 myboot.asm
-rw-r--r-- 1 mehoggan mehoggan 1065 2012-02-29 20:14 ourbootloader.asm
------
0000000 00eb c031 d88e 0fbe e87c 0010 1de9 4800
0000010 6c65 6f6c 202c 6f57 6c72 0064 08ac 74c0
0000020 b40a bb0e 0007 10cd f1e9 c3ff fde9 00ff
0000030 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200
total 20
-rw-r--r-- 1 mehoggan mehoggan  512 2012-02-29 21:57 boot.bin
-rw-r--r-- 1 mehoggan mehoggan 2290 2012-02-29 20:23 bootloader0.asm
-rw-r--r-- 1 mehoggan mehoggan 1661 2012-02-29 21:55 bootloader1.asm
-rw-r--r-- 1 mehoggan mehoggan 1786 2012-02-29 21:49 myboot.asm
-rw-r--r-- 1 mehoggan mehoggan 1065 2012-02-29 20:14 ourbootloader.asm

Why are the files sizes off by 6 bytes?

  • 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-30T15:15:10+00:00Added an answer on May 30, 2026 at 3:15 pm

    Check out the last little block of assembly code there:

    size    equ     $ - entry
            times   (512 - size - 2) db 0
            db      0x55, 0xAA              ;2  byte boot signature
    

    This block of code calculates how big the code is (from entry to the current location), then pads it out to a total of 512 bytes with zeroes and a signature 0x55 0xAA in the last two positions. That is:

    entry: Some code
           .
           .
           .
      Some zeroes
           .
           .
           .
       0x55 0xAA 
    

    That little assembly block means the output size from the entry label to 0x55 0xAA is always 512 bytes. In your first example, there is a six byte string Hello\0 before entry. In your second example there’s not. Therefore, the first program is six bytes longer than the second. You probably want to move that string to someplace after entry and before the padding block.

    If you use hexump -C on your binaries, you’ll see the string right up at the top of the first binary.

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

Sidebar

Related Questions

I'm developing a simple webapp based on Spring framework. I have these two files
I have two text files that have these structures: File 1 Column1:Column2 Column1:Column2 ...
I have a class split across two files. One of these is generated, the
Is there any way to list all the files that have changed between two
I have these two methods on a class that differ only in one method
I have these two files File: 11 11 456123 File: 22 11 789 Output
I have two files. I want to create pdf with these two files. does
I have these two XIB files. The first one edited by my friend to
I'm having two files that I've to invoke from a java program: a batch
I have these two file in my project that I am migrating from php.

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.