LAB2 - BRNZP AFTERSWAP AFTERSWAPADD R1 R1 #1 next mem...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Lab Assignment 2 .ORIG x3000 LEA R1 x0EF load memory address of char 1 x30F0 into R1 LEA R7 x0FD memory address of last character AND R4 R4 #0 R4 = was there a swap? STORECHARSLDR R2 R1 #0 Load contents of R1 into R2 LDR R3 R1 #1 Load contents of R1(next char) into R3 BRNZP COMPARE COMPAREAND R5 R5 #0 set R5 to zero NOT R3 R3 ADD R3 R3 #1 turn R3 into 2's complement of char two, ADD R5 R2 R3 Subtract R3 from R2, comparing the two characters ADD R3 R3 #-1 NOT R3 R3 turn back into positive char ADD R5 R5 #0 BRNZ AFTERSWAP if negative or zero, branch to afterswap BRP SWAP if positive, branch to swap SWAPSTR R2 R1 #1 STR R3 R1 #0 swap ADD R4 R4 #1 increment R4 to indicate swap
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: BRNZP AFTERSWAP AFTERSWAPADD R1 R1 #1 next mem address AND R0 R0 #0 zero R0 AND R6 R6 #0 zero R6 ADD R6 R7 #0 put last address into R6 NOT R6 R6 ADD R6 R6 #1 negative of last address ADD R0 R1 R6 subtract addresses BRNP STORECHARS if not last address, compare again BRZ GOAGAIN if last address, test if there were any swaps GOAGAINADD R4 R4 #0 BRZ END If R4 is zero, no swaps, then sort is complete BRP RESET if R4 is anything else, there were swaps, reset. RESETAND R4 R4 #0 reset R4 to zero ADD R1 R1 #-16 set R1 back to first char addr BRNZP STORECHARS compare again ENDTRAP x25 stop program .END...
View Full Document

Ask a homework question - tutors are online