binary to octal source code using nasm

  • Follow


can anyone help me...i have a a class project...we are required to
make a program that will convert binary input into its octal
equivalent...help

0
Reply static123ph 5/3/2004 5:06:14 PM

"iceman" <static123ph@yahoo.com> wrote in message
news:62011d8f.0405030313.11f050c7@posting.google.com...
> can anyone help me...i have a a class project...we are required to
> make a program that will convert binary input into its octal
> equivalent...help
>

simplest way... make a table... (it's also the fastest method that i know
of)

hard way.... bits 6 and 7 make the (8^2) digit... bits 3, 4, 5 the (8^1)
digit... bits 0, 1, 2 (8^0) the third digit...

i say (8^2) & (8^1) because it wouldn't exactly be proper to say hundreds &
tens, as that's truthfully decimal talk... (10^2)=100  &  (10^1)=10

anyways.. here ya go.. if i lost ya somewhere in there... the source code
should be a snap for ya now...

x7x6  x5x4x3  x2x1x0 = y2y1y0

(by the way, if you're wondering what to do with that first group of bits
since there's only two bits there instead of three... imagine there being a
x8, and that bit has a value of 0...)

0
Reply Bx 5/3/2004 7:10:29 PM


static123ph@yahoo.com (iceman) wrote in message news:<62011d8f.0405030313.11f050c7@posting.google.com>...
> can anyone help me...i have a a class project...we are required to
> make a program that will convert binary input into its octal
> equivalent...help


DYOH

0
Reply PlasmaDragon 5/3/2004 10:52:58 PM

"Bx.C" <invalid-email-address@invalid.shiragajin> wrote in message news:<jFwlc.64779$oN1.38589@bignews5.bellsouth.net>...
> "iceman" <static123ph@yahoo.com> wrote in message
> news:62011d8f.0405030313.11f050c7@posting.google.com...
> > can anyone help me...i have a a class project...we are required to
> > make a program that will convert binary input into its octal
> > equivalent...help
> >
> 
> simplest way... make a table... (it's also the fastest method that i know
> of)
> 
> hard way.... bits 6 and 7 make the (8^2) digit... bits 3, 4, 5 the (8^1)
> digit... bits 0, 1, 2 (8^0) the third digit...
> 
> i say (8^2) & (8^1) because it wouldn't exactly be proper to say hundreds &
> tens, as that's truthfully decimal talk... (10^2)=100  &  (10^1)=10
> 
> anyways.. here ya go.. if i lost ya somewhere in there... the source code
> should be a snap for ya now...
> 
> x7x6  x5x4x3  x2x1x0 = y2y1y0
> 
> (by the way, if you're wondering what to do with that first group of bits
> since there's only two bits there instead of three... imagine there being a
> x8, and that bit has a value of 0...)

but how would you convert a binary having 8 bits

0
Reply static123ph 5/4/2004 8:24:59 AM

"iceman" <static123ph@yahoo.com> wrote in message
news:62011d8f.0405032248.4aac3fd6@posting.google.com...
> "Bx.C" <invalid-email-address@invalid.shiragajin> wrote in message
news:<jFwlc.64779$oN1.38589@bignews5.bellsouth.net>...
> > "iceman" <static123ph@yahoo.com> wrote in message
> > news:62011d8f.0405030313.11f050c7@posting.google.com...
> > > can anyone help me...i have a a class project...we are required to
> > > make a program that will convert binary input into its octal
> > > equivalent...help
> > >
> >
> > simplest way... make a table... (it's also the fastest method that i
know
> > of)
> >
> > hard way.... bits 6 and 7 make the (8^2) digit... bits 3, 4, 5 the (8^1)
> > digit... bits 0, 1, 2 (8^0) the third digit...
> >
> > i say (8^2) & (8^1) because it wouldn't exactly be proper to say
hundreds &
> > tens, as that's truthfully decimal talk... (10^2)=100  &  (10^1)=10
> >
> > anyways.. here ya go.. if i lost ya somewhere in there... the source
code
> > should be a snap for ya now...
> >
> > x7x6  x5x4x3  x2x1x0 = y2y1y0
> >
> > (by the way, if you're wondering what to do with that first group of
bits
> > since there's only two bits there instead of three... imagine there
being a
> > x8, and that bit has a value of 0...)
>
> but how would you convert a binary having 8 bits
>

i just said.... assume there exists a 9th bit (bit#8) with value of 0, and
take groups of 3

bit8,bit7,bit6= first digit    (bit 8 is your 9th bit.. thus it's value is
0)
bit5,bit4,bit3= second digit
bit2,bit1,bit0= third digit

your values will range from 000 to 377 if you're considering the byte as
unsigned

need more help? keep asking questions... i'll be glad to answer...

however, realize that this group doesn't write code for school work... so,
i'm not going to make it that easy... (but if ever do,... know this... the
code will use so many tricks in it, that you wouldn't be able to explain to
the instructor how it does what it does... and i rarely comment my code...
(yes, i know.. poor programming practices...))

