{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern