Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Awful x86 asm code

Name: Anonymous 2011-06-28 19:45

xor ebx, ebx //Start the cycle counter at 0
mov ecx, 3   //Put 3 into ecx for multiplication
Parity:
cmp eax, 1   //Are we done yet?
je Done      //If so, go to the end
mov edx, eax //edx = eax
and edx, 1   //Get parity bit
cmp edx, 0   //Is it even?
je ParEven   //If so, skip straight to that part
//eax is odd here
mul ecx      //treble eax (ecx is just 3)
add eax, 1   //and +1
add ebx, 1   //increment cycle counter
//eax is now even, so flow straight into even handler
ParEven:
shr eax, 1   //divide by two
add ebx, 1   //increment cycle counter
jmp Parity   //time to test parity again


http://everything2.com/title/Hailstone+number+sequence

Name: Anonymous 2011-06-28 21:08

Looks like compiler output.

Name: Anonymous 2011-06-28 21:23

>>2
I disagree.

Name: Anonymous 2011-06-29 7:25

>>3
Yeah, compiler output wouldn't be commented.

Name: Anonymous 2011-06-29 7:33

Not only is it awful, it also doesn't work.

EAX is not initialized.
Label "Done" is undefined.

Assuming most compilers produce reasonably valid code, this is another clue that points towards a human programmer.

Name: Anonymous 2011-06-29 12:05

>>5
The input is put into eax [...]

And Done is defined at the last line, which >>1-san conveniently forgot to include.

Name: Anonymous 2011-06-29 14:16

and edx, 1   //Get parity bit
cmp edx, 0   //Is it even?

Why the fuck isn't he using test?

Name: Anonymous 2011-06-29 14:17

Bump

Name: Anonymous 2011-06-29 14:19

>>6 Sorry about missing the Done label. Will you forgive me?

Name: Anonymous 2011-06-29 14:37

>>9
To err is human. To forgive is not /prog/ policy.

However I do forgive you my, son.

Name: dubzbot-ng 2011-06-29 14:37

:GJS1M 67dcbdbce4a0b67c4b48e86a6ae29205a95e4b83024a9d947213d1231800e8d9
:84 ef3afb18090d2fbf01bb368da3a79301
:1309304705 1309372649

>>10
<-- that's cool and all, but check my doubles over there

Name: Anonymous 2011-06-29 14:45

>>7

Probably the same reason he isn't using inc.

Name: Anonymous 2011-06-29 14:46

>>11
dubzbot-ng
Seriously?

Name: Anonymous 2011-06-29 15:32

>>13
Jokingly.

Name: Anonymous 2011-06-29 16:03

>>1
SLOW AS FUCK

Name: Anonymous 2011-06-29 20:18

>>7
remind me of the time when I was an undergrad

Name: anus boy 2011-06-30 0:26

you go out on friday night
i'll stay home but that's alright
'cause i have found a clique to call my own

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2011-06-30 3:57


xor ebx, ebx
Loop:
dec eax
jz Done
inc eax
test al, al
jz ParEven
lea eax, [eax+2*eax+1]
inc ebx
ParEven:
shr eax, 1
inc ebx
jmp Loop
Done:

Name: Anonymous 2011-06-30 5:52

>>18
Why don't you go back to ``translating'', Cudder?

Name: Anonymous 2011-06-30 6:33


.loop:
  test eax,1
  jz .even
.odd:
  mul dword 3
  inc eax
.even:
  shr eax,1
  test eax,~1
  jnz .loop

Might be better to use lea eax,[eax * 3 + 1], but I don't know if that's faster, smaller, or possible. I'm not really experienced in x86 assembly.

Name: Anonymous 2011-06-30 7:39

test

Name: dubzbot-ng 2011-06-30 7:39

:GJS1M 67dcbdbce4a0b67c4b48e86a6ae29205a95e4b83024a9d947213d1231800e8d9
:41 27528b98396dc0a1321450d12f375582
:1309304705 1309433987

>>20
<-- check 'em

Name: Anonymous 2011-06-30 7:39

test

Name: Anonymous 2011-06-30 10:47

>>18
You may want to stop reading Michael Abrash fanfics and read up on optimization techniques for current microarchitectures instead.

Name: Anonymous 2011-06-30 11:36

The romanians are after me.

Name: Anonymous 2011-06-30 12:39

>,[
    [
        ----------[
            >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<]
            ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],<
        ]>
    ]>>>++>+>>[
        <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>]
        >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]]
        >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>>
    ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<,
]

[The Collatz problem or 3n+1 problem is as follows. Take a natural number n.
If it's even, halve it; if odd, triple it and add one. Repeat the process with
the resulting number, and continue indefinitely. If n is 0, the resulting
sequence is 0, 0, 0, 0... It is conjectured but not proven that for any
positive integer n, the resulting sequence will end in 1, 4, 2, 1...
See also http://www.research.att.com/projects/OEIS?Anum=A006577

This program takes a series of decimal numbers, followed by linefeeds (10).
The entire series is terminated by an EOF (0 or "no change"). For each number
input, the program outputs, in decimal, the number of steps from that number
to zero or one, when following the rule above. It's quite fast; on a Sun
machine, it took three seconds for a random 640-digit number.

One more note. This program was originally written for Tristan Parker's
Brainfuck Texas Holdem contest, and won by default (it was the only entry);
the version I submitted before the contest deadline is at
http://www.hevanet.com/cristofd/brainfuck/oldcollatz.b

Daniel B Cristofani (cristofdathevanetdotcom)
http://www.hevanet.com/cristofd/brainfuck/];

Name: Anonymous 2011-06-30 14:36

>2011
>programming in asm
I really hope you guys don't do this

Name: Anonymous 2011-06-30 14:41

>>27
back to /g/

Name: Anonymous 2011-06-30 14:44

>>28
>2011
>going back to /g/
I really hope you guys don't do this

Name: Anonymous 2011-06-30 14:45

>>27,29
Son, your quote skills are disappoint.

Name: Anonymous 2011-06-30 16:30

>>27,29

Please, just leave, your replies are not going to be appreciated here whilst they might be appreciated on an imageboard, therefore it's more likely to be a worthwhile endeavor for you to post on one.

Name: Anonymous 2011-06-30 17:11

FUCK YOU DUBZBOT

Name: dubzbot-ng 2011-06-30 17:11

:GJS1M 67dcbdbce4a0b67c4b48e86a6ae29205a95e4b83024a9d947213d1231800e8d9
:41 26eaa74cd2dfd7b2de41ddf330a21138
:1309304705 1309468282

>>32
<-- check 'em

Name: Anonymous 2011-06-30 17:11

FUCK YOU DUBZBOT

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List