Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   A little help please (http://www.programmingforums.org/showthread.php?t=5866)

browning_man9 Sep 11th, 2005 8:23 PM

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!

lostcauz Sep 12th, 2005 3:25 PM

;number to check in eax
and eax, 1
jz label ; even
;else odd
label:

DaWei Sep 12th, 2005 4:06 PM

@lostcauz: Don't be comin' roun' giving simple answers when a complex one can be devised. We've talked about this....

CodeJunkie Sep 13th, 2005 9:08 AM

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!

stevengs Sep 13th, 2005 10:26 AM

I reckon it is completely wasted on some people! ;)

DaWei Sep 13th, 2005 12:38 PM

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!

iignotus Sep 13th, 2005 1:24 PM

lolz @ n00bs :D

We all love each other, and whatnot.

lostcauz Sep 13th, 2005 2:49 PM

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... :D

I almost gave the OP a link to this but I figured that would be 'overhelpin'. :)

DaWei Sep 13th, 2005 2:59 PM

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.


All times are GMT -5. The time now is 3:47 AM.

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