PDA

View Full Version : Programming discussion


ET Warrior
12-02-2004, 05:38 PM
So I'm a little stuck with a program I'm writing for my Computers as Components class. I'm writing in assembly on a Motorola 68k processor, and it's a calculator program, and it does all the math in hex, and to output it i have to convert it to decimal and then into ASCII.

The problem is that it outputs the first digit of the answer I input, but that's it. If the answer is more than one digit I only get the first. And so I conclude the problem lies in my recurse function which converts to decimal and then ASCII and outputs it....

I know there are a few of you on here who are gifted programmers, though I'm not sure if any of you know assembly, and if you do if you know assembly on a 68k...but I'm stuck as hell.

As a note, d1, d2, and d3 are my data registers, sp is my stack pointer, d1 holds the value of the number I am converting, d2 is the radix (which is 10 since i'm converting to decimal) and D3 holds the value of my remainder of my divisions.

_recurse:
link a6,#0
movem.l d1-d3,-(sp)
move.l 8(a6),d1
move.w #$A,d2
ANDI.l #$0000FFFF,d1
divu d2,d1
move.l d1,d3
lsr.l #8,d3
lsr.l #8,d3
ANDI.l #$0000FFFF,d1
tst d1
beq L1
move.l d1,-(sp)
jsr _recurse
addq #4,sp
addi.w #$30,d3
move.b d3,$600003
movem.l (sp)+,d1-d3
unlk a6
rts

If nobody understands and can help me that's cool

Troopr-Undr-Fir
12-02-2004, 06:14 PM
Crap, I know what you're doing as I had a project similar to this my Junior year in my Comp. Science class.

I was more good with C++ and Java than I ever was in assembly.

I remember the project and when I did it... Just can't remember what I did :(.

I know I have an assembly book around here somewhere, not a huge one, but still I think it could help you out.

Let me search for ye.

EDIT: I also think you're missing a line of code there somewhere, because it doesn't add up all the way.

coupes.
12-02-2004, 07:01 PM
OMG ! assembly ! GEEK ! :eek:

I'm sorry I can't help you with this... I'm know some programming language... but I've never done assembly before. :(

ET Warrior
12-02-2004, 08:23 PM
Heh.....it actually works perfectly.

The problem was actually hardware related. The LCD screen that I output to is slower than the code was sending values, so it sent values before the LCD screen was ready to write them.

I wrote a little busy-wait loop that took care of it :)



So now that my program is workin, we can change this thread to a discussion of programming in general. Who here programs, what languages do you know, what projects have you done, etc. etc. :)

Samuel Dravis
12-02-2004, 08:43 PM
Originally posted by ET Warrior
So now that my program is workin, we can change this thread to a discussion of programming in general. Who here programs, what languages do you know, what projects have you done, etc. etc. :) Meh. I know VB, PHP, some ASP, (ECMA script & VBscript). I'm supposed to be learning C/++ but it's not happenin' yet - I can read it and translate it to VB for example, but I can't write the stuff. :p

coupes.
12-02-2004, 10:28 PM
I'm fluent in ASP (JScript :(), Javascript, ActionScript, Lingo and even if they're not really programming languages, I also know HTML(DHTML,XHTML), XML, CSS and SQL... that's about it.

In the near future I intend to lean PHP and ASP with VBscript.

--ZeeMan--
12-02-2004, 10:37 PM
simple html here.....*cowers into corner*

Astrotoy7
12-02-2004, 10:43 PM
this thread should be re-titled.... "how to get hot chicks"

:p

mtfbwya

Troopr-Undr-Fir
12-03-2004, 02:42 PM
Originally posted by Astrotoy7
this thread should be re-titled.... "how to get hot chicks"

:p

mtfbwya

Damn right!!!

Who says you can't get a hot women to love you if know a few programming languages. :tsk:

Not to brag... Aww hell I SHALL BRAG! My girl friend is freakin smokin. Even I can't figure out why she loves me :eek:

