|help me to how to check the result on memory
|Page 1 of 1|
|Author:||charlie2 [ Mon Aug 16, 2010 5:05 pm ]|
|Post subject:||help me to how to check the result on memory|
N EQU 5 TOTAL 5 NUMBERS
CLR.B D4 set D0 as largest
MOVE.W #N-1,D1 USE D1 AS COUNTER AND PRESET IT TO N-1
LEA list,A0 USE A0 as a pointer to the list
next MOVE.B (A0)+,D2 read a number
CMP.B D4,D2 is new number >largest?
BPL last if it isn't go and check for end of loop
MOVE.B D2,D4 It is, record the largset no
Last DBRA D1,next repeat until counter 0
List DC.B 1,2,8,5,3
above is the program to find the the largest no. but i don't know how to check the result on memory. Please help to locate the result on memory.
or is there any other instruction i need to add.
|Author:||profkelly [ Mon Aug 16, 2010 10:02 pm ]|
The program is correct except for the BPL last instruction, it should be BLE last. I always tell my students to read the CMP instruction backwards in order for the branch instruction to read correctly. In this case we are comparing D2 to D4 and branching when it is less than or equal.
BTW, Good comments.
When the program completes the largest value is contained in register D4 which is visible in Sim68K.
|Author:||charlie2 [ Tue Aug 17, 2010 2:44 am ]|
Thank you sir. it helped me a lot.
|Page 1 of 1||All times are UTC|
|Powered by phpBB® Forum Software © phpBB Group