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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:08:06+00:00 2026-05-26T03:08:06+00:00

From Does the program counter always have to change (upon a clock tick)? ,

  • 0

From Does the program counter always have to change (upon a clock tick)?, I already know that the PC does not have to change at each clock; as a particular instruction may take more than one clock tick to execute.

I’d like to further that question a bit. Let’s say we have the following simple C code:

// gcc -g min.c -o min.exe          # generate executable
// gcc -S min.c -o min.s            # generate assembler listing from source
// objdump -S min.exe > min.sdump   # generate assembler listing from executable
int main() {
  int a;
  a = 15;
  return a;
}

By comparing the assembler listings (objdump -S doesn’t always intersperse source lines very accurately), I get something like this:

min.s:                     min.sdump:
---------------------      -------------------------
main:                      08048394 <main>:
    pushl   %ebp                8048394: 55                    push   %ebp
    movl    %esp, %ebp          8048395: 89 e5                 mov    %esp,%ebp
    subl    $16, %esp           8048397: 83 ec 10              sub    $0x10,%esp
    movl    $15, -4(%ebp)       804839a: c7 45 fc 0f 00 00 00  movl   $0xf,-0x4(%ebp)
    movl    -4(%ebp), %eax      80483a1: 8b 45 fc              mov    -0x4(%ebp),%eax
    leave                       80483a4: c9                    leave
    ret                         80483a5: c3                    ret
    .size   main, .-main        80483a6: 90                    nop

I know this is most likely wrong – but let’s take that the one-byte instructions take one clock tick, and the others take two. Then, I could take the “instruction tick” to be the rising clock edge at the time after “the previous” command has finished; as shown the following timing diagram (corresponding to the disassembly listing; Latex/Tikz code for image can be found here):

min-timing.png

So to paraphrase the original question:

… Does the PC (program counter) always have to change (upon each new instruction tick)?
I was thinking, if an instruction set the PC (or rather next PC), so the next execution address is same as its current one, there would be no way to exit that loop (unless there is some extern interrupt, of course)?

  • 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-26T03:08:07+00:00Added an answer on May 26, 2026 at 3:08 am

    So this small program would do what you ask for:

    int main(){
        loop: goto loop;
    }
    

    It compile into something like this:

    .L3:
        jmp .L3
    

    The effect is, that the PC will stay the same when looking from the outside. On the inside the silicon will do something like this in one step:

    PC = argument of JMP
    

    The PC will be set but always to the same value as it is currently.

    Edit

    It is not clear what you mean exactly with “lock”. Every endless loop will will eat CPU resources and will be uninterruptible if interrupts are disabled. This has nothing to do whether the PC changes or not. The loop from above is only the smallest tight loop possible.

    However: On real systems there ARE interrupts – on every OS worth these two letters the scheduler will be woken up by a timer interrupt and give the CPU to the next process. Even on a microcontroller where there is usually no “operating system” internal and external interrupts are used in every non-trivial case. In fact – the tight loop from above is not uncommon on microcontrollers – the main job is done, the CPU goes into a tight loop and wait for the next interrupt. The interrupt will somehow break the loop.

    Please note, that on a real OS a mere user space program has no direct control over the interrupts for exactly that reason: Otherwise any stupid program could bring the system down with one assembler command.

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

Sidebar

Related Questions

I need a select from table which does not have column that tells when
From MSDN: The CancelWaitableTimer function does not change the signaled state of the timer.
I have to program a little program that show a Fibonacci sequence from 1
SELECT 1 FROM (SELECT 1 FROM table) q does not working on my local
Does any one know from where can I download source code for Cassini. I
Python does not print traceback messages from exceptions raised in daemon threads. For example,
I have a SQL Server table full of orders that my program needs to
I am using C# to write a program that uses a web service from
I have a program that writes to stdout and possibly stderr. I want to
I'm making a program that takes names from the user seperated by commas. The

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.