I wish I had a picture of her, but she has a tick thingy to where she is embaressed when people look at her in photos. Maybe a phobia? Though I don't know what it would be called. I guess it's fine because I don't really see the need for pictures myself either.

EDIT: heh, forgot the languages:

HTML, XHTML, DHTML, JavaScript, C++, and little knowledge of Assembly.

Though now I can only remember HTML and some of it's variants by heart.

ET Warrior
12-03-2004, 03:30 PM
I tried to learn HTML, but then I got bored, it was too many tags and overall I was very uninterested in it :giveup:

C++ is where it's at for me, I really enjoy writing programs in C++ :)

Astrotoy7
12-03-2004, 03:33 PM
Originally posted by Troopr-Undr-Fir
Not to brag... Aww hell I SHALL BRAG! My girl friend is freakin smokin. Even I can't figure out why she loves me :eek:


I can ...riddle me this batman. she's waitin for you to get a high payin job in the tech industry....pop out a cpl of kids, then ditch ya, take the house and car, the kids + maintenance and half your superannuation...leaving you butt poor and forcing you to move back to your momz... :p dont think it hasnt happenned before :D

either that, or youre hung like a donkey :p (which is how it is in my case :D ;) )

mtfbwya

Samuel Dravis
12-03-2004, 04:18 PM
If you're counting SGML based languages, I know HTML, XHTML, and XML. I love XML. It's just cool. :D

DHTML is just a name for HTML with some type of clientside scripting language (VBscript/Javascript/ECMAscript) used to modify the look of the page.

Edit: CSS too, heh.

Alegis
12-03-2004, 11:16 PM
Only HTML, CSS (as if that's much :p ) and Javascript. I can recognise php but not create it (in other words; edit existing code but not yet create new one, never learned php)

jon_hill987
12-04-2004, 02:13 AM
I've learnt some C and some assembly.

Rogue Nine
12-04-2004, 05:50 AM
Anybody who knows Java wanna write my last proggie for me? Cuz I really don't want to.

Troopr-Undr-Fir
12-04-2004, 08:14 AM
Originally posted by Astrotoy7
I can ...riddle me this batman. she's waitin for you to get a high payin job in the tech industry....pop out a cpl of kids, then ditch ya, take the house and car, the kids + maintenance and half your superannuation...leaving you butt poor and forcing you to move back to your momz... :p dont think it hasnt happenned before :D

either that, or youre hung like a donkey :p (which is how it is in my case :D ;) )

mtfbwya

Heh, yeah I know that happens sometimes.

But I don't want a Tech Carrier. I want to be a fireman, shes knows this. It's amazing to think she stays with me even though I wouldn't see her 3 quarters of the week if I take that path. Though, I am only 22 and still in college. I still only see her half of the time. Who knows... But yeah, I am part donkey :p


Edit: Anybody who knows Java wanna write my last proggie for me? Cuz I really don't want to.

if only you were that lucky :rolleyes: :p

ET Warrior
12-04-2004, 08:43 AM
Originally posted by Rogue Nine
Anybody who knows Java wanna write my last proggie for me? Cuz I really don't want to.

I suppose that depends on if you want to pay me.

And teach me Java first.

:D


What is the program though?

narfblat
12-04-2004, 08:45 AM
I took C++ in high school. I made a tic-tac-toe game, with the computer as the O's. Nobody could beat it.

ET Warrior
12-04-2004, 08:47 AM
I knew a guy last year who programmed a 3 dimensional 4x4 grid of a tic tac toe game. His original AI for the computer was beatable, but then he changed it's priorities and let it plan ahead a few more moves and it became unbeatable.

Rogue Nine
12-04-2004, 08:47 AM
Here, ET.

