This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simulator issue with printf?

While using the simulator, the values of i in the serial window are shifted by left 8 bits.

#include "stdlib.h"
#include "stdio.h"
#include "reg51.h"

void main (void)
{
    unsigned char i;
    SCON  = 0x50;
    TMOD |= 0x20;
    TH1   = 221;
    TR1   = 1;
    TI    = 1;

    for (i = 0; i < 8; i++)
    {
        printf("%x\n", i);
    }
}

Parents
  • So, to conclude:

    1) You have hijacked a thread (actually at least two threads).

    2) You like to SCREAM in threads.

    3) You like to constantly repeat your questions.

    4) You like to formulate your questions as requests.

    5) You don't know what problem you want to solve - hence the incorrect query about printing BCD numbers.

    6) This is a school assignment.

    7) Your current bet is some rubbish code you have got from a friend.

    8) You think uninitialized variables are the way to go, because the broken code looks like it produces sligthly better results then.

    9) You refuces to sit down with a pen and paper and figure out what to do, and how to do it.

    10) You think cheating in an acceptable way of passing school assignments.

    Exactly what do you expect us to do about this mess? receive the full unabrigated school assignment and write a fully working and perfectly documented program to solve the task for you? Would that make you a better student - or just a student that have cheated?

    Note, that by helping you cheat on school assignments, that makes us cheaters too. If I just knew exactly what the task is, I could probably code and test the code within 5 minutes. Hence, if you participated on the lessons, you should be able to solve the problem (without Google) within an hour.

    How about picking up the school books and for cnce spend some time reading them. Yes, I know that this will take a _huge_ amount of time. It is quite obvious that you will have to open the books at an very early page. Variables are treated very early. Uninitialized variables are definitely discussed very thoroughly!

    This is a _trivial_ assignment, so do spend some time solving it yourself, instead of almost killing yourself trying to find the best way to cheat.

    By the way - you do know that some teachers actually keeps track of Internet forums, to see which students are busying themselves with cheating? They don't have to read all posts on all forums in this world: The advantage of Google, is that they can google for people cheating...

Reply
  • So, to conclude:

    1) You have hijacked a thread (actually at least two threads).

    2) You like to SCREAM in threads.

    3) You like to constantly repeat your questions.

    4) You like to formulate your questions as requests.

    5) You don't know what problem you want to solve - hence the incorrect query about printing BCD numbers.

    6) This is a school assignment.

    7) Your current bet is some rubbish code you have got from a friend.

    8) You think uninitialized variables are the way to go, because the broken code looks like it produces sligthly better results then.

    9) You refuces to sit down with a pen and paper and figure out what to do, and how to do it.

    10) You think cheating in an acceptable way of passing school assignments.

    Exactly what do you expect us to do about this mess? receive the full unabrigated school assignment and write a fully working and perfectly documented program to solve the task for you? Would that make you a better student - or just a student that have cheated?

    Note, that by helping you cheat on school assignments, that makes us cheaters too. If I just knew exactly what the task is, I could probably code and test the code within 5 minutes. Hence, if you participated on the lessons, you should be able to solve the problem (without Google) within an hour.

    How about picking up the school books and for cnce spend some time reading them. Yes, I know that this will take a _huge_ amount of time. It is quite obvious that you will have to open the books at an very early page. Variables are treated very early. Uninitialized variables are definitely discussed very thoroughly!

    This is a _trivial_ assignment, so do spend some time solving it yourself, instead of almost killing yourself trying to find the best way to cheat.

    By the way - you do know that some teachers actually keeps track of Internet forums, to see which students are busying themselves with cheating? They don't have to read all posts on all forums in this world: The advantage of Google, is that they can google for people cheating...

Children