Jump to content
  • Advertisement
Sign in to follow this  
kev670

assembly program help

This topic is 4217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to design an assembly program that does 3 things. first a user created array is input. then the values are put into a new array which lines them up smallest number first. (this is where I'm stuck. after this they are put into a third array where the numbers are reversed, so biggest numbers come first then a smaller then number and then the smallest. finally the factorial is calculated and put into a 4th array. any help you could give me would be much appreciated. I'm using wism68 as a simulator for the 68000 processor. i know that this may be the wrong forum to ask so if someone could point me in the direction of a better place that would be great to
PROGRAM	EQU $6000
DATA	EQU $4000

		ORG PROGRAM

		LEA ASCSORT,A1		;GET START ADDRESS OF ARRAY
		LEA DESCSORT,A2		;GET START ADDRESS OF ARRAY
		LEA FACTS,A3		;GET START ADDRESS OF ARRAY

		NOP			;N O P = COMMENT OUTERWHILE LOOP STARTS HERE => USE CMP, SOME FORM OF BRA AND COUNTER
		LEA INPUT,A0		;GET START ADDRESS OF ARRAY


		NOP			;INNER WHILE LOOP

W2		MOVE #0,D1		;INTIALISE D1 TO TERMINATING VALUE
		MOVE.B (A0),D0		;ASSUME THE FIRST ELEMENT IS SMALLEST

W1		CMP.B #8,D1		;COMPARE ELEMENT (A0) TO D1
		BEQ EXIT		;BRANCH TO EXIT IF EQUAL
		ADD #1,D1		;INCREMENT LOOP COUNTER

		CMP.B #$F,(A0)		;CHECK IF ARRAY ELEMENT = PREVIOUSLY FOUND ELEMENT
		BEQ NEXT		;IF IT IS, PROGRESS TO NEXT ELEMENT

		CMP.B (A0),D0		;IF NOT COMPARE WITH CURRENT SMALLEST
		BLT NEXT		;IF NOT LESS THAN THEN BRACH TO NEXT

		MOVE.B (A0),D0		;OTHERWISE MOVE NEW SMALLER VALUE TO D0
		MOVEA A0,A5		;USE A5 TO TEMPORARILY HOLD ADDRESS OF MIN VALUE

NEXT	ADDA #1,A0
		BRA W1			;GO BACK TO START OF WHILE LOOP

EXIT:	MOVE.B D0,(A1)
		MOVE.B #$F,(A5)		;OVERWRITE LOCATION WHERE MIN VALUE FOUND USING $F AS A MASK


		NOP			;END OF OUTER WHILE LOOP
		
		JMP W2

		STOP #$2700


	ORG DATA
INPUT 	DC.B 4,3,2,5,1,6,3,8
ASCSORT	DS.B 8
DESCSORT DS.B 8
FACTS	DS.L 8

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!