Basic Compiler
| Jeans & Development | 電子ブロック工房 | 三日坊主 | フロントページ |
Debbuged print routine [Basic Compiler]
2007年10月16日
The print routine was debugged.

OK. Let's go to string variable and substring routines.

OK. Let's go to string variable and substring routines.
BASIC compiler [Basic Compiler]
2007年10月4日
The array routine was completed today.

Mmm...there is a bug around PRINT routine, however, putting value to array and getting value from array work well!

Mmm...there is a bug around PRINT routine, however, putting value to array and getting value from array work well!
Div routine [Basic Compiler]
2007年7月31日
Revised dividing code follows:
Previous code contains bug due to mistake about carry. SBC subtracts 1 when carry is not set and doesn't when carry is set. The result is also the same: carry is set when there is no carry over.
* = $0F40 0F40 LDA #$00 A9 00 0F42 STA $1001 8D 01 10 0F45 STA $1003 8D 03 10 0F48 LDA #$80 A9 80 0F4A STA $1000 8D 00 10 0F4D LDA #$0A A9 0A 0F4F STA $1002 8D 02 10 ;Main starts here. 0F52 LDA $1003 AD 03 10 0F55 BNE OK D0 21 0F57 LDA $1002 AD 02 10 0F5A BEQ ERROR F0 19 0F5C CMP #$01 C9 01 0F5E BNE OK D0 18 0F60 DIVIDE BY 1 0F60 LDA $1000 AD 00 10 0F63 STA $1006 8D 06 10 0F66 LDA $1001 AD 01 10 0F69 STA $1007 8D 07 10 0F6C LDA #$00 A9 00 0F6E STA $1000 8D 00 10 0F71 STA $1001 8D 01 10 0F74 RTS 60 0F75 ERROR 0F75 JMP ERROR 4C 75 0F 0F78 OK 0F78 LDA #$00 A9 00 0F7A STA $1004 8D 04 10 0F7D STA $1005 8D 05 10 0F80 STA $1006 8D 06 10 0F83 STA $1007 8D 07 10 0F86 INC $1004 EE 04 10 0F89 LOOP 0F89 CLC 18 0F8A ROL $1004 2E 04 10 0F8D ROL $1005 2E 05 10 0F90 CLC 18 0F91 ROL $1002 2E 02 10 0F94 ROL $1003 2E 03 10 0F97 BCC LOOP 90 F0 0F99 ROR $1003 6E 03 10 0F9C ROR $1002 6E 02 10 0F9F CLC 18 0FA0 ROR $1005 6E 05 10 0FA3 ROR $1004 6E 04 10 0FA6 SUB 0FA6 SEC 38 0FA7 LDA $1000 AD 00 10 0FAA SBC $1002 ED 02 10 0FAD TAX AA 0FAE LDA $1001 AD 01 10 0FB1 SBC $1003 ED 03 10 0FB4 BCC SKIP 90 19 0FB6 STA $1001 8D 01 10 0FB9 STX $1000 8E 00 10 0FBC ADD 0FBC CLC 18 0FBD LDA $1004 AD 04 10 0FC0 ADC $1006 6D 06 10 0FC3 STA $1006 8D 06 10 0FC6 LDA $1005 AD 05 10 0FC9 ADC $1007 6D 07 10 0FCC STA $1007 8D 07 10 0FCF SKIP 0FCF CLC 18 0FD0 ROR $1003 6E 03 10 0FD3 ROR $1002 6E 02 10 0FD6 CLC 18 0FD7 ROR $1005 6E 05 10 0FDA ROR $1004 6E 04 10 0FDD BCC SUB 90 C7 0FDF END 0FDF RTS 60
Previous code contains bug due to mistake about carry. SBC subtracts 1 when carry is not set and doesn't when carry is set. The result is also the same: carry is set when there is no carry over.
Math calc routine [Basic Compiler]
2007年7月10日
Mathematical calculation routines. Two input values must be put into $1000 - $1003. Note that the addresses, $1000 - $1007 are not static but dinamically set by compiler. Result will be put into X and Y resisters (X+Y*256).
Add and Sub are easy:
Mul and Dev routines are complex as follows.
Add and Sub are easy:
//16bit add CLC LDA $1000 ADC $1002 TAX LDA $1001 ADC $1003 TAY RTS //16bit sub CLC LDA $1000 SBC $1002 TAX LDA $1001 SBC $1003 TAY RTS
Mul and Dev routines are complex as follows.
Integer and string [Basic Compiler]
2007年7月4日
Integer may contain:
53(35h) + 54(36h) - 176(B0h) XX XX (2byte integer, -32768 to 32767) | 185(B9h) XX XX (2byte integer, -32768 to 32767) 38h: ( .......... 72h: ) 193(C1h): A | 218(DAh): Z C1h B0h - C1h B9h: A0 - A9 | DAh B0h _ DAh B9h: Z0-Z9 C1h 34h .... 72h : A( ..... ) ; array 46 63: PEEK( ..... 72h:) 47 63: RND( ..... 72h:) 48 63: SGN( ..... 72h:) 49 63: ABS( ..... 72h:)and
18 + 19 - 20 * 21 / 22 = 23 # 24 >= 25 > 26 <= 27 <> 28 < 29 AND 30 OR 31 MOD
Statements [Basic Compiler]
2007年7月4日
Apple Basic allows following statements in program
1 end of line
3 : (next statement)
77 CALL
78, 79 DIM
80 TAB
81 END
82-84 INPUT
85 FOR
89 NEXT
91 RETURN
92 GOSUB
93 REM
94 LET (see below)
95 GOTO
96 IF
97-99 PRINT
100 POKE
1 end of line
3 : (next statement)
77 CALL
78, 79 DIM
80 TAB
81 END
82-84 INPUT
85 FOR
89 NEXT
91 RETURN
92 GOSUB
93 REM
94 LET (see below)
95 GOTO
96 IF
97-99 PRINT
100 POKE
Hacking Apple Basic [Basic Compiler]
2007年7月4日
Making compiler is a fun for me. So I started making a basic-compiler for Apple1. First, what I need to do is to hack the Apple Basic. In 30 years old computer, the program is NEVER stored as simple text but stored as binary code.