Number (decimal) in ascii -> binary

djsfantasi

Joined Apr 11, 2010
9,237
But if i don't understand the code in the program of my professor how am i supposed to know how to write the algorithm?
You’re confusing yourself by working on the code first. Even if it’s your professor’s code.

It’s not reasonable to expect to understand someone else’s code when you don’t understand what it’s trying to do!

That’s why you need to understand the algorithm first. It seems like you’re fighting yourself by finding excuses to not develop the algorithm first. We’ve told you that is the correct approach. I think you should try it.
 

Thread Starter

Rlern

Joined Nov 25, 2021
20
You’re confusing yourself by working on the code first. Even if it’s your professor’s code.

It’s not reasonable to expect to understand someone else’s code when you don’t understand what it’s trying to do!

That’s why you need to understand the algorithm first. It seems like you’re fighting yourself by finding excuses to not develop the algorithm first. We’ve told you that is the correct approach. I think you should try it.
Okay I will try to do it now, thanks
 

Thread Starter

Rlern

Joined Nov 25, 2021
20
You’re confusing yourself by working on the code first. Even if it’s your professor’s code.

It’s not reasonable to expect to understand someone else’s code when you don’t understand what it’s trying to do!

That’s why you need to understand the algorithm first. It seems like you’re fighting yourself by finding excuses to not develop the algorithm first. We’ve told you that is the correct approach. I think you should try it.
Hello,
I did this algorithm, am I right?
 

Attachments

MrChips

Joined Oct 2, 2009
34,826
A flowchart is one way to express a solution to a problem.
Pseudo code written in plain language is another way.

Is your flowchart complete?
Did you step through your flow chart and verified that it would work for every possible situation?

Every flowchart has a start (entry point) and an end (exit point).
Every flowchart has input and output.
When stepping through a flowchart, ask yourself the question "What if?"


1638798460739.png


1638798557787.png
 

Thread Starter

Rlern

Joined Nov 25, 2021
20
A flowchart is one way to express a solution to a problem.
Pseudo code written in plain language is another way.

Is your flowchart complete?
Did you step through your flow chart and verified that it would work for every possible situation?

Every flowchart has a start (entry point) and an end (exit point).
Every flowchart has input and output.
When stepping through a flowchart, ask yourself the question "What if?"


View attachment 254327


View attachment 254328
I think it's okay, I just don't take in account if an invalid ASCII character is detected in the input but I don't want to add more problems
I tried this afternoon to think about the address symbols for creating pointers in my code, but I don't know how to use them yet
 

djsfantasi

Joined Apr 11, 2010
9,237
Hello,
I did this algorithm, am I right?
Seems to me that you’re repeating something mentioned in another post, but do not understand why it’s used.

Go to MrChips response in post #35 and read it several times. If you don’t understand any part of it, ask questions.

Don’t try to understand the code. Only make an effort to understand MrChips post.

For example, the equation you used has two values, R and N. Where are they set; how do you determine them?
 

absf

Joined Dec 29, 2010
1,968
I don't understand the goal of multiplying by 10 at all.
.......
There is no interest to multiply by 10 here, so why?
Because there are many ways to acomplish your projcet. From your sample program, it seems you are using 8051 asm for your project, there is an instruction called "MUL AB" which would be handy to be used in your program.

Your sample program shows:
Code:
Main:

Loop:
        call    ASCII_2_BIN
     
        jmp    loop

ASII_2_BIN:
          call    MUL10
          RET

MUL10:

          RET
So I think you can include The multiplication instruction in your program.

The format of MUL is
MUL AB, where A register is multiplier and B register is multiplicand.
It is an 8 bit x 8 bit instruction and the result is 16 bit in A and B registers; where B is high (MSB) byte and A is low (LSB) byte.

You may use this way to get your answer.

Let's say your 4 numbers are 2 5 6 7 stored in 0x41 to 0x44,

Code:
1. get first number and mult by 10                 20
    store result in R4 and R5 (HI then LO)         (R4,R5) = 20
2 get second number and add it to R4,R5,          (R4,R5) = 25
    Mult R4,R5 by 10                                  (R4,R5) = 250
3. get 3rd number and add it to R4,R5            (R4,R5) = 256
    Mult R4,R5 by 10                                   (R4,R5) = 2560
4. get 4th (last) number and add it to R4,R5       (R4,R5) = 2567
    return
I hope you can get the idea how to get your flow chart constructed based on the above.

Good luck in your project.
 
Last edited:

MrChips

Joined Oct 2, 2009
34,826
Let's ignore the MUL instruction for now.

TS still has not responded on the question if they know how to multiply by 2.
 

djsfantasi

Joined Apr 11, 2010
9,237
@Rlern

I’m publicly calling you out, for your own good.

Rlern contacted me via PM, offering to pay me for a solution to this problem.

I offered to do it, if he gave me his professors email address so I could claim the college credit that I earned.

I explained the consequences of his actions. And passed on a story of mine. I was accused in college of stealing another’s work. Fortunately, my solution was unique and the other student couldn’t explain it. He was expelled from college.

To anyone considering his approach, do do at your own peril! The consequences are severe.
 

bertus

Joined Apr 5, 2008
22,928
Hello,

@Rlern , We do offer support, but will not give you a complete solution.
The members over here can give you guidelines to help you to reach the solution for your problem.
You will have to show your efforts, so we can see the progress.

Bertus
 
Top