Advertisement
yugorin

Bubble sort 6502 asm

Jun 13th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :BasicUpstart2(main)
  2.  
  3. .var brkFile = createFile("breakpoints.txt")
  4.  
  5. .macro break() {
  6.   .eval brkFile.writeln("break " + toHexString(*))
  7. }
  8.  
  9.  
  10. main:
  11.  
  12.  
  13.     ldx #$00
  14. tam:
  15.     ldy #$00
  16.  
  17. tutaj:
  18.  
  19.         lda numery,y
  20.         cmp numery+1,y
  21.         beq noswap
  22.         bcc noswap
  23.        
  24.         lda numery+1,y
  25.         sta tmp
  26.         lda numery,y
  27.         sta numery+1,y
  28.         lda tmp
  29.         sta numery,y
  30.  
  31. noswap:
  32.  
  33.         iny
  34.         cpy #$fe
  35.         bne tutaj  
  36.         inx
  37.         cpx #$fe
  38.         bne tam
  39.         rts
  40.        
  41.            
  42.        
  43.        
  44. .pc = $c000 "Tablica"
  45.        
  46. numery:
  47. .byte $7F,$7C,$79,$76,$72,$6F,$6C,$69,$66,$63,$60,$5D,$5A,$57,$54,$51
  48. .byte $4E,$4B,$48,$45,$42,$3F,$3D,$3A,$37,$35,$32,$30,$2D,$2B,$29,$26
  49. .byte $24,$22,$20,$1E,$1C,$1A,$18,$16,$14,$12,$11,$F,$E,$C,$B,$A
  50. .byte $9,$7,$6,$5,$4,$4,$3,$2,$2,$1,$1,$0,$0,$0,$0,$0
  51. .byte $0,$0,$0,$0,$0,$1,$1,$2,$2,$3,$4,$5,$6,$7,$8,$9
  52. .byte $A,$C,$D,$F,$10,$12,$13,$15,$17,$19,$1B,$1D,$1F,$21,$23,$25
  53. .byte $27,$2A,$2C,$2F,$31,$34,$36,$39,$3B,$3E,$41,$44,$46,$49,$4C,$4F
  54. .byte $52,$55,$58,$5B,$5E,$61,$64,$67,$6B,$6E,$71,$74,$77,$7A,$7D,$81
  55. .byte $84,$87,$8A,$8D,$90,$93,$97,$9A,$9D,$A0,$A3,$A6,$A9,$AC,$AF,$B2
  56. .byte $B5,$B8,$BA,$BD,$C0,$C3,$C5,$C8,$CA,$CD,$CF,$D2,$D4,$D7,$D9,$DB
  57. .byte $DD,$DF,$E1,$E3,$E5,$E7,$E9,$EB,$EC,$EE,$EF,$F1,$F2,$F4,$F5,$F6
  58. .byte $F7,$F8,$F9,$FA,$FB,$FC,$FC,$FD,$FD,$FE,$FE,$FE,$FE,$FE,$FE,$FE
  59. .byte $FE,$FE,$FE,$FD,$FD,$FC,$FC,$FB,$FA,$FA,$F9,$F8,$F7,$F5,$F4,$F3
  60. .byte $F2,$F0,$EF,$ED,$EC,$EA,$E8,$E6,$E4,$E2,$E0,$DE,$DC,$DA,$D8,$D5
  61. .byte $D3,$D1,$CE,$CC,$C9,$C7,$C4,$C1,$BF,$BC,$B9,$B6,$B3,$B0,$AD,$AA
  62. .byte $A7,$A4,$A1,$9E,$9B,$98,$95,$92,$8F,$8C,$88,$85,$82,$7F
  63.  
  64.  
  65.    
  66. tmp:
  67.     .byte $00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement