Home » CEEFAX disks » telesoftware3.adl » 23_10_87/B\OSB02
23_10_87/B\OSB02
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 » CEEFAX disks » telesoftware3.adl |
Filename: | 23_10_87/B\OSB02 |
Read OK: | ✔ |
File size: | 0608 bytes |
Load address: | 1900 |
Exec address: | 8023 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- CEEFAX disks » telesoftware3.adl » 01_11_87/B\OSB02
- CEEFAX disks » telesoftware3.adl » 23_10_87/B\OSB02
File contents
10REM OSbits module B/osb02 20REM Addition and subtraction 30REM Version 1.0 24.8.86 40 50*KEY1MO.3|M|NL.|M 60 70DIM code% 256 80DIM number1% 4 90DIM number2% 4 100DIM addition% 4 110DIM subtraction% 4 120 130INPUT "Enter the first number "!number1% 140INPUT "Enter the second number "!number2% 150 160FOR pass%=0 TO 3 STEP 3 170P%=code% 180 190[OPT pass% 200\ Addition of the two numbers 210CLC \ Clear the carry flag for LSB of an addition 220 230LDA number1% \ Add least significant bytes 240ADC number2% 250STA addition% 260 270LDA number1%+1 \ Add second bytes 280ADC number2%+1 290STA addition%+1 300 310LDA number1%+2 \ Add third bytes 320ADC number2%+2 330STA addition%+2 340 350LDA number1%+3 \ Add fourth, and most significant, bytes 360ADC number2%+3 370STA addition%+3 380 390\ Subtraction of the two numbers 400SEC \ Set the carry flag for LSB of a subtraction 410 420LDA number1% \ Subtract first bytes (LSB) 430SBC number2% 440STA subtraction% 450 460LDA number1%+1 \ Then second bytes 470SBC number2%+1 480STA subtraction%+1 490 500LDA number1%+2 \ Then third bytes 510SBC number2%+2 520STA subtraction%+2 530 540LDA number1%+3 \ Finally subtract fourth bytes (MSB) 550SBC number2%+3 560STA subtraction%+3 570 580RTS \ Return to BASIC 590] 600NEXT 610CALL code% 620PRINT 630PRINT "The sum is ";!addition%; " from Mcode : ";!number1%+!number2%;" from BASIC" 640PRINT "The difference is ";!subtraction%; " from Mcode : ";!number1%-!number2%;" from BASIC"
� OSbits module B/osb02 � Addition and subtraction � Version 1.0 24.8.86 ( 2*KEY1MO.3|M|NL.|M < F� code% 256 P� number1% 4 Z� number2% 4 d� addition% 4 n� subtraction% 4 x �(� "Enter the first number "!number1% �)� "Enter the second number "!number2% � �� pass%=0 � 3 � 3 �P%=code% � �[OPT pass% �"\ Addition of the two numbers �ECLC \ Clear the carry flag for LSB of an addition � �5LDA number1% \ Add least significant bytes �ADC number2% �STA addition% *LDA number1%+1 \ Add second bytes ADC number2%+1 "STA addition%+1 , 6)LDA number1%+2 \ Add third bytes @ADC number2%+2 JSTA addition%+2 T ^ALDA number1%+3 \ Add fourth, and most significant, bytes hADC number2%+3 rSTA addition%+3 | �%\ Subtraction of the two numbers �ESEC \ Set the carry flag for LSB of a subtraction � �4LDA number1% \ Subtract first bytes (LSB) �SBC number2% �STA subtraction% � �+LDA number1%+1 \ Then second bytes �SBC number2%+1 �STA subtraction%+1 � �*LDA number1%+2 \ Then third bytes �SBC number2%+2 STA subtraction%+2 =LDA number1%+3 \ Finally subtract fourth bytes (MSB) &SBC number2%+3 0STA subtraction%+3 : D)RTS \ Return to BASIC N] X� b� code% l� vR� "The sum is ";!addition%; " from Mcode : ";!number1%+!number2%;" from BASIC" �\� "The difference is ";!subtraction%; " from Mcode : ";!number1%-!number2%;" from BASIC" �
00000000 0d 00 0a 1c f4 20 20 4f 53 62 69 74 73 20 6d 6f |..... OSbits mo| 00000010 64 75 6c 65 20 42 2f 6f 73 62 30 32 0d 00 14 1f |dule B/osb02....| 00000020 f4 20 20 41 64 64 69 74 69 6f 6e 20 61 6e 64 20 |. Addition and | 00000030 73 75 62 74 72 61 63 74 69 6f 6e 0d 00 1e 1a f4 |subtraction.....| 00000040 20 20 56 65 72 73 69 6f 6e 20 31 2e 30 20 32 34 | Version 1.0 24| 00000050 2e 38 2e 38 36 0d 00 28 05 20 0d 00 32 15 2a 4b |.8.86..(. ..2.*K| 00000060 45 59 31 4d 4f 2e 33 7c 4d 7c 4e 4c 2e 7c 4d 0d |EY1MO.3|M|NL.|M.| 00000070 00 3c 05 20 0d 00 46 0f de 20 63 6f 64 65 25 20 |.<. ..F.. code% | 00000080 32 35 36 0d 00 50 10 de 20 6e 75 6d 62 65 72 31 |256..P.. number1| 00000090 25 20 34 0d 00 5a 10 de 20 6e 75 6d 62 65 72 32 |% 4..Z.. number2| 000000a0 25 20 34 0d 00 64 11 de 20 61 64 64 69 74 69 6f |% 4..d.. additio| 000000b0 6e 25 20 34 0d 00 6e 14 de 20 73 75 62 74 72 61 |n% 4..n.. subtra| 000000c0 63 74 69 6f 6e 25 20 34 0d 00 78 05 20 0d 00 82 |ction% 4..x. ...| 000000d0 28 e8 20 22 45 6e 74 65 72 20 74 68 65 20 66 69 |(. "Enter the fi| 000000e0 72 73 74 20 6e 75 6d 62 65 72 20 22 21 6e 75 6d |rst number "!num| 000000f0 62 65 72 31 25 0d 00 8c 29 e8 20 22 45 6e 74 65 |ber1%...). "Ente| 00000100 72 20 74 68 65 20 73 65 63 6f 6e 64 20 6e 75 6d |r the second num| 00000110 62 65 72 20 22 21 6e 75 6d 62 65 72 32 25 0d 00 |ber "!number2%..| 00000120 96 05 20 0d 00 a0 15 e3 20 70 61 73 73 25 3d 30 |.. ..... pass%=0| 00000130 20 b8 20 33 20 88 20 33 0d 00 aa 0c 50 25 3d 63 | . 3 . 3....P%=c| 00000140 6f 64 65 25 0d 00 b4 05 20 0d 00 be 0e 5b 4f 50 |ode%.... ....[OP| 00000150 54 20 70 61 73 73 25 0d 00 c8 22 5c 20 20 41 64 |T pass%..."\ Ad| 00000160 64 69 74 69 6f 6e 20 6f 66 20 74 68 65 20 74 77 |dition of the tw| 00000170 6f 20 6e 75 6d 62 65 72 73 0d 00 d2 45 43 4c 43 |o numbers...ECLC| 00000180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000190 20 5c 20 43 6c 65 61 72 20 74 68 65 20 63 61 72 | \ Clear the car| 000001a0 72 79 20 66 6c 61 67 20 66 6f 72 20 4c 53 42 20 |ry flag for LSB | 000001b0 6f 66 20 61 6e 20 61 64 64 69 74 69 6f 6e 0d 00 |of an addition..| 000001c0 dc 05 20 0d 00 e6 35 4c 44 41 20 6e 75 6d 62 65 |.. ...5LDA numbe| 000001d0 72 31 25 20 20 20 20 20 20 20 20 5c 20 41 64 64 |r1% \ Add| 000001e0 20 6c 65 61 73 74 20 73 69 67 6e 69 66 69 63 61 | least significa| 000001f0 6e 74 20 62 79 74 65 73 0d 00 f0 10 41 44 43 20 |nt bytes....ADC | 00000200 6e 75 6d 62 65 72 32 25 0d 00 fa 11 53 54 41 20 |number2%....STA | 00000210 61 64 64 69 74 69 6f 6e 25 0d 01 04 05 20 0d 01 |addition%.... ..| 00000220 0e 2a 4c 44 41 20 6e 75 6d 62 65 72 31 25 2b 31 |.*LDA number1%+1| 00000230 20 20 20 20 20 20 5c 20 41 64 64 20 73 65 63 6f | \ Add seco| 00000240 6e 64 20 62 79 74 65 73 0d 01 18 12 41 44 43 20 |nd bytes....ADC | 00000250 6e 75 6d 62 65 72 32 25 2b 31 0d 01 22 13 53 54 |number2%+1..".ST| 00000260 41 20 61 64 64 69 74 69 6f 6e 25 2b 31 0d 01 2c |A addition%+1..,| 00000270 05 20 0d 01 36 29 4c 44 41 20 6e 75 6d 62 65 72 |. ..6)LDA number| 00000280 31 25 2b 32 20 20 20 20 20 20 5c 20 41 64 64 20 |1%+2 \ Add | 00000290 74 68 69 72 64 20 62 79 74 65 73 0d 01 40 12 41 |third bytes..@.A| 000002a0 44 43 20 6e 75 6d 62 65 72 32 25 2b 32 0d 01 4a |DC number2%+2..J| 000002b0 13 53 54 41 20 61 64 64 69 74 69 6f 6e 25 2b 32 |.STA addition%+2| 000002c0 0d 01 54 05 20 0d 01 5e 41 4c 44 41 20 6e 75 6d |..T. ..^ALDA num| 000002d0 62 65 72 31 25 2b 33 20 20 20 20 20 20 5c 20 41 |ber1%+3 \ A| 000002e0 64 64 20 66 6f 75 72 74 68 2c 20 61 6e 64 20 6d |dd fourth, and m| 000002f0 6f 73 74 20 73 69 67 6e 69 66 69 63 61 6e 74 2c |ost significant,| 00000300 20 62 79 74 65 73 0d 01 68 12 41 44 43 20 6e 75 | bytes..h.ADC nu| 00000310 6d 62 65 72 32 25 2b 33 0d 01 72 13 53 54 41 20 |mber2%+3..r.STA | 00000320 61 64 64 69 74 69 6f 6e 25 2b 33 0d 01 7c 05 20 |addition%+3..|. | 00000330 0d 01 86 25 5c 20 20 53 75 62 74 72 61 63 74 69 |...%\ Subtracti| 00000340 6f 6e 20 6f 66 20 74 68 65 20 74 77 6f 20 6e 75 |on of the two nu| 00000350 6d 62 65 72 73 0d 01 90 45 53 45 43 20 20 20 20 |mbers...ESEC | 00000360 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 | \ S| 00000370 65 74 20 74 68 65 20 63 61 72 72 79 20 66 6c 61 |et the carry fla| 00000380 67 20 66 6f 72 20 4c 53 42 20 6f 66 20 61 20 73 |g for LSB of a s| 00000390 75 62 74 72 61 63 74 69 6f 6e 0d 01 9a 05 20 0d |ubtraction.... .| 000003a0 01 a4 34 4c 44 41 20 6e 75 6d 62 65 72 31 25 20 |..4LDA number1% | 000003b0 20 20 20 20 20 20 20 5c 20 53 75 62 74 72 61 63 | \ Subtrac| 000003c0 74 20 66 69 72 73 74 20 62 79 74 65 73 20 28 4c |t first bytes (L| 000003d0 53 42 29 0d 01 ae 10 53 42 43 20 6e 75 6d 62 65 |SB)....SBC numbe| 000003e0 72 32 25 0d 01 b8 14 53 54 41 20 73 75 62 74 72 |r2%....STA subtr| 000003f0 61 63 74 69 6f 6e 25 0d 01 c2 05 20 0d 01 cc 2b |action%.... ...+| 00000400 4c 44 41 20 6e 75 6d 62 65 72 31 25 2b 31 20 20 |LDA number1%+1 | 00000410 20 20 20 20 5c 20 54 68 65 6e 20 73 65 63 6f 6e | \ Then secon| 00000420 64 20 62 79 74 65 73 0d 01 d6 12 53 42 43 20 6e |d bytes....SBC n| 00000430 75 6d 62 65 72 32 25 2b 31 0d 01 e0 16 53 54 41 |umber2%+1....STA| 00000440 20 73 75 62 74 72 61 63 74 69 6f 6e 25 2b 31 0d | subtraction%+1.| 00000450 01 ea 05 20 0d 01 f4 2a 4c 44 41 20 6e 75 6d 62 |... ...*LDA numb| 00000460 65 72 31 25 2b 32 20 20 20 20 20 20 5c 20 54 68 |er1%+2 \ Th| 00000470 65 6e 20 74 68 69 72 64 20 62 79 74 65 73 0d 01 |en third bytes..| 00000480 fe 12 53 42 43 20 6e 75 6d 62 65 72 32 25 2b 32 |..SBC number2%+2| 00000490 0d 02 08 16 53 54 41 20 73 75 62 74 72 61 63 74 |....STA subtract| 000004a0 69 6f 6e 25 2b 32 0d 02 12 05 20 0d 02 1c 3d 4c |ion%+2.... ...=L| 000004b0 44 41 20 6e 75 6d 62 65 72 31 25 2b 33 20 20 20 |DA number1%+3 | 000004c0 20 20 20 5c 20 46 69 6e 61 6c 6c 79 20 73 75 62 | \ Finally sub| 000004d0 74 72 61 63 74 20 66 6f 75 72 74 68 20 62 79 74 |tract fourth byt| 000004e0 65 73 20 28 4d 53 42 29 0d 02 26 12 53 42 43 20 |es (MSB)..&.SBC | 000004f0 6e 75 6d 62 65 72 32 25 2b 33 0d 02 30 16 53 54 |number2%+3..0.ST| 00000500 41 20 73 75 62 74 72 61 63 74 69 6f 6e 25 2b 33 |A subtraction%+3| 00000510 0d 02 3a 05 20 0d 02 44 29 52 54 53 20 20 20 20 |..:. ..D)RTS | 00000520 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 52 | \ R| 00000530 65 74 75 72 6e 20 74 6f 20 42 41 53 49 43 0d 02 |eturn to BASIC..| 00000540 4e 05 5d 0d 02 58 05 ed 0d 02 62 0b d6 20 63 6f |N.]..X....b.. co| 00000550 64 65 25 0d 02 6c 05 f1 0d 02 76 52 f1 20 22 54 |de%..l....vR. "T| 00000560 68 65 20 73 75 6d 20 69 73 20 22 3b 21 61 64 64 |he sum is ";!add| 00000570 69 74 69 6f 6e 25 3b 20 22 20 66 72 6f 6d 20 4d |ition%; " from M| 00000580 63 6f 64 65 20 3a 20 22 3b 21 6e 75 6d 62 65 72 |code : ";!number| 00000590 31 25 2b 21 6e 75 6d 62 65 72 32 25 3b 22 20 66 |1%+!number2%;" f| 000005a0 72 6f 6d 20 42 41 53 49 43 22 0d 02 80 5c f1 20 |rom BASIC"...\. | 000005b0 22 54 68 65 20 64 69 66 66 65 72 65 6e 63 65 20 |"The difference | 000005c0 69 73 20 22 3b 21 73 75 62 74 72 61 63 74 69 6f |is ";!subtractio| 000005d0 6e 25 3b 20 22 20 66 72 6f 6d 20 4d 63 6f 64 65 |n%; " from Mcode| 000005e0 20 3a 20 22 3b 21 6e 75 6d 62 65 72 31 25 2d 21 | : ";!number1%-!| 000005f0 6e 75 6d 62 65 72 32 25 3b 22 20 66 72 6f 6d 20 |number2%;" from | 00000600 42 41 53 49 43 22 0d ff |BASIC"..| 00000608