home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / _addresses / !Addresses / MakeCode (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1993-09-22  |  2KB  |  94 lines

  1.  >MakeCode
  2.  Forms part of !Addresses v1.16 upwards
  3.  Thanks to M.T.C.'s book ARM Assembly Language Programming for 'toUpper'
  4. " at line ";
  5.  code% 512, buff1% 20, buff2% 20
  6. cr=&0D
  7. strPtr=0
  8.         sp=13
  9. link=14
  10. carryBit=&20000000
  11. pass%=0 
  12. P%=code%
  13. [opt pass%
  14. .toUpper
  15. %   STMFD   (sp)!,{R1,strPtr,link}
  16. .toUpLp
  17.    LDRB    R1, [strPtr], #1
  18.    CMP     R1, #cr
  19. &   LDMEQFD (sp)!, {R1, strPtr, pc}
  20.    CMP     R1,#
  21.    RSBHSS  R2,R1,#
  22.    SUBHS   R1,R1,#&20
  23.    STRB    R1,[strPtr, #-1]
  24.    B       toUpLp
  25.    MOV     pc,link
  26.     .sort
  27. .sortlp
  28.    LDRB    r2,[r0],#1
  29.    LDRB    r3,[r1],#1
  30.    CMP     r2,#cr
  31.    BEQ     lower
  32.    CMP     r3,#cr
  33.    BEQ     higher
  34.    CMP     r2,r3
  35.    BEQ     sortlp
  36.    BLT     lower
  37.    B       higher
  38. .lower
  39.    MOV     r0,#1
  40.    CMP     r2,r3
  41. Q   r0,#2
  42.    MOV     pc,link
  43. .higher
  44.    MOV     r0,#0
  45.    CMP     r2,r3
  46. Q   r0,#2
  47.    MOV     pc,link
  48. 4K$buff1%="Neil Walker":
  49. $buff1%;:A%=buff1%:
  50.  toUpper:
  51. " Becomes "$buff1%
  52. 5Q$buff1%="NEIL WALKAR":$buff2%="NEIL WALKER":A%=buff1%:B%=buff2%:result%=
  53.  result% 
  54. 7-   
  55. $buff1%;" is lower than ";$buff2%
  56. 8-   
  57. $buff2%;" is lower than ";$buff1%
  58. "Equal"
  59. count%=0 
  60.  1000
  61. >Fentry$="NEIL WALKER":nextentry$="NEIL WALKAR":ascending%=
  62. :swap%=0
  63. ext%=1
  64. @G      char%=(
  65. entry$,ext%)
  66. &5F):nextchar%=(
  67. nextentry$,ext%)
  68.       
  69. ascending%
  70. B%         
  71. char%>nextchar% swap%=
  72.       
  73. D%         
  74. char%<nextchar% swap%=
  75.       
  76. F       
  77. char%=nextchar% 
  78. -s%,swap%
  79. swap%=0
  80. count%=0 
  81.  1000
  82. MQ$buff1%="NEIL WALKAR":$buff2%="NEIL WALKER":A%=buff1%:B%=buff2%:result%=
  83. ascending%
  84.       
  85. result%=1 swap%=
  86.       
  87. result%=0 swap%=
  88. -s%,swap%
  89. "SAVE Code "+
  90. ~code%+" "+
  91. "SetType Code Data"
  92. "toUpper offset = ";toUpper-code%
  93. "sort    offset = ";sort-code%
  94.