Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_39.ADF » P/Wrap

P/Wrap

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_39.ADF
Filename: P/Wrap
Read OK:
File size: 0569 bytes
Load address: FFFFFB48
Exec address: 1226D
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
   10REM Demonstrate how to wordwrap in
   20REM assembler
   30:
   40DIM wrap% &100
   50osnl=&FFE7:osas=&FFE3:oswc=&FFEE
   60addrL=&70:addrH=&71:REM Hi and low bytes of the address where the text starts
   70oldpos=&72
   80:
   90FORX=0TO3STEP3
  100P%=wrap%
  110[OPTX
  120.getstring
  130\Start at the end and work backwards
  140LDY#39:\Offset 39 is the end of the 40 column screen
  150.getletter
  160LDA(addrL),Y:CMP#ASC"0":BCCwrappointfound:DEY:BMInowrappoint:JMPgetletter
  170:
  180.wrappointfound
  190\Might still be (or might be) a carriage return too
  200INY:STYoldpos:LDY#0
  210.carriagesearch
  220LDA(addrL),Y:CMP#13:BEQcarriagereturn:INY:CPY#40:BNEcarriagesearch
  230LDAoldpos:JSRprintitthen
  240LDAoldpos:CMP#40:BEQgetstring:JSRosnl:JMPgetstring
  250EQUS"(C)1998 SPROW"
  260:
  270.carriagereturn
  280\Print upto the carriage return
  290INY:TYA:JSRprintitthen:JMPgetstring
  300:
  310.nowrappoint
  320\Just print out 40 letters cos we couldn't wrap
  330LDA#40:JSRprintitthen:JMPgetstring
  340:
  350.printitthen
  360\Prints out 'n' chrs specified in A
  370LDY#0:TAX:DEX
  380.printloop
  390LDA(addrL),Y:BEQprintjobdone:JSRoswc:INY:DEX:BPLprintloop
  400.printadd
  410TYA:CLC:ADCaddrL:STAaddrL
  420LDA#0:ADCaddrH:STAaddrH:RTS:\Bump up the address by 'n' characters
  430.printjobdone
  440PLA:PLA:RTS:\Suck off top stack entry and quit
  450]
  460NEXT
  470DIMtext% 5000
  480?addrL=text% MOD256:?addrH=text% DIV256
  490CLS:VDU14
  500OSCLI"LOAD Tester "+STR$~text%
  510CALLwrap%

