Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 11th, 2005, 8:23 PM   #1
browning_man9
Newbie
 
Join Date: Sep 2005
Posts: 5
Rep Power: 0 browning_man9 is on a distinguished road
A little help please

Hey I am new to this forum and very new to this forum. I am currently taking a computer science introductory course and I am having a little bit of trouble. We are using all the basic commands of assembly (I think) like mov, inp, cpy, div a, mul a, add a, brz (branch if zero) a, brp a (branch if positive), jmp (jump), etc. I am trying to write a program that prints the ulam sequence....if that inputted number is even divide it by two...if its odd, multiply by three and add one....I am finding it very difficult to figure out how to test if the number is odd or even using these few commands, and using only 32 bytes. This is the only part I am stuck on....Could you please show me how to test if its even or odd using only the simple commands? Thank you very much for your time!
browning_man9 is offline   Reply With Quote
Old Sep 12th, 2005, 3:25 PM   #2
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
;number to check in eax
and eax, 1
jz label ; even
;else odd
label:
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Sep 12th, 2005, 4:06 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
@lostcauz: Don't be comin' roun' giving simple answers when a complex one can be devised. We've talked about this....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 13th, 2005, 9:08 AM   #4
CodeJunkie
Programmer
 
Join Date: Aug 2005
Location: England
Posts: 37
Rep Power: 0 CodeJunkie is on a distinguished road
To be honest DaWei, Why not ? (I dont mean give the answer, that does`nt help anyone) but dangling incoherant fragments of information over somebody who is just trying to learn, is one of the reasons i dont post on this forum anymore!

I thought the purpose of a forum was to help people and share the knowledge, not make yourself feel omnipotent!
CodeJunkie is offline   Reply With Quote
Old Sep 13th, 2005, 10:26 AM   #5
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
I reckon it is completely wasted on some people!
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Sep 13th, 2005, 12:38 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Good lord, CodeJunkie! Lostcauz is a friend of mine; I'm yanking his chain! He will recognize that, even if you don't. Perhaps if you weren't looking for nonexistent issues to hype, the forum wouldn't seem so intolerable to you!
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 13th, 2005, 1:24 PM   #7
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
lolz @ n00bs

We all love each other, and whatnot.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Sep 13th, 2005, 2:49 PM   #8
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
DaWei, I've slept since our last talk and as you know each day begins a new slate for me. Maybe brain damage or short-term memory loss. Hope I'm not in twubble...

I almost gave the OP a link to this but I figured that would be 'overhelpin'.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Sep 13th, 2005, 2:59 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
LOL, your solution was just so elegant I had to make a crack. I mean, one could arrange to do some shifts and work the carry flag in there, all sorts of high-powered looking stuff. I rarely mention elegance, but I keep my feelings about it in my signature. It sometimes lives automatically in the best solutions.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC