Summary Files Commits Branches @commit @diff @stats
path: root / isprime / basic_starter.oph.s
blob: cf7c4106cf4300ffb64f42127720317c8b0846de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
; The starting address is defined by the value (label or alias) "main".
; Since in basic we need to provide a decimal string, but we store a decimal value, we need
; to do this complicated convertion.
.alias main_addr_ch1 '0 + main / 10000                         ; 65535 -> 6
.alias main_addr_ch2 '0 + [main - main / 10000 * 10000] / 1000 ; 65535 -> 65535 - 60000 = 5535 / 1000 = 5
.alias main_addr_ch3 '0 + [main - main / 1000 * 1000] / 100    ; 65535 -> 65535 - 65000 = 535 / 100 = 5
.alias main_addr_ch4 '0 + [main - main / 100 * 100] / 10       ; 65535 -> 65535 - 65500 = 35 / 10 = 3
.alias main_addr_ch5 '0 + main - main / 10 * 10                ; 65535 -> 65535 - 65530 = 5

.word $0801 ; Header -- addr 2049
.org  $0801 ; Program Counter

.scope
         .word _eop             ; Next line addr  (I guess it is used to tell how long the line is?)
         .word 10               ; 10              (line of BASIC program)
         .byte $9e," "          ; SYS 2064        (opcode for SYS and null terminated string)
         .byte main_addr_ch1,main_addr_ch2,main_addr_ch3,main_addr_ch4,main_addr_ch5,0
_eop:    .word 0                ; End of program
.scend