Commit 67069412 authored by Flaxo's avatar Flaxo

added listings

parent 8abc753c
;;
;; Assembly Language for Kids - Page 006
;;
;; ACME Assembler
!to "006-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
jsr $e544 ; jump to subroutine at $E544
rts ; return to basic
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 007
3 REM
10 C = 58692 :REM DECIMAL VALUE FOR $E544
20 LB = C-INT(C/256)*256 :REM LO-BYTE
30 HB = INT(C/256) :REM HI-BYTE
40 POKE 49152,32 :REM JSR
50 POKE 49153,LB
60 POKE 49154,HB
70 POKE 49155,96 :REM RTS
;;
;; Assembly Language for Kids - Page 010
;;
;; ACME Assembler
!to "010-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
jsr $e544
rts
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 010
3 REM
10 PRINT CHR$(147)
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 014
3 REM
10 BC=53281 :REM ADDRESS OF BACKGROUND COLOR
20 LB=BC-INT(BC/256)*256 :REM LOW BYTE
30 HB=INT(BC/256) :REM HIGH BYTE
40 POKE 49152,169 :REM LDA
50 POKE 49153,0 :REM BLACK COLOR CODE
60 POKE 49154,141 :REM STA
70 POKE 49155,LB :REM LOW BYTE ADRS
80 POKE 49156,HB :REM HIGH BYTE ADRS
90 POKE 49157,96 :REM RTS
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 014
3 REM
10 PRINT CHR$(147)
20 INPUT "HIT RETURN TO SEE THE SCREEN GO BLACK";A$
30 SYS 49152
40 PRINT "NOW IT'S BLACK!"
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 017
3 REM
10 GOTO 30
20 BY {YOUR NAME}
30 POKE 2060,255 : POKE 2061,255
40 PRINT CHR$(147) : LIST
;;
;; Assembly Language for Kids - Page 022
;;
;; ACME Assembler
!to "022-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
jsr $e544
lda #$08
sta $d021
rts
;;
;; Assembly Language for Kids - Page 027
;;
;; ACME Assembler
!to "027-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
ldx #$00 ; Load X register with 0
start: txa ; Transfer X register values to ACC
sta $0400,x ; Store ACC value in $0400 indexed by X
inx ; Increment X register value
cmp #$fe ; Compare ACC value with 254
bne start ; Branch back if not equal
rts
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 049
3 REM -= TAPE MACHINE LANGUAGE LOADER =-
4 REM
10 PRINT CHR$(147)
20 INPUT "NAME OF FILE TO LOAD ";NF$
30 INPUT "ADDRESS TO LOAD";SA
40 OPEN 1,1,0,NF$
50 INPUT #1,NB
60 FOR X=SA TO SA+(NB-1)
70 INPUT #1,CD
80 POKE SA,CD
90 NEXT X
100 CLOSE 1
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 049
3 REM -= SOURCE CODE READER DISK =-
4 REM
10 PRINT CHR$(147)
20 INPUT "FILENAME ";NF$
30 NF$="0:"+NF$+",S,R"
40 OPEN 9,8,9,NF$
50 INPUT #9,A$
60 PRINT A$
70 IF ST=0 THEN 50
80 CLOSE 9
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 050
3 REM -= SOURCE CODE READER TAPE =-
4 REM
10 PRINT CHR$(147) : X=0
20 INPUT "NAME OF SOURCE FILE ";NF$ : NF$=NF$+".S"
30 OPEN 22,1,0,NF$
40 INPUT #22,A$,B$,C$
50 PRINT A$,B$,C$
60 A$="" : B$="" : C$=""
70 IF ST=0 THEN 40
80 CLOSE 22
;;
;; Assembly Language for Kids - Page 051
;;
;; background border and character colors
;; ACME Assembler
!to "051-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
JSR $E544
LDA #0
STA $D021
LDA #4
STA $D020
LDA #5
JSR $E716
RTS
;;
;; Assembly Language for Kids - Page 071
;;
;; ACME Assembler
!to "071-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
JSR $E544 ; Jumps to clear routine
LDA #144
JSR $E716 ; Jumps to screen output
LDA #65
JSR $E716
LDA #66
JSR $E716
RTS ; Returns to BASIC
;;
;; Assembly Language for Kids - Page 071
;;
;; ACME Assembler
!to "071-2.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
start: jsr $E544
lda #0 ; Color code for black
sta $D021 ; Store in background register
lda #4 ; Color code for purple
sta $D020 ; Store in border register
lda #5 ; ASCII controll code for white letters
jsr $E716 ; Output to screen
end: rts
;;
;; Assembly Language for Kids - Page 088
;;
;; ACME Assembler
!to "088-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
JSR $E544
LDA #0
STA $D021
LDA #5
STA $E716
RTS
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 098
3 REM -= HEX/DEC DEC/HEX CONVERTER =-
4 REM
10 PRINT CHR$(147)
20 INPUT "DEC OR HEX CONVERSION (D/H)Q = QUIT";C$
30 IF C$="H" THEN 200
40 IF C$="Q" THEN END
50 IF C$<>"D" THEN 20
60 HEX$="" : N=0
70 INPUT "DECIMAL VALUE";N
80 HB=INT(N/256)
90 LB=N-INT(N/256)*256
100 FOR X=1 TO 2
110 IF X=1 THEN N=HB
120 IF X=2 THEN N=LB
130 N%=INT(N/16) : GOSUB 310
140 N%=N-N%*16 : GOSUB 310
150 IF X=1 THEN H1$=HEX$ : HEX$=""
160 IF H1$="0" THEN H1$="00"
170 NEXT
180 HEX$=H1$+HEX$
190 HEX$="$"+HEX$ : PRINT "HEX="; HEX$ : PRINT : GOTO 20
200 H$="" : DE=0
210 INPUT "HEX VALUE ";H$
220 GOSUB 250
230 PRINT "DECIMAL VALUE = ";DE
240 PRINT : GOTO 20
250 REM **********************
260 REM CONVERT HEX TO DECIMAL
270 REM **********************
280 FOR L=1 TO LEN(H$) : HD=ASC(MID$(H$,L,1))
290 DE=DE*16+HD-48+((HD > 57)*7)
300 NEXT L : RETURN
310 REM **********************
320 REM CONVERT DECIMAL TO HEX
330 REM **********************
340 HEX$=HEX$+CHR$(48+N%+7*ABS(N% > 9))
350 RETURN
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 100
3 REM -= BIN/DEC CONVERTER =-
4 REM
10 PRINT CHR$(147)
20 INPUT "BINARY VALUE "; B$
30 IF LEN(B$) <> 8 THEN 20
40 FOR X=0 TO 7
50 V$ = MID$(B$, X+1, 1)
60 V = VAL(V$) : IF V<1 THEN X=7 : PRINT "BONG!" : TD=0 : BV=0 : NEXT : GOTO 20
70 P=7-X
80 IF V=1 THEN BV=2^P :REM UPWARD ARROW KEY
90 TD=TD+BV
100 BV=0
110 NEXT X
120 PRINT "DECIMAL VALUE = ";TD
130 INPUT "ANOTHER(Y/N) ";AN$
140 IF AN$="Y" THEN TD=0 : GOTO 20
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 100
3 REM -= BIN/DEC CONVERTER =-
4 REM
10 PRINT CHR$(147)
20 INPUT "BINARY VALUE "; B$
25 IF B$="Q" THEN END
30 IF LEN(B$) <> 8 THEN 20
40 FOR X=0 TO 7
50 V$ = MID$(B$, X+1, 1)
60 V = VAL(V$) :REM ORIGINAL B0RKED HERE
70 P=7-X
80 IF V=1 THEN BV=2^P :REM UPWARD ARROW KEY
90 TD=TD+BV
100 BV=0
110 NEXT X
120 PRINT "DECIMAL VALUE = ";TD
130 INPUT "ANOTHER(Y/N) ";AN$
140 IF AN$="Y" THEN TD=0 : GOTO 20
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 120
3 REM -= MINI MONITOR =-
4 REM
10 PRINT CHR$(147)
20 PRINT "BEGINNING ADDRESS OR 'RETURN' FOR NEXT"
30 INPUT "ADDRESS. PRESS 'Q' TO QUIT ";AD$
40 IF AD$="Q" THEN END
50 AD=VAL(AD$)
60 FOR K=AD TO AD+15 : N=K
70 HB=INT(N/256)
80 LB=N-INT(N/256)*256
90 FOR X=1 TO 2
100 IF X=1 THEN N=HB
110 IF X=2 THEN N=LB
120 N% = INT(N/16) : GOSUB 250
130 N% = N-N%*16 : GOSUB 250
140 IF X=1 THEN H1$=HEX$ : HEX$=""
150 IF H1$ = "0" THEN H1$ = "00"
160 NEXT
170 HEX$ = H1$+HEX$
180 HEX$ = "$"+HEX$ : PRINT HEX$;"-"; : HEX$=""
190 N = PEEK(K)
200 N% = INT(N/16) : GOSUB 250
210 N% = N-N%*16 : GOSUB 250
220 PRINT HEX$;" ";K;"-";PEEK(K) : HEX$=""
230 NEXT
240 AD$ = STR$(K) : GOTO 20
250 REM **********************
260 REM CONVERT DECIMAL TO HEX
270 REM **********************
280 HEX$ = HEX$ + CHR$(48 + N% + 7 * ABS(N% > 9))
290 RETURN
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 120
3 REM -= MINI MONITOR =-
4 REM
10 PRINT CHR$(147)
20 PRINT "BEGINNING ADDRESS OR 'RETURN' FOR NEXT"
30 INPUT "ADDRESS. PRESS 'Q' TO QUIT ";AD$
40 IF AD$="Q" THEN END
45 PRINT "HEX DEC"
50 AD=VAL(AD$)
60 FOR K=AD TO AD+15 : N=K
70 HB=INT(N/256)
80 LB=N-INT(N/256)*256
90 FOR X=1 TO 2
100 IF X=1 THEN N=HB
110 IF X=2 THEN N=LB
120 N% = INT(N/16) : GOSUB 250
130 N% = N-N%*16 : GOSUB 250
140 IF X=1 THEN H1$=HEX$ : HEX$=""
150 IF H1$ = "0" THEN H1$ = "00"
160 NEXT
170 HEX$ = H1$+HEX$
180 HEX$ = "$"+HEX$ : PRINT HEX$;"-"; : HEX$=""
190 N = PEEK(K)
200 N% = INT(N/16) : GOSUB 250
210 N% = N-N%*16 : GOSUB 250
220 PRINT HEX$;" ";K;"-";PEEK(K) : HEX$=""
230 NEXT
240 AD$ = STR$(K) : GOTO 20
250 REM **********************
260 REM CONVERT DECIMAL TO HEX
270 REM **********************
280 HEX$ = HEX$ + CHR$(48 + N% + 7 * ABS(N% > 9))
290 RETURN
;;
;; Assembly Language for Kids - Page 130
;;
;; ACME Assembler
!to "130-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
jsr $e544 ; clear screen
lda #88 ; load accumulator
jsr $e716 ; output to screen
rts
;;
;; Assembly Language for Kids - Page 131
;;
;; The following example loads different values into the
;; accumulator and prints my first name, "BILL".
;; ACME Assembler
!to "131-1-bill.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
JSR $E544
LDA #$42 ; B
JSR $E716
LDA #$49 ; I
JSR $E716
LDA #$4C ; L
JSR $E716
JSR $E716
RTS
;;
;; Assembly Language for Kids - Page 135
;;
;; The following program loads (LDA) a value into the accumulator in
;; the immediate addressing mode (#), stores the value at an unused
;; address (STA), clears the accumulator by loading it with zero, (LDA #0),
;; and then loads the accumulator from the absolute mode (LDA)
;; from the address it first stored the value. To show you what it did,
;; it prints the character for the ASCII code in the accumulator with
;; JSR $E716.
;; ACME Assembler
!to "135-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
jsr $e544 ; clear screen
lda #$43 ; ASCII 'C'
sta $c050 ; store at location $c050
lda #$00 ; load ACC with value of 0
lda $c050 ; load ACC with the value at $c050
jsr $e716 ; print value of ACC to screen
rts
;;
;; Assembly Language for Kids - Page 136
;;
;; When you use a soft-switch address to STA a value, it is the same
;; as POKEing that location in BASIC. For example, to turn your
;; background to black, you would STA the accumulator value in
;; $D021. The following little program shows you how:
;; ACME Assembler
!to "136-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
lda #$00 ; load ACC with the value 0
sta $d021 ; store at location $d021 bg-color
rts
;;
;; Assembly Language for Kids - Page 137
;;
;; Let's make a simple and practical program. In fact, let's make
;; two. One will make all your keys repeat, and the other will turn off
;; your key repeat. We'll store one program at 49152 and the other at
;; 49200. When you SYS 49152, all your keys will repeat, and when
;; you SYS 49200, the repeat will be turned off. These programs can
;; be loaded simultaneously while you program in BASIC. You might
;; want to turn on the repeat function if you're working with
;; keyboard graphics and turn it off if you're working with text. Save
;; the first program under the name ON and the second OFF.
;; ACME Assembler
!to "137-1-on.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
lda #$80
sta $028a
rts
;;
;; Assembly Language for Kids - Page 138
;;
;; Let's make a simple and practical program. In fact, let's make
;; two. One will make all your keys repeat, and the other will turn off
;; your key repeat. We'll store one program at 49152 and the other at
;; 49200. When you SYS 49152, all your keys will repeat, and when
;; you SYS 49200, the repeat will be turned off. These programs can
;; be loaded simultaneously while you program in BASIC. You might
;; want to turn on the repeat function if you're working with
;; keyboard graphics and turn it off if you're working with text. Save
;; the first program under the name ON and the second OFF.
;; ACME Assembler
!to "138-1-off.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
lda #$00
sta $028a
rts
1 REM
2 REM - ASSEMBLY LANGUAGE FOR KIDS - PAGE 139
3 REM - MULTILOADER -
4 REM
10 IF X = 0 THEN X = 1 : LOAD "137-1-ON.O",8,1
20 IF X = 1 THEN X = 2 : LOAD "138-1-OFF.O",8,1
\ No newline at end of file
;;
;; Assembly Language for Kids - Page 141
;;
;; A final place to STA values is right on your screen! Your screen
;; memory 40 x 25 matrix is located from 1024-2023 ($400-$7E7).
;; Overlaying the screen memory on the same matrix is the Color
;; Memory from 55296-56295 ($D800-$DBE7). When you store
;; a character on the screen, you also have to store a color or you
;; won't be able to see the character.
;; ACME Assembler
!to "141-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $c000
jsr $e544
lda #$00 ; load 0 into the ACC (black)
sta $d800 ; 1st color address
lda #$58 ; spade (char set 1)
sta $0400 ; 1st screen position
rts
;;
;; Assembly Language for Kids - Page 144
;;
;; Likewise the
;; PLOT subroutine at $FFF0 reads the X and Y registers to plot the
;; row and column position of the cursor. For example, if we wanted
;; to move the cursor to the middle of the screen on a 40 by 25 matrix,
;; we would want to specify a location of about 12/19. Let's see how
;; we can use the X and Y registers to output the contents of the A
;; register to the middle of the screen.
;; ACME Assembler
!to "144-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
jsr $E544
ldx #$0C ; row number 24/2
ldy #$13 ; column number 40/2
clc ; clear the carry flag to write reg
jsr $FFF0 ; plot subroutine (scrambles ACC)
lda #$58 ; load x / spade in ACC
jsr $E716 ; output to screen
rts
;;
;; Assembly Language for Kids - Page 146
;;
;; Likewise, you can transfer the Y register to the X register using the
;; TYA-TAX sequence. Let's take a look at a program that will show
;; you some work with these registers. See if you can guess what will
;; be printed on your screen before you SYS your program.
;; ACME Assembler
!to "146-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
jsr $E544 ; clear screen
ldx #$54 ; put value (84 = T) in X
txa ; transfer X register to ACC
jsr $E716 ; write ACC to screen memory
ldx #$41 ; load X with 65 (A)
txa ; transfer X register to ACC
sta $C030 ; store ACC in memory position $c030
ldy $C030 ; load value from memory $C030 into Y
tya ; transfer Y register to ACC
jsr $E716 ; write ACC to screen memory
ldy #$58 ; load Y register with 88 (X)
tya ; transfer Y register to ACC
jsr $E716 ; write ACC to screen memory
rts
;;
;; Assembly Language for Kids - Page 148
;;
;; Here, we're only going to see what happens when the INX, INY, DEX or
;; DEY in struction occurs. Basically, when an INX or INY instruction
;; is issued, +1 is added to the X or Y register. With a DEX or DEY in
;; struction, 1 is subtracted from the X or Y register. By transferring
;; the values of the X and Y registers to the accumulator and sending
;; the results to the screen, we can graphically see what happens.
;; ACME Assembler
!to "148-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
jsr $E544
ldx #$5A ; 90 =
ldy #$41 ; 65 = A
txa
jsr $E716 ; output to screen
tya
jsr $E716
dex ; decrement X register
txa
jsr $E716
iny ; increment Y register
tya
jsr $E716
rts
;;
;; Assembly Language for Kids - Page 151
;;
;; The next two assembly programs will allow you to LOAD a BASIC file
;; into memory and not destroy the contents of memory. Actually, it
;; loads the program onto the end of the program in memory. This is
;; done simply by resetting the pointers showing the beginning of the
;; BASIC program to the end of the program in memory. Then, a second
;; machine language program resets the pointers to the actual beginning
;; of BASIC thereby linking the two programs together.
;; ACME Assembler
!to "151-1-append.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
ldx $2D
dex
dex
stx $2B
ldx $2E
stx $2C
rts
;;
;; Assembly Language for Kids - Page 151
;;
;; The next two assembly programs will allow you to LOAD a BASIC file
;; into memory and not destroy the contents of memory. Actually, it
;; loads the program onto the end of the program in memory. This is
;; done simply by resetting the pointers showing the beginning of the
;; BASIC program to the end of the program in memory. Then, a second
;; machine language program resets the pointers to the actual beginning
;; of BASIC thereby linking the two programs together.
;; ACME Assembler
!to "151-1-link.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
lda #$01
sta $2B
lda #$08
sta $2C
rts
10 REM MULTI LOADER
20 IF X=0 THEN X=1 :LOAD "151-1-APPEND.O",8,1
30 IF X=1 THEN X=2 :LOAD "151-2-LINK.O",8,1
\ No newline at end of file
10 REM PART 1
20 REM LOAD FIRST
\ No newline at end of file
30 REM PART 2
40 APPENDS TO PART 1
\ No newline at end of file
;;
;; Assembly Language for Kids - Page 151
;;
;; INDEXED ABSOLUTE ADDRESSING
;; Basically, the way indexed addressing works with your programs
;; is to add the value of the X or Y register to the address in the
;; operand. For example, look at the following program:
;; ACME Assembler
!to "154-1.o", cbm ; name of output, type of assembly
!cpu 6510 ; type of cpu
* = $C000
LDX #$00
TXA
STA $0400,X ; store X register value at $0400
INX ; increment X register
TXA
STA $0400,X ; sotre X register value in $0401
;;
;; Assembly Language for Kids - Page 155
;;
;; To see how we can put this to use, let's pick a location that we can
;; see incremented. We know the screen addresses $0400 to $07E7 make up