$� Demonstrate how to wordwrap in
� assembler
:
(� wrap% &100
2$osnl=&FFE7:osas=&FFE3:oswc=&FFEE
<OaddrL=&70:addrH=&71:� Hi and low bytes of the address where the text starts
Foldpos=&72
P:
Z�X=0�3�3
dP%=wrap%
n	[OPTX
x.getstring
�(\Start at the end and work backwards
�8LDY#39:\Offset 39 is the end of the 40 column screen
�.getletter
�KLDA(addrL),Y:CMP#�"0":BCCwrappointfound:DEY:BMInowrappoint:JMPgetletter
�:
�.wrappointfound
�7\Might still be (or might be) a carriage return too
�INY:STYoldpos:LDY#0
�.carriagesearch
�FLDA(addrL),Y:CMP#13:BEQcarriagereturn:INY:CPY#40:BNEcarriagesearch
�LDAoldpos:JSRprintitthen
�6LDAoldpos:CMP#40:BEQgetstring:JSRosnl:JMPgetstring
�EQUS"(C)1998 SPROW"
:
.carriagereturn
#\Print upto the carriage return
"'INY:TYA:JSRprintitthen:JMPgetstring
,:
6.nowrappoint
@3\Just print out 40 letters cos we couldn't wrap
J&LDA#40:JSRprintitthen:JMPgetstring
T:
^.printitthen
h'\Prints out 'n' chrs specified in A
rLDY#0:TAX:DEX
|.printloop
�=LDA(addrL),Y:BEQprintjobdone:JSRoswc:INY:DEX:BPLprintloop
�
.printadd
�TYA:CLC:ADCaddrL:STAaddrL
�FLDA#0:ADCaddrH:STAaddrH:RTS:\Bump up the address by 'n' characters
�.printjobdone
�2PLA:PLA:RTS:\Suck off top stack entry and quit
�]
��
��text% 5000
�'?addrL=text% �256:?addrH=text% �256
�	�:�14
��"LOAD Tester "+�~text%
�
�wrap%
�
00000000  0d 00 0a 24 f4 20 44 65  6d 6f 6e 73 74 72 61 74  |...$. Demonstrat|
00000010  65 20 68 6f 77 20 74 6f  20 77 6f 72 64 77 72 61  |e how to wordwra|
00000020  70 20 69 6e 0d 00 14 0f  f4 20 61 73 73 65 6d 62  |p in..... assemb|
00000030  6c 65 72 0d 00 1e 05 3a  0d 00 28 10 de 20 77 72  |ler....:..(.. wr|
00000040  61 70 25 20 26 31 30 30  0d 00 32 24 6f 73 6e 6c  |ap% &100..2$osnl|
00000050  3d 26 46 46 45 37 3a 6f  73 61 73 3d 26 46 46 45  |=&FFE7:osas=&FFE|
00000060  33 3a 6f 73 77 63 3d 26  46 46 45 45 0d 00 3c 4f  |3:oswc=&FFEE..<O|
00000070  61 64 64 72 4c 3d 26 37  30 3a 61 64 64 72 48 3d  |addrL=&70:addrH=|
00000080  26 37 31 3a f4 20 48 69  20 61 6e 64 20 6c 6f 77  |&71:. Hi and low|
00000090  20 62 79 74 65 73 20 6f  66 20 74 68 65 20 61 64  | bytes of the ad|
000000a0  64 72 65 73 73 20 77 68  65 72 65 20 74 68 65 20  |dress where the |
000000b0  74 65 78 74 20 73 74 61  72 74 73 0d 00 46 0e 6f  |text starts..F.o|
000000c0  6c 64 70 6f 73 3d 26 37  32 0d 00 50 05 3a 0d 00  |ldpos=&72..P.:..|
000000d0  5a 0c e3 58 3d 30 b8 33  88 33 0d 00 64 0c 50 25  |Z..X=0.3.3..d.P%|
000000e0  3d 77 72 61 70 25 0d 00  6e 09 5b 4f 50 54 58 0d  |=wrap%..n.[OPTX.|
000000f0  00 78 0e 2e 67 65 74 73  74 72 69 6e 67 0d 00 82  |.x..getstring...|
00000100  28 5c 53 74 61 72 74 20  61 74 20 74 68 65 20 65  |(\Start at the e|
00000110  6e 64 20 61 6e 64 20 77  6f 72 6b 20 62 61 63 6b  |nd and work back|
00000120  77 61 72 64 73 0d 00 8c  38 4c 44 59 23 33 39 3a  |wards...8LDY#39:|
00000130  5c 4f 66 66 73 65 74 20  33 39 20 69 73 20 74 68  |\Offset 39 is th|
00000140  65 20 65 6e 64 20 6f 66  20 74 68 65 20 34 30 20  |e end of the 40 |
00000150  63 6f 6c 75 6d 6e 20 73  63 72 65 65 6e 0d 00 96  |column screen...|
00000160  0e 2e 67 65 74 6c 65 74  74 65 72 0d 00 a0 4b 4c  |..getletter...KL|
00000170  44 41 28 61 64 64 72 4c  29 2c 59 3a 43 4d 50 23  |DA(addrL),Y:CMP#|
00000180  97 22 30 22 3a 42 43 43  77 72 61 70 70 6f 69 6e  |."0":BCCwrappoin|
00000190  74 66 6f 75 6e 64 3a 44  45 59 3a 42 4d 49 6e 6f  |tfound:DEY:BMIno|
000001a0  77 72 61 70 70 6f 69 6e  74 3a 4a 4d 50 67 65 74  |wrappoint:JMPget|
000001b0  6c 65 74 74 65 72 0d 00  aa 05 3a 0d 00 b4 13 2e  |letter....:.....|
000001c0  77 72 61 70 70 6f 69 6e  74 66 6f 75 6e 64 0d 00  |wrappointfound..|
000001d0  be 37 5c 4d 69 67 68 74  20 73 74 69 6c 6c 20 62  |.7\Might still b|
000001e0  65 20 28 6f 72 20 6d 69  67 68 74 20 62 65 29 20  |e (or might be) |
000001f0  61 20 63 61 72 72 69 61  67 65 20 72 65 74 75 72  |a carriage retur|
00000200  6e 20 74 6f 6f 0d 00 c8  17 49 4e 59 3a 53 54 59  |n too....INY:STY|
00000210  6f 6c 64 70 6f 73 3a 4c  44 59 23 30 0d 00 d2 13  |oldpos:LDY#0....|
00000220  2e 63 61 72 72 69 61 67  65 73 65 61 72 63 68 0d  |.carriagesearch.|
00000230  00 dc 46 4c 44 41 28 61  64 64 72 4c 29 2c 59 3a  |..FLDA(addrL),Y:|
00000240  43 4d 50 23 31 33 3a 42  45 51 63 61 72 72 69 61  |CMP#13:BEQcarria|
00000250  67 65 72 65 74 75 72 6e  3a 49 4e 59 3a 43 50 59  |gereturn:INY:CPY|
00000260  23 34 30 3a 42 4e 45 63  61 72 72 69 61 67 65 73  |#40:BNEcarriages|
00000270  65 61 72 63 68 0d 00 e6  1c 4c 44 41 6f 6c 64 70  |earch....LDAoldp|
00000280  6f 73 3a 4a 53 52 70 72  69 6e 74 69 74 74 68 65  |os:JSRprintitthe|
00000290  6e 0d 00 f0 36 4c 44 41  6f 6c 64 70 6f 73 3a 43  |n...6LDAoldpos:C|
000002a0  4d 50 23 34 30 3a 42 45  51 67 65 74 73 74 72 69  |MP#40:BEQgetstri|
000002b0  6e 67 3a 4a 53 52 6f 73  6e 6c 3a 4a 4d 50 67 65  |ng:JSRosnl:JMPge|
000002c0  74 73 74 72 69 6e 67 0d  00 fa 17 45 51 55 53 22  |tstring....EQUS"|
000002d0  28 43 29 31 39 39 38 20  53 50 52 4f 57 22 0d 01  |(C)1998 SPROW"..|
000002e0  04 05 3a 0d 01 0e 13 2e  63 61 72 72 69 61 67 65  |..:.....carriage|
000002f0  72 65 74 75 72 6e 0d 01  18 23 5c 50 72 69 6e 74  |return...#\Print|
00000300  20 75 70 74 6f 20 74 68  65 20 63 61 72 72 69 61  | upto the carria|
00000310  67 65 20 72 65 74 75 72  6e 0d 01 22 27 49 4e 59  |ge return.."'INY|
00000320  3a 54 59 41 3a 4a 53 52  70 72 69 6e 74 69 74 74  |:TYA:JSRprintitt|
00000330  68 65 6e 3a 4a 4d 50 67  65 74 73 74 72 69 6e 67  |hen:JMPgetstring|
00000340  0d 01 2c 05 3a 0d 01 36  10 2e 6e 6f 77 72 61 70  |..,.:..6..nowrap|
00000350  70 6f 69 6e 74 0d 01 40  33 5c 4a 75 73 74 20 70  |point..@3\Just p|
00000360  72 69 6e 74 20 6f 75 74  20 34 30 20 6c 65 74 74  |rint out 40 lett|
00000370  65 72 73 20 63 6f 73 20  77 65 20 63 6f 75 6c 64  |ers cos we could|
00000380  6e 27 74 20 77 72 61 70  0d 01 4a 26 4c 44 41 23  |n't wrap..J&LDA#|
00000390  34 30 3a 4a 53 52 70 72  69 6e 74 69 74 74 68 65  |40:JSRprintitthe|
000003a0  6e 3a 4a 4d 50 67 65 74  73 74 72 69 6e 67 0d 01  |n:JMPgetstring..|
000003b0  54 05 3a 0d 01 5e 10 2e  70 72 69 6e 74 69 74 74  |T.:..^..printitt|
000003c0  68 65 6e 0d 01 68 27 5c  50 72 69 6e 74 73 20 6f  |hen..h'\Prints o|
000003d0  75 74 20 27 6e 27 20 63  68 72 73 20 73 70 65 63  |ut 'n' chrs spec|
000003e0  69 66 69 65 64 20 69 6e  20 41 0d 01 72 11 4c 44  |ified in A..r.LD|
000003f0  59 23 30 3a 54 41 58 3a  44 45 58 0d 01 7c 0e 2e  |Y#0:TAX:DEX..|..|
00000400  70 72 69 6e 74 6c 6f 6f  70 0d 01 86 3d 4c 44 41  |printloop...=LDA|
00000410  28 61 64 64 72 4c 29 2c  59 3a 42 45 51 70 72 69  |(addrL),Y:BEQpri|
00000420  6e 74 6a 6f 62 64 6f 6e  65 3a 4a 53 52 6f 73 77  |ntjobdone:JSRosw|
00000430  63 3a 49 4e 59 3a 44 45  58 3a 42 50 4c 70 72 69  |c:INY:DEX:BPLpri|
00000440  6e 74 6c 6f 6f 70 0d 01  90 0d 2e 70 72 69 6e 74  |ntloop.....print|
00000450  61 64 64 0d 01 9a 1d 54  59 41 3a 43 4c 43 3a 41  |add....TYA:CLC:A|
00000460  44 43 61 64 64 72 4c 3a  53 54 41 61 64 64 72 4c  |DCaddrL:STAaddrL|
00000470  0d 01 a4 46 4c 44 41 23  30 3a 41 44 43 61 64 64  |...FLDA#0:ADCadd|
00000480  72 48 3a 53 54 41 61 64  64 72 48 3a 52 54 53 3a  |rH:STAaddrH:RTS:|
00000490  5c 42 75 6d 70 20 75 70  20 74 68 65 20 61 64 64  |\Bump up the add|
000004a0  72 65 73 73 20 62 79 20  27 6e 27 20 63 68 61 72  |ress by 'n' char|
000004b0  61 63 74 65 72 73 0d 01  ae 11 2e 70 72 69 6e 74  |acters.....print|
000004c0  6a 6f 62 64 6f 6e 65 0d  01 b8 32 50 4c 41 3a 50  |jobdone...2PLA:P|
000004d0  4c 41 3a 52 54 53 3a 5c  53 75 63 6b 20 6f 66 66  |LA:RTS:\Suck off|
000004e0  20 74 6f 70 20 73 74 61  63 6b 20 65 6e 74 72 79  | top stack entry|
000004f0  20 61 6e 64 20 71 75 69  74 0d 01 c2 05 5d 0d 01  | and quit....]..|
00000500  cc 05 ed 0d 01 d6 0f de  74 65 78 74 25 20 35 30  |........text% 50|
00000510  30 30 0d 01 e0 27 3f 61  64 64 72 4c 3d 74 65 78  |00...'?addrL=tex|
00000520  74 25 20 83 32 35 36 3a  3f 61 64 64 72 48 3d 74  |t% .256:?addrH=t|
00000530  65 78 74 25 20 81 32 35  36 0d 01 ea 09 db 3a ef  |ext% .256.....:.|
00000540  31 34 0d 01 f4 1b ff 22  4c 4f 41 44 20 54 65 73  |14....."LOAD Tes|
00000550  74 65 72 20 22 2b c3 7e  74 65 78 74 25 0d 01 fe  |ter "+.~text%...|
00000560  0a d6 77 72 61 70 25 0d  ff                       |..wrap%..|
00000569
P/Wrap.m0
P/Wrap.m1
P/Wrap.m2
P/Wrap.m4
P/Wrap.m5