Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



Programmer logic in everyday life


35 replies to this topic - - - - -

#31 +Phouchg

    Blackheart

  • 3,775 posts
  • Joined: 28-March 11
  • Location: Krikkit
  • OS: GrumpyOS 6.1.7601 x64

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

    Resident Elite

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

Posted 02 December 2012 - 00:32

View PostHum, on 02 December 2012 - 00:18, said:

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

    Neowinian ULTRAKILL

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

Posted 02 December 2012 - 00:52

Threads merged

View PostIce_Blue, on 02 December 2012 - 00:32, said:

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

    Resident Elite

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

Posted 02 December 2012 - 01:22

View PostCalum, on 02 December 2012 - 00:52, said:

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

    Neowinian Senior

  • 2,272 posts
  • Joined: 23-October 01
  • Location: Denver, CO
  • OS: Windows 8 Pro
  • Phone: Nokia Lumia 920

Posted 02 December 2012 - 01:38

View Postsimplezz, on 05 June 2012 - 17:18, said:

: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 Dushmany

    I cannot Teach Him, the Boy has no Patience!

  • 2,578 posts
  • Joined: 15-October 10
  • Location: United Kingdom
  • OS: Windows 7 X64 Ultimate Edition
  • Phone: Samsung Galaxy S3 i9300 (4.1.2) Stock

Posted 02 December 2012 - 15:28

lol