Binary conversion (machine)

new topic     » topic index » view thread      » older message » newer message

Actually I got bored and started optimizing the byte
swap routine the easy way.  Directly.  However for
some reason it just doesnt seem to be working quite
right.

Someone whos boned up on machine to Eu interfacing
want to take a peek at this and see what I did
wrong?

==========
include machine.e

atom mem, SwapBytes
sequence Code_Space

mem = allocate( 4 )
poke4( mem, 90 )

Code_Space =
{
    #50,                        -- push eax
    #B8} & int_to_bytes(mem) &  -- mov eax, offset mem
{   #0F, #C8,                   -- bswap eax
    #A3} & int_to_bytes(mem) &  -- mov offset mem, eax
{   #58,                        -- pop eax
    #C3                         -- ret
}

SwapBytes = allocate( length(Code_Space) )
poke( SwapBytes, Code_Space )

? peek4u( mem )
call( SwapBytes )
? peek4u( mem )
call( SwapBytes )
? peek4u( mem )
call( SwapBytes )
? peek4u( mem )

free( SwapBytes )
free( mem )

-- break for debugging
atom break
==========

Don Phillips

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu