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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:33:18+00:00 2026-06-06T04:33:18+00:00

I’m trying to load sectors from the disk into memory with the following assembly

  • 0

I’m trying to load sectors from the disk into memory with the following assembly code, but as I figured out with some int 0x10 to the terminal, the reason it’s not working is it gets stuck in an infinite loop. I thought loop automatically decremented the cx register for me. Below is the code, with the test show_message left in for you to see how I came to the conclusion that loop is not decrementing cx. What I see is msg_2 “Still in loop” over and over and over again without end.

Another great answer would be why the read never succeeds (why the carry flag is never clear) as I’m very confident the values for the registers are good at the time of the call, but other than those registers’ contents not being right, if someone can see something I did wrong in setting up for int 0x13, that would be great too.

One last note: I know about ch being the low eight bits of the cylinder, the two high bits of cl being the two high bits of the cylinder, and the low 6 bits of cl being the sector number. My stuff is at cylinder 0, sector 2, so [CYLNUM] is 0x00 and [SECTNUM] is 0x02.

;;;Load Memory;;;

load_mem:

 mov cx, 3        ;Try to read the drive 3 times



read_loop:

  xor ah, ah        ;ah=0, reset drive

  int 0x13            ;Call drive reset



  mov ax, [SYSADDR]

  mov es, ax        ;Destination- es:bx

  mov bx, 0



  mov dl, [DRIVENUM]

  mov dh, [HEADNUM]

  mov al, [NUMKERNELSECTS]

  mov ch, [CYLNUM]

  mov cl, [SECTNUM]

  mov ah, 0x02        ;ah=2, read drive

  int 0x13            ;Call read interrupt

  jnc exit            ;If carry flag is clear, exit
;;test;;
  mov si, msg_2
  call show_message
;;test;;

  loop read_loop

  mov si, read_error    ;Failed 3 times

  call show_message

hang:

  jmp hang            ;hang for now

exit:

  ret
  • 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-06T04:33:21+00:00Added an answer on June 6, 2026 at 4:33 am

    You’re modifying CX in your loop:

      mov ch, [CYLNUM]
    
      mov cl, [SECTNUM]
    

    CX register consists of CH (Higher byte) and CL (Lower byte).

    To avoid that, you could try using PUSH/POP operations on CX (or ECX) before/after the INT invocation (or maybe better at the beginning/end of the loop).

    Of course, I may be wrong – I haven’t been programming in assembly for 10 years.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.