Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

LMC Bubble Sort Explination.

assembly

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 CaptainFalcon

CaptainFalcon

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 25 January 2017 - 06:02 AM

Hi guys

 

Here is a code I found in the assembly sub section of this forum , and it is what we are currently studying at school in computer science. However I cant understand some of the finer elements of the code. I understand the simple INP , and STA NUM1 etc , but the variables like FLAG and TEMP I struggle to see their purpose? Could somebody shed some light on the situation.

Here is the code for reference:

 

        INP
        STA NUMONE
        INP
        STA NUMTWO
        INP
        STA NUMTHREE
        INP
        STA NUMFOUR
        INP
        STA NUMFIVE
START   LDA ZERO
        STA FLAG
        LDA NUMTWO
        SUB NUMONE
        BRP TWOBIG
        LDA ONE
        STA FLAG
        LDA NUMONE
        STA TEMP
        LDA NUMTWO
        STA NUMONE
        LDA TEMP
        STA NUMTWO
TWOBIG  LDA NUMTHREE
        SUB NUMTWO
        BRP THREEBIG
        LDA ONE
        STA FLAG
        LDA NUMTWO
        STA TEMP
        LDA NUMTHREE
        STA NUMTWO
        LDA TEMP
        STA NUMTHREE
THREEBIG LDA NUMFOUR
        SUB NUMTHREE
        BRP FOURBIG
        LDA ONE
        STA FLAG
        LDA NUMTHREE
        STA TEMP
        LDA NUMFOUR
        STA NUMTHREE
        LDA TEMP
        STA NUMFOUR
FOURBIG LDA NUMFIVE
        SUB NUMFOUR
        BRP FIVEBIG
        LDA ONE
        STA FLAG
        LDA NUMFOUR
        STA TEMP
        LDA NUMFIVE
        STA NUMFOUR
        LDA TEMP
        STA NUMFIVE
FIVEBIG LDA FLAG
        BRZ FLAGZERO
        BRA START
FLAGZERO LDA NUMONE
        OUT
        LDA NUMTWO
        OUT
        LDA NUMTHREE
        OUT
        LDA NUMFOUR
        OUT
        LDA NUMFIVE
        OUT
        HLT
NUMONE  DAT
NUMTWO  DAT
NUMTHREE DAT
NUMFOUR DAT
NUMFIVE DAT
FLAG    DAT
TEMP    DAT
ONE     DAT 001
ZERO    DAT 000

 






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download