0
Reply Bx 5/4/2004 1:37:31 PM

people how do you create a program that converts binary numbers into octal numbers using matlab.


0
Reply user6666 (2) 4/18/2011 8:29:42 AM

people how do you create a program that converts binary numbers into octal numbers using matlab.
0
Reply siposetu 4/18/2011 8:29:46 AM

siposetu wrote:
> people how do you create a program that converts binary numbers into octal numbers using matlab.

Ummm... using MATLAB or using Nasm? I understand that MATLAB is a 
commercial program - probably got a nice Manual, eh? From what little 
I've found online, I get the impression that "oct" will do what you want 
- no idea what the syntax might be...

I also get the impression that MATLAB can call a free-standing "C or 
C++" executable. We should be able to write the executable in Nasm 
instead of "C or C++" - MATLAB would never know. What's the interface, 
though? Number to convert on the command line and output to STDOUT? Or 
what? (I/O to/from "MAT-file format" files?)

I also get the impression that MATLAB can use a function from a shared 
library - .dll or .so (which?). We should be able to write such a 
function in Nasm and make it into a .dll or .so. I suppose the interface 
is "standard"(?) in this case(?).

The "oct" function is apparently part of your "fixed-point toolkit". 
MATLAB also seems to use "doubles" - specifically a matrix of 
doubles(?). I don't imagine you need to represent any fractional parts 
as octal (do ya?). Further, MATLAB strings appear to be "wide" - two 
bytes per character. That can be arranged, but failing to take it into 
account (if true) would probably give wrong results...

I don't think I have an example at hand of displaying a number as octal 
(not often used these days)... maybe an old dos example... but I'm sure 
we can cook one up...

Tell us more about exactly what you're trying to do, and how much you 
know about interfacing with MATLAB. What OS? 32-bit or 64-bit? Maybe we 
can help more with more information. Meanwhile, I'll try to come up with 
a rudimentary example - in Nasm - of displaying a number as octal...

Best,
Frank
0
Reply fbkotler9831 (124) 4/18/2011 3:53:01 PM

"siposetu" asked:
> people how do you create a program that converts binary numbers into
> octal numbers using matlab.

I don't know mathlab at all, even I think to have heard about it
to be a G-styled tool with drag and drop menus for C-functions.
And me think a 'math-lab' should have 'bool/hex/oct/dec/float/...'
as predefined functions anyway.

But because you ask this question in an ASM-group, I assume that
it might have opportunities for InLineAssembler as well.

Every x86-disassembler (caused by the mainly octal based opcodes)
will have such a 'split' function to determine mod.ttt.r/m from
opcode bytes ie:
just a hint, if I'd ever need Octals it would look a bit smarter :)

SPLIT:
 mov dl,[source]  ;get one byte
 mov al,dl        ;make two more copies
 mov ah,dl
 shr dl,6         ;dl holds now origin bits 7,6 in bits 1,0
                  ;and bits 2..7 are zeroed on the fly here.
 shr ah,3         ;ah will become origin bits 5,4,3 as value,
 and ax,0707h     ;and al show only the low three bits 2,1,0
; DONE
; or ax,3030h     ;to make it printable numbers if desired
; or dl,30h       ;print order then will be DL,AH,AL

this method can be expanded for larger source quants ie:

MOV edx,[source] ;get 32 bits at once
MOV edi,[buffer] ;must be reserved ahead of this
MOV ecx,10       ;32 bit mean 11 octal characters (count implies 0 yet)
L1:
 mov al,dl
 and al,7         ;get the lowest three bits (AKA Octal) first
 or al,30         ;if the buffer shall aleady show ASCII
 mov [edi+ecx],al ;store lowest octal at the end
 shr edx,3        ;preare for next three bits
 dec ecx          ;next character
 jns L1           ;loop until Sign yet, because we want Zero too.
; DONE            ;the buffer is filled with 11 Octal characters
                  ;with MSD first (still pointed to by EDI).

HTH.
__
wolfgang


0
Reply nowhere583 (184) 4/19/2011 5:14:54 PM

Il 18.04.2011 10:29, siposetu ha scritto:
> people how do you create a program that converts binary numbers into octal numbers using matlab.
>
Hi All,
is there an opensource alternative to matlab ?

Cheers,

-- 

  .:hopcode[marc:rainer:kranz]:.
  x64 Assembly Lab
  http://sites.google.com/site/x64lab
0
Reply hopcode (31) 4/20/2011 9:02:08 AM

On 20.04.2011 11:02, hopcode wrote:
> Hi All,
> is there an opensource alternative to matlab ?
> 
> Cheers,
> 

Yes, there is. It's called GNU octave.

HTH,
Markus
0
Reply nullplan (53) 4/20/2011 2:35:32 PM

10 Replies
402 Views

(page loaded in 4.17 seconds)

Similiar Articles:













7/25/2012 2:11:42 AM


Reply: