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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:51:33+00:00 2026-05-17T22:51:33+00:00

I have started to learn assembly. I came across these lines. ;*************************************************; ; Second

  • 0

I have started to learn assembly. I came across these lines.

;*************************************************;
; Second Stage Loader Entry Point
;************************************************;

main:
   cli  ; clear interrupts
   push cs ; Insure DS=CS
   pop ds

Here on second line of code, the code segment is push to the stack(I think this). I have seen it in many codes. Why we should do this and how it ensures DS =CS? On third line DS is pop out of stack(I think this). Why it is done? It is pop out of stack means it was push to stack before. There is no code for that. Can anybody explain all this to me? Thanks in advance.

  • 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-17T22:51:33+00:00Added an answer on May 17, 2026 at 10:51 pm

    It’s not the push cs that ensures this, it’s the push cs; pop ds; combination that does.

    The first instruction copies the current value of cs onto the stack, and the second pulls that value off the stack and puts it into the ds register.


    In response to your request for more information, let’s start with the following stack and registers:

    stack=[1,2,3], cs=7, ds=6
    

    After push cs, which pushes the value of the cs register onto the stack:

    stack=[1,2,3,7], cs=7, ds=6
    

    After pop ds, which pops a value off the stack and put it into the ds register:

    stack=[1,2,3], cs=7, ds=7
    

    And that’s basically it.


    I can’t recall of the top of my head whether it was possible to transfer between segment registers with a mov instruction (I don’t think it was, but I may be wrong, and this would necessitate the push/pop sequence). This link would seem to confirm that: there is no mov option with a segment register as both source and destination.

    But even if it were, assembler coders often chose more suitable instructions, either for speed or compact code (or both), things like using xor ax, ax instead of mov ax, 0 for example.

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

Sidebar

Related Questions

When I started to learn about WPF and MVVM recently, I came across some
I have started to learn about python and is currently reading through a script
I'm really wanting to learn assembly. I'm pretty good at c/c++, but want a
I've recently started to learn Fluent NH, and I'm having some trouble with this
I'm learning assembly language. I started with Paul A. Carter's PC Assembly Language which
I've been trying to learn embedded software development for some time (been doing software
I would like to learn how to write device drivers because I think it
I sorta feel embarrassed because I am sure the answer to this is simple.
I am about to start my A-Level Computing project (High School Level) which will
Possible Duplicate: Haskell vs. procedural programming in the real world Few times I heard

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.