How do I print an integer that is interpreted as hex?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
stevewoods1986
Member
Member
Posts: 80
Joined: Wed Aug 09, 2017 7:37 am

Re: How do I print an integer that is interpreted as hex?

Post by stevewoods1986 »

obiwac wrote:
I'm not the most experienced with instructions like AND and OR.
Ok hes a troll.
I am not a troll, OK? I am not a troll. I have done nothing to you. I am not a troll. I have no history of being a troll. I am not a troll.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: How do I print an integer that is interpreted as hex?

Post by BrightLight »

stevewoods1986 wrote:I don't want a puzzle. Fine, I'll figure it out.
I said it clearly enough. Imagine you're doing this in C without itoa(), printf() or any other standard functions. How would you do it? If you can't achieve that in C, then you can't do OS development. If you can do that in C, translate the code into assembly, looking up relevant instructions to do so.

Hint: Octacone already gave you the instructions you need.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: How do I print an integer that is interpreted as hex?

Post by neon »

Hello,
I don't want a puzzle. Fine, I'll figure it out.
You don't need to figure it out on your own. I even encouraged for you to take a close look at those answers and ask questions about it for clarity or sample code. How can we help someone that actively ignores the answers instead of asking questions?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
zaval
Member
Member
Posts: 659
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: How do I print an integer that is interpreted as hex?

Post by zaval »

MichaelFarthing wrote: How long will everyone be fooled by this troll? Anyone who casually uses a word like nybble can't possibly be innocently making the sort of posts we see.
this must be a huge compliment for Steve.

Steve is not a troll. Nor he is fooling the forum. He is just a very active noob @$$. :lol: Unfortunately, instead of directing his activity into hard and boring learning to achieve dreams come true, he is torturizing the forum. I guess School-Rea is especially vulnerable for this, since he tries to explain things in very details. And all that goes in vain, since Steve is not inclined to pay attention to advices.

Or maybe this is yet another "lickmynigga" incarnation, taking another approach for doing bad things?
Steve, stop it. It's embarrassing for you. Go learn. Assembly, Intel manuals, whatever.
Last edited by zaval on Thu Aug 17, 2017 1:15 pm, edited 1 time in total.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
stevewoods1986
Member
Member
Posts: 80
Joined: Wed Aug 09, 2017 7:37 am

Re: How do I print an integer that is interpreted as hex?

Post by stevewoods1986 »

neon wrote:Hello,
I don't want a puzzle. Fine, I'll figure it out.
You don't need to figure it out on your own. I even encouraged for you to take a close look at those answers and ask questions about it for clarity or sample code. How can we help someone that actively ignores the answers instead of asking questions?

Code: Select all

mov
Yep, mov is not really code. It's more of an instruction, huh?

Listen, I can do OS development. I have never been on such a (BLEEP)...ing negative forum. Everyone just complains.
stevewoods1986
Member
Member
Posts: 80
Joined: Wed Aug 09, 2017 7:37 am

Re: How do I print an integer that is interpreted as hex?

Post by stevewoods1986 »

zaval wrote:
MichaelFarthing wrote: How long will everyone be fooled by this troll? Anyone who casually uses a word like nybble can't possibly be innocently making the sort of posts we see.
this must be a huge compliment for Steve.

Steve is not a troll. Nor he is fooling the forum. He is just a very active noob (BLEEP). :lol: Unfortunately, instead of directing his activity into hard and boring learning to achieve dreams come true, he is torturizing the forum. I guess School-Rea is especially vulnerable for this, since he tries to explain things in very details. And all that goes in vain, since Steve is not inclined to pay attention to advices.

Or maybe this is yet another "(BLEEP)" incarnation, taking another approach for doing bad things?
Racist, huh? Racism. I am not causing any torture here. His name is not School-Rea by the way. I don't want advice. Most advice from the Internet is bullying. I have already learned the hard way, OK? I am an experienced programmer. I haven't just been playing with HTML for 5 minutes.

I haven't done any beginner mistakes, OK?

