View Single Post
Old Jan 24th, 2007, 1:17 PM   #1
n00b
Programmer
 
Join Date: Sep 2005
Posts: 69
Rep Power: 3 n00b is on a distinguished road
Send a message via MSN to n00b
assembly questions

this is one of the first code examples i've used to take a peek into assembly programming. this one i can't quite figure out. basically, i have made a X.txt file that has coordinates of points that make a star. the program asks user to input the name of the file where the coordinates are located, it draws the star using different colors, and it computes the sum of all xxxx and yyyy coordinates. there are plenty of values in hex form that don't make sense to me, i can't figure out why they're THERE that is. also, i can't figure out what is the function of each of those labels. i understand every line of code, what it does to be exact, but my brain can't compile it as a whole. i've marked the parts i don't understand (not all of it though) in red, bold font. so if you have the nerves, please hit me up with some info. thank you all for your time


START	ORG	$1000  

	MOVE.L #23,D1
	LEA text1,A1  *get adress of tekst1, store in A1
	MOVE #1,D0  *print the text from (A1), without CR, LF. 
	TRAP #15  *activates I/O

	MOVE.L #$2000,A1
	MOVE #2,D0  *input char via keyboard
	TRAP #15

	MOVE #51,D0  *open existing file
	TRAP #15
	
	MOVE.L #$2300,A0	
	MOVE.L #$2010,A1
	MOVE.L #$500,D2
	MOVE #53,D0  *set number of chars for "reading"
	TRAP #15
	
	MOVE.L #$208E, A2
	MOVE.L #$200E, A1
	MOVE.L #$201E, A3
	MOVE.L #$2100, A5
	MOVE.L #$2110, A6

Y1	MOVE.L #$00000000,D7
	JMP X2	

X1	MOVE.L #$00000000,D7
	ADD #$2,A1
	ADD #$2,A2
	MOVE.B (A1),D7
	CMP #$2E,D7
	SUB #$30,D7
	MULU #100,D7
	ADD #$1,A1
	MOVE.B (A1),D6
	SUB #$30,D6
	MULU #10,D6
	ADD #$1,A1
	MOVE.B (A1),D5
	SUB #$30,D5
	ADD D5,D6
	ADD D6,D7
	MOVE.W D7,(A2)
	JMP K2
K1	MOVE.L #$00000000,A4
	ADD D7,(A0)
	SUB #$8,A0
	SUB #$8,A0
	JMP K3
K2	CMP #$00000000,A4
	BNE K1
	ADD D7,(A0)
	MOVE.L #$00000001,A4
	ADD #$10,A0
K3	MOVE.B D5,D0
	
X2	CMP A3,A1
	BNE X1
	

	MOVE.L A1,A7
	ADD #$2,A7
	MOVE.B (A7),D1
	
	
	JMP X3
X4	MOVE.L #$0000FF00,D1
	JMP X5
X3	CMP #$31,D1
	BEQ X4	
	JMP X6
X7	MOVE.L #$000000FF,D1
	JMP X5
X6	CMP #$32,D1
	BEQ X7		
	JMP X8
X9	MOVE.L #$00FF0000,D1
	JMP X5
X8	CMP #$33,D1
	BEQ X9	
	JMP X10
X11	MOVE.L #$00FF00FF,D1
	JMP X5
X10	CMP #$34,D1
	BEQ X11	



X5	MOVE #80,D0
	TRAP #15
	
	MOVE.L #$2090,A2
	MOVE.W (A5),D1
	CMP #$0,D1
	BNE J1
	
	MOVE.W (A2),D1
	ADD #$2,A2
	MOVE.W (A2),D2
	ADD #$2,A2
J1	MOVE.W (A2),D3
	ADD #$2,A2
	MOVE.W (A2),D4
	
	MOVE.W (A5),D5
	JMP J3
J2	MOVE.W (A6),D1
	JMP J4
J3	CMP #$0,D5
	BNE J2
	

J4	MOVE #84,D0
	TRAP #15
	
	MOVE.L #$00000000,D1
	MOVE.L D3,D1
	MOVE.L D4,D2
	MOVE.W D1,(A6)
	
	ADD #$2, A1
	ADD #$A, A3
	MOVE.L #$208E, A2
	ADD #$1,(A5)
	CMP #$A, (A5)
	BNE Y1
	
	move.l #$00000016,d1
	move.l #11,d0
	trap #15
	
	MOVE.L #$17,D1
	LEA text2,A1
	MOVE.L #1,D0
	TRAP #15
	
	move.l #$00000000,d1
	move.w (a0),d1
	move #3,d0
	trap #15

	move.l #$00000017,d1
	move.l #11,d0
	trap #15

	MOVE.L #$17,D1
	LEA text3,A1
	MOVE.L #1,D0
	TRAP #15
	
	add #$10,a0
	move.l #$00000000,d1
	move.w (a0),d1
	move #3,d0
	trap #15




	MOVE.B	#9,D0
	TRAP	#15		Halt Simulator
text1	DC.B 'File input: ',$D,$A,0
text2 	DC.B 'Sum of x coordinates: ',$D,$A,0
text3	DC.B 'Sum of y coordinates: ',$D,$A,0
	END	START
n00b is offline   Reply With Quote