#x86 machine code, 39 bytes
x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly (NASM syntax):
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
#x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly (NASM syntax):
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly (NASM syntax):
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
#x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly (NASM syntax):
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
#x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly:
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
#x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly (NASM syntax):
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '
#x86 machine code, 39 bytes
00000000: 9150 6800 0000 00e8 fcff ffff 5958 a901 .Ph.........YX..
00000010: 0000 0074 04d1 e8eb 066a 035a f7e2 4009 ...t.....j.Z..@.
00000020: c075 dec3 2564 20 .u..%d
Assembly:
section .text
global func
extern printf
func: ;the function uses fastcall conventions
xchg eax, ecx ;load function arg into eax
loop:
push eax
push fmt
call printf ;print eax
pop ecx
pop eax
test eax, 1 ;if even zf=1
jz even ;if eax is even jmp to even
odd: ;eax=eax/2
shr eax, 1
jmp skip
even: ;eax=eax*3+1
push 3
pop edx
mul edx
inc eax
skip:
or eax, eax
jne loop ;if eax!=0, keep looping
ret ;return eax
section .data
fmt db '%d '