You have made this all happen. I carry my own weight. I get confused. I've (BLEEP)...ing done nothing wrong. I don't want to upset the community.
Last edited by stevewoods1986 on Thu Aug 17, 2017 1:21 pm, edited 1 time in total.
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: How do I print an integer that is interpreted as hex?

Post by glauxosdever »

Hi,

stevewoods1986 wrote:Everyone just complains.
Sorry. It's you that complained first...

Seriously, Octacone provided a nice way of doing what you want. Why don't you simply try to figure that out?


Regards,
glauxosdever
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do I print an integer that is interpreted as hex?

Post by iansjack »

The sad thing is that I found detailed answers to this question in about 30 seconds using Google. All this sillyness could be avoided simply by learning how to use a search engine.
stevewoods1986
Member
Member
Posts: 80
Joined: Wed Aug 09, 2017 7:37 am

Re: How do I print an integer that is interpreted as hex?

Post by stevewoods1986 »

iansjack wrote:The sad thing is that I found detailed answers to this question in about 30 seconds using Google. All this sillyness could be avoided simply by learning how to use a search engine.
Me too. Stackoverflow has a question that has no complaining at all. I even have an account there :)
https://stackoverflow.com/users/8248254/steve-woods

I have actually helped. Want proof it's mine?

I don't use Stackoverflow for OS development. However, the behaviour (behavior) of members is great. Why can't any of you be like that?

I'll check out the instructions provided, OK?
User avatar
obiwac
Member
Member
Posts: 149
Joined: Fri Jan 27, 2017 12:15 pm
Libera.chat IRC: obiwac
Location: Belgium

Re: How do I print an integer that is interpreted as hex?

Post by obiwac »

stevewoods1986 wrote:Most advice from the Internet is bullying
Then get the (BLEEP) outta here.
stevewoods1986 wrote:Yep, mov is not really code. It's more of an instruction, huh?
I thought you didn't want code? As @neon said "In the previous thread you said you don't want code or sample code".
stevewoods1986 wrote:Listen, I can do OS development
:? Didn't know someone could be more arrogant than me.
stevewoods1986 wrote:I haven't done any beginner mistakes, OK?
About that...
stevewoods1986 wrote:Stackoverflow has a question that has no complaining at all.
We were not even complaining at first. Only after you started bashing us as being unhelpful. And don't say that farthing post was starting the complaining, as this was based on your previous posts and you overall reputation.

All in all, you are arrogant and contradict yourself in 95% of your posts.
I could go on for ages with these quotes, but I do think I have better things to do.
Last edited by obiwac on Thu Aug 17, 2017 1:34 pm, edited 1 time in total.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: How do I print an integer that is interpreted as hex?

Post by BrightLight »

stevewoods1986 wrote:However, the behaviour (behavior) of members is great. Why can't any of you be like that?
In all my experience here, the members are generally very friendly and try to help when possible. Seriously, a bit of advice, and a few hints, and some work for you to figure out on your own. If you're doing OS development, you should be capable of doing much more than that.

Try to focus on the main issue, instead of doing things that'll hurt your reputation later, and reduce people's likeliness to reply to your threads.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
stevewoods1986
Member
Member
Posts: 80
Joined: Wed Aug 09, 2017 7:37 am

Re: How do I print an integer that is interpreted as hex?

Post by stevewoods1986 »

obiwac wrote:
stevewoods1986 wrote:Most advice from the Internet is bullying
Then get the (BLEEP) outta here.
stevewoods1986 wrote:Yep, mov is not really code. It's more of an instruction, huh?
I thought you didn't want code? As @neon said "In the previous thread you said you don't want code or sample code".
stevewoods1986 wrote:Listen, I can do OS development
:? Didn't know someone could be more arrogant than me.
stevewoods1986 wrote:I haven't done any beginner mistakes, OK?
About that...
stevewoods1986 wrote:Stackoverflow has a question that has no complaining at all.
We were not even complaining at first. Only after you started bashing us as being unhelpful. And don't say that farthing post was starting the complaining, as this was based on your previous posts and you overall reputation.

