Jump to content

Home

Programming discussion


ET Warrior

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...