Jump to content



Photo

Programmer logic in everyday life

joke joke

  • Please log in to reply
35 replies to this topic

#31 +Phouchg

Phouchg

    Resident Misanthrope

  • 5,689 posts
  • Joined: 28-March 11
  • Location: Neowin Detainment Camp

Posted 02 December 2012 - 00:26

title groc
.model small
.stack 100h

.data
eggs dw baadh
milk dw f00dh
bag dw d00dh

.code
.486

start:
mov ax, [eggs]
cmp ax, 0
jz noeggs
mov cx, 6
jmp initbuy
noeggs:
mov cx, 2

initbuy:
xor ax, ax
buy:
add ax, 1
mov edx, [milk + ax * 4]
mov [bag + ax * 4], edx
cmp ax, cx
jne buy
endbuy:

mov ax, 4c00h
int 21h
end start


And, before anyone points out, yes. I don't know shhh about x86 assembly (contrary to, for example, the post above), but, arguably, it still looks cool and I had to pretend I'm smart :geek:


#32 Ice_Blue

Ice_Blue

    Neowinian

  • 1,313 posts
  • Joined: 02-February 09
  • Location: The Den Of Zen
  • OS: Windows 8.1 Pro x64
  • Phone: Nokia N8 Belle

Posted 02 December 2012 - 00:32

Yep -- posted back in June:

http://www.neowin.ne...g-a-programmer/

I just had to be a little smart alec :p


Thanks. I kind of figured it, but maybe I didn't search hard enough.

#33 vetCalum

Calum

    Neowinian Senior

  • 13,211 posts
  • Joined: 10-January 07

Posted 02 December 2012 - 00:52

Threads merged

Thanks. I kind of figured it, but maybe I didn't search hard enough.

It's hard to find such a topic when it doesn't have an obvious title (like your one did, which is why I kept this title in the merged thread) :)

#34 Ice_Blue

Ice_Blue

    Neowinian

  • 1,313 posts
  • Joined: 02-February 09
  • Location: The Den Of Zen
  • OS: Windows 8.1 Pro x64
  • Phone: Nokia N8 Belle

Posted 02 December 2012 - 01:22

Threads merged


It's hard to find such a topic when it doesn't have an obvious title (like your one did, which is why I kept this title in the merged thread) :)


Thanks, Calum.

#35 +scumdogmillionaire

scumdogmillionaire

    Neowinian Senior

  • 2,612 posts
  • Joined: 23-October 01
  • Location: Denver, CO
  • OS: Windows 8.1 Pro/Windows 8.1 RT
  • Phone: Nokia Lumia 920

Posted 02 December 2012 - 01:38

:D I like the ternary operator version as well:

int
get_milk()
{
	return ( shop_has_eggs() ) ? 6 : 1;
}


+1 that's how I'd write it :)

#36 Aheer.R.S.

Aheer.R.S.

    I cannot Teach Him, the Boy has no Patience!

  • 11,540 posts
  • Joined: 15-October 10

Posted 02 December 2012 - 15:28

lol