flat assembler
Message board for the users of flat assembler.
Index
> Main > Printing binary in asm |
Author |
|
DimonSoft 27 Feb 2018, 07:03
moveax41h wrote: I know in C that you have to do a workaround using a switch-case because there's not a "binary format specifier." Is there a simple way to do this in asm? Thank you. The question has nothing to do with C vs asm differences. You’re using a C function printf, so what would you expect? Either the function has such capability or you have to implement the feature yourself. Just like in any other programming language. Seems like this time you’re unlucky and have to write it yourself. |
|||
27 Feb 2018, 07:03 |
|
revolution 27 Feb 2018, 07:12
moveax41h wrote: ... printing binary straight to the console... Each of these three would require different code to accomplish. Do you already know how to convert a value into a string of 0's and 1's? I'm sure we can help if this is something you are not sure about. |
|||
27 Feb 2018, 07:12 |
|
yeohhs 27 Feb 2018, 08:39
moveax41h wrote:
There is an interesting discussion about this here. https://stackoverflow.com/questions/40811218/creating-an-x86-assembler-program-that-converts-an-integer-to-a-16-bit-binary-st |
|||
27 Feb 2018, 08:39 |
|
moveax41h 28 Feb 2018, 01:31
yeohhs thanks for the link, that's helpful.
revolution, that was a good question. I think I'm going to stick to msvcrt funcs for now. I think programming the hardware myself would be cool too but I have no knowledge of how to go about that other than by using 8086emu and interrupts. I don't think I can do that on a current Windows machine anymore right? |
|||
28 Feb 2018, 01:31 |
|
revolution 28 Feb 2018, 10:39
So if you use the MSVCRT DLL functions then one way to do what you want is to convert the value to a string of 0s/1s, and then you can use printf to output the string with %s.
|
|||
28 Feb 2018, 10:39 |
|
rugxulo 28 Feb 2018, 21:38
There's only 16 total hex nibbles anyways. So just use a small lookup table. Honestly, hex is very easy to convert to binary (1:1), so you can do it in your head fairly easily. Decimal 8 is bit 3 is 1000, decimal 15 (0xF) of all four bits (8+4+2+1) is 1111, decimal 10 (0xA, 8+2) is 1010.
|
|||
28 Feb 2018, 21:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.