All in all, you are arrogant and contradict yourself in 95% of your posts.
I could go on for ages with these quotes, but I do think I have better things to do.
I don't know what to do. You just keep complaining about other things. You bully me because I don't use someone's code or another programming language. You give me links to stupid Japanese animated videos.

Fine, give me code. Give me code if that helps you. Just give me code. I don't care. Wouldn't that be better?

JAAman, the moderator viewing this forum, can you give me an answer please instead of accusing me of trolling?

How would I just get the first and second nybble? Get the first nybble, put it in register with 0. Then, I just have to compare 0-9.
For example, AL had 0x45. I want to compare the first (4) and second nybble (5), then print it.
dseller
Member
Member
Posts: 84
Joined: Thu Jul 03, 2014 5:18 am
Location: The Netherlands
Contact:

Re: How do I print an integer that is interpreted as hex?

Post by dseller »

stevewoods1986 wrote: I am an experienced programmer.
You must be mad.
stevewoods1986 wrote:I understand about bitwise logic, OK?
stevewoods1986 wrote:How would I just get the first and second nybble?
Last edited by dseller on Thu Aug 17, 2017 1:56 pm, edited 1 time in total.
User avatar
obiwac
Member
Member
Posts: 149
Joined: Fri Jan 27, 2017 12:15 pm
Libera.chat IRC: obiwac
Location: Belgium

Re: How do I print an integer that is interpreted as hex?

Post by obiwac »

stevewoods1986 wrote:
obiwac wrote:
stevewoods1986 wrote:Most advice from the Internet is bullying
Then get the (BLEEP) outta here.
stevewoods1986 wrote:Yep, mov is not really code. It's more of an instruction, huh?
I thought you didn't want code? As @neon said "In the previous thread you said you don't want code or sample code".
stevewoods1986 wrote:Listen, I can do OS development
:? Didn't know someone could be more arrogant than me.
stevewoods1986 wrote:I haven't done any beginner mistakes, OK?
About that...
stevewoods1986 wrote:Stackoverflow has a question that has no complaining at all.
We were not even complaining at first. Only after you started bashing us as being unhelpful. And don't say that farthing post was starting the complaining, as this was based on your previous posts and you overall reputation.

All in all, you are arrogant and contradict yourself in 95% of your posts.
I could go on for ages with these quotes, but I do think I have better things to do.
I don't know what to do. You just keep complaining about other things. You bully me because I don't use someone's code or another programming language. You give me links to stupid Japanese animated videos.

Fine, give me code. Give me code if that helps you. Just give me code. I don't care. Wouldn't that be better?

JAAman, the moderator viewing this forum, can you give me an answer please instead of accusing me of trolling?

How would I just get the first and second nybble? Get the first nybble, put it in register with 0. Then, I just have to compare 0-9.
For example, AL had 0x45. I want to compare the first (4) and second nybble (5), then print it.
Although we are similar, Geri and I are not the same person. You mixing us up.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: How do I print an integer that is interpreted as hex?

Post by Octacone »

stevewoods1986 wrote:I don't know what I want. I need something that is not code, I don't want to use somebody else's code. I don't want anime links with witches. How to do it? Stop fighting... You are all mean to me... Okay give me code, OK? OK? I don't care just give me some code...whatever. I just want to learn it myself...
Okay, here is an example on how to do it. This is not the only way, there are other ways of doing it.
I can't provide you with any useful Assembly code (because I mostly code in C++) but here is a walk-through.
  • Create an array (this will be used as an output object), make it hold 3 characters. 1st being used for the first digit, 2nd being used for the second digit, 3rd being used as a null terminator. (so you don't display any junk) (make sure your print function supports '\0')
  • Create a second array, 16 characters in size. Make it equal "0123456789ABCDEF" (characters used for displaying hexadecimal values)
  • Grab your first array (the output one), make its 0th element equal second_array[(number AND with 0xF0) --->> all shifted 4 bytes to the right];
  • Grab your first array again, make its 1st element equal second_array[AND number with 0x0F];
  • Print that array as a string.
  • Profit!?
If you don't understand what these logical ANDs and shifts do, read my first reply again.
If you can't code this in Assembly, then you don't know Assembly. Take a step back, learn it and come back.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Locked