Skip to main content
Use xxd instead of hexdump on TIO.run
Source Link
user36046
user36046

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!Try it online!

Edit: fixed bash stderr errors on TIO

Edit 2: improved formatting in TIO header and footer code

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

Edit: fixed bash stderr errors on TIO

Edit 2: improved formatting in TIO header and footer code

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

Edit: fixed bash stderr errors on TIO

Edit 2: improved formatting in TIO header and footer code

Improved formatting in TIO footer and header
Source Link
user36046
user36046

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!Try it online!

Edit: fixed bash stderr errors on TIO

Edit 2: improved formatting in TIO header and footer code

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

Edit: fixed bash stderr errors on TIO

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

Edit: fixed bash stderr errors on TIO

Edit 2: improved formatting in TIO header and footer code

Fixed errors on TIO
Source Link
user36046
user36046

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!Try it online!

Edit: fixed bash stderr errors on TIO

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

x86 machine code, 39 bytes

00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6  .9..D.YZ).....D.
00000020: 83f9 fb0f 44c6 c3                        ....D..

Assembly

section .text
	global func
func:					;inputs int32_t ecx and edx
	push 0x1
	pop esi
	push 0x5
	pop edi
	push edx
	push ecx
	xor eax, eax

	;ecx==edx?
	cmp ecx, edx
	cmove eax, esi

	;ecx+edx==5?
	add ecx, edx
	cmp edi, ecx
	cmove eax, esi
	
	;ecx-edx==5?
	pop ecx
	pop edx
	sub ecx, edx
	cmp ecx, 5
	
	;ecx-edx==-5?
	cmove eax, esi
	cmp ecx, -5
	cmove eax, esi

	ret

Try it online!

Edit: fixed bash stderr errors on TIO

Source Link
user36046
user36046
Loading