Teh blah. (http://bingweb.binghamton.edu/~sreksc/Lab7.doc)

ET Warrior
12-04-2004, 08:54 AM
I don't understand the parameters of the assignment...I see you have yourself a nice database of movies and their rankings and whatnot....but what are you supposed to do? And how is the database arranged? Is it a linked list of objects that hold the information on the movie?

Rogue Nine
12-04-2004, 08:56 AM
Remove the Lab7.doc extension, that should take you to the main page with the file for it.

ET Warrior
12-04-2004, 09:00 AM
So you get to design the class that holds the information on all the movies, you will want to fill your classes with the information that you read in from that file, and then you want to implement the functionality where you can look at the specifics of a particular ranked movie, look at all the movies, and look at the top 3 grossing movies? Extra credit if you figure that last part out?

Rogue Nine
12-04-2004, 09:01 AM
Basically, yeah.

ET Warrior
12-04-2004, 09:10 AM
Well that doesn't sound too hard you pansy :xp:

I can't believe you're getting extra credit for that last part...it seems so simple...

I'd make three arrays of size 2. First slot of the array can hold the rank of the movie, second slot holds what it's gross is. (assuming you write your class with the design that you can return that as a value, which would be a simple function to add)

Then step through the database one at a time. every value's gross check against the current top ranked gross. If it's greater, you move whatever you have in second place (second row in the array) down into the third place(third row) and then move what was in 1st into second, and move your new value into 1st. If it was less than the 1st place you test it against the 2nd place. If greater then you move what was in 2nd into third and new one into 2nd. Then if less than what was in 2nd you test it against what was in 3rd, and if it's greater you replace it, if not you move on to the next value in the database.


Seems pretty simple to me :dozey:


<.<


>.>


Does that constitute cheating on your homework if you read that? :xp:

Rogue Nine
12-04-2004, 09:12 AM
See, that's predicated on the knowledge I actually know Java.

:joy:

StarWarsPhreak
12-04-2004, 09:59 AM
I know basic Javascript, and HTML.

I will be starting CS classes next semester...

ET Warrior
12-04-2004, 10:40 AM
Originally posted by Rogue Nine
See, that's predicated on the knowledge I actually know Java.


Well.......yeah :p


If you were working in C++ I would be a lot more help, as I've not learned Java yet ;)

Mex
12-04-2004, 10:53 AM
I don't know any languages. *Gets booed out*

ET Warrior
12-04-2004, 11:06 AM
The real question here is, does my description of how to pull of the top three grossing films button sound reasonable and correct? Because I would assume after a semester of this course you would know enough Java to be able to handle three simple arrays in a loop :p

tk102
12-04-2004, 03:33 PM
Bah to Java.
Perl solution:open $movie_database, "<", "movie.dat";

while (<$movie_database>) {
next unless /\$(\d+)\s+\$(\d+)/;
$this_gross=$1+$2;
$this_movie=unpack('A*',substr($_,8,40));
if ($this_gross>$top3_gross) {
if ($this_gross>$top2_gross) {
if ($this_gross>$top1_gross) {
$top3_movie=$top2_movie;
$top3_gross=$top2_gross;
$top2_movie=$top1_movie;
$top2_gross=$top1_gross;
$top1_movie=$this_movie;
$top1_gross=$this_gross;
}
else {
$top3_movie=$top2_movie;
$top3_gross=$top2_gross;
$top2_movie=$this_movie;
$top2_gross=$this_gross;
}
}
else {
$top3_movie=$this_movie;
$top3_gross=$this_gross;
}
}
}
close $movie_database;
printf "Top 3 Movies:\n%s \$%d\n%s \$%d\n%s \$%d",
$top1_movie, $top1_gross,
$top2_movie, $top2_gross,
$top3_movie, $top3_gross;

TK-8252
12-04-2004, 03:41 PM
There is a [ code ] tag, 102. :p


cls
if thread$ = "geeky" then
print "This is the geekiest thread... EVAR."
end if


This is the geekiest thread... EVAR.



Gimme a break, all I know is QBasic. :xp:

tk102
12-04-2004, 07:45 PM
the code tag doesn't work well with the spoiler tag.



Test

Oh.. this works...
test
:) Fixed.