Upload files to "files"

This commit is contained in:
Vichingo455 2025-02-13 13:42:50 +00:00
parent 2d2fa5b1df
commit ebb09b3fd6
34 changed files with 3138 additions and 0 deletions

73
files/basmul.asm Normal file
View File

@ -0,0 +1,73 @@
; Compiled with: Z80 Simulator IDE v9.70
;
; Begin
LD IX,0FF00H
LD SP,0FEFAH
; The address of 'a' (integer) (global) is FEFEH (IX-2)
a: EQU 0FEFEH
; The address of 'b' (integer) (global) is FEFCH (IX-4)
b: EQU 0FEFCH
; The address of 'c' (integer) (global) is FEFAH (IX-6)
c: EQU 0FEFAH
; Begin of program
; 1: Dim a As Integer
LD A,00H
LD (IX-02H),A
LD (IX-01H),A
; 2: Dim b As Integer
LD A,00H
LD (IX-04H),A
LD (IX-03H),A
; 3: Dim c As Integer
LD A,00H
LD (IX-06H),A
LD (IX-05H),A
; 4:
; 5: a = 123 'First number
LD HL,007BH
LD (IX-02H),L
LD (IX-01H),H
; 6: b = 234 'Second number
LD HL,00EAH
LD (IX-04H),L
LD (IX-03H),H
; 7: c = a * b
LD L,(IX-02H)
LD H,(IX-01H)
LD E,(IX-04H)
LD D,(IX-03H)
CALL M001
LD (IX-06H),L
LD (IX-05H),H
; End of program
HALT
; Integer Multiplication Routine
M001: PUSH BC
LD B,H
LD C,L
LD HL,0000H
LD A,10H
M003: DEC D
INC D
JR NZ,M002
CP 09H
JR C,M002
SUB 08H
PUSH AF
LD D,E
LD E,H
LD H,L
LD L,00H
POP AF
JR M003
M002: ADD HL,HL
RL E
RL D
JR NC,M004
ADD HL,BC
M004: DEC A
JR NZ,M003
POP BC
RET
; End of listing
.END

7
files/basmul.bas Normal file
View File

@ -0,0 +1,7 @@
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = 123 'First number
b = 234 'Second number
c = a * b

8
files/basmul.hex Normal file
View File

@ -0,0 +1,8 @@
:10000000DD2100FF31FAFE3E00DD77FEDD77FF3EA9
:1000100000DD77FCDD77FD3E00DD77FADD77FB2143
:100020007B00DD75FEDD74FF21EA00DD75FCDD740B
:10003000FDDD6EFEDD66FFDD5EFCDD56FDCD4700BD
:10004000DD75FADD74FB76C5444D2100003E1015C8
:1000500014200FFE09380BD608F5535C652E00F10D
:0F00600018ED29CB13CB123001093D20E2C1C9A5
:00000001FF

74
files/basmul.lst Normal file
View File

@ -0,0 +1,74 @@
0001 0000 ; Compiled with: Z80 Simulator IDE v9.70
0002 0000 ;
0003 0000 ; Begin
0004 0000 DD 21 00 FF LD IX,0FF00H
0005 0004 31 FA FE LD SP,0FEFAH
0006 0007 ; The address of 'a' (integer) (global) is FEFEH (IX-2)
0007 0007 a: EQU 0FEFEH
0008 0007 ; The address of 'b' (integer) (global) is FEFCH (IX-4)
0009 0007 b: EQU 0FEFCH
0010 0007 ; The address of 'c' (integer) (global) is FEFAH (IX-6)
0011 0007 c: EQU 0FEFAH
0012 0007 ; Begin of program
0013 0007 ; 1: Dim a As Integer
0014 0007 3E 00 LD A,00H
0015 0009 DD 77 FE LD (IX-02H),A
0016 000C DD 77 FF LD (IX-01H),A
0017 000F ; 2: Dim b As Integer
0018 000F 3E 00 LD A,00H
0019 0011 DD 77 FC LD (IX-04H),A
0020 0014 DD 77 FD LD (IX-03H),A
0021 0017 ; 3: Dim c As Integer
0022 0017 3E 00 LD A,00H
0023 0019 DD 77 FA LD (IX-06H),A
0024 001C DD 77 FB LD (IX-05H),A
0025 001F ; 4:
0026 001F ; 5: a = 123 'First number
0027 001F 21 7B 00 LD HL,007BH
0028 0022 DD 75 FE LD (IX-02H),L
0029 0025 DD 74 FF LD (IX-01H),H
0030 0028 ; 6: b = 234 'Second number
0031 0028 21 EA 00 LD HL,00EAH
0032 002B DD 75 FC LD (IX-04H),L
0033 002E DD 74 FD LD (IX-03H),H
0034 0031 ; 7: c = a * b
0035 0031 DD 6E FE LD L,(IX-02H)
0036 0034 DD 66 FF LD H,(IX-01H)
0037 0037 DD 5E FC LD E,(IX-04H)
0038 003A DD 56 FD LD D,(IX-03H)
0039 003D CD 47 00 CALL M001
0040 0040 DD 75 FA LD (IX-06H),L
0041 0043 DD 74 FB LD (IX-05H),H
0042 0046 ; End of program
0043 0046 76 HALT
0044 0047 ; Integer Multiplication Routine
0045 0047 C5 M001: PUSH BC
0046 0048 44 LD B,H
0047 0049 4D LD C,L
0048 004A 21 00 00 LD HL,0000H
0049 004D 3E 10 LD A,10H
0050 004F 15 M003: DEC D
0051 0050 14 INC D
0052 0051 20 0F JR NZ,M002
0053 0053 FE 09 CP 09H
0054 0055 38 0B JR C,M002
0055 0057 D6 08 SUB 08H
0056 0059 F5 PUSH AF
0057 005A 53 LD D,E
0058 005B 5C LD E,H
0059 005C 65 LD H,L
0060 005D 2E 00 LD L,00H
0061 005F F1 POP AF
0062 0060 18 ED JR M003
0063 0062 29 M002: ADD HL,HL
0064 0063 CB 13 RL E
0065 0065 CB 12 RL D
0066 0067 30 01 JR NC,M004
0067 0069 09 ADD HL,BC
0068 006A 3D M004: DEC A
0069 006B 20 E2 JR NZ,M003
0070 006D C1 POP BC
0071 006E C9 RET
0072 006F ; End of listing
0073 006F .END
Number of errors = 0

BIN
files/basmul.obj Normal file

Binary file not shown.

900
files/basprint.asm Normal file
View File

@ -0,0 +1,900 @@
; Compiled with: Z80 Simulator IDE v9.70
;
; Begin
LD IX,0FF00H
LD SP,0FEF4H
; The address of 'a' (single) (global) is FEFCH (IX-4)
a: EQU 0FEFCH
; The address of 'b' (single) (global) is FEF8H (IX-8)
b: EQU 0FEF8H
; The address of 'c' (single) (global) is FEF4H (IX-12)
c: EQU 0FEF4H
; Begin of program
; 1: Dim a As Single
LD A,00H
LD (IX-04H),A
LD (IX-03H),A
LD (IX-02H),A
LD (IX-01H),A
; 2: Dim b As Single
LD A,00H
LD (IX-08H),A
LD (IX-07H),A
LD (IX-06H),A
LD (IX-05H),A
; 3: Dim c As Single
LD A,00H
LD (IX-0CH),A
LD (IX-0BH),A
LD (IX-0AH),A
LD (IX-09H),A
; 4:
; 5: a = 9.876543 'First number
LD BC,411EH
LD DE,0652H
LD (IX-04H),E
LD (IX-03H),D
LD (IX-02H),C
LD (IX-01H),B
; 6: b = 2.345678 'Second number
LD BC,4016H
LD DE,1F97H
LD (IX-08H),E
LD (IX-07H),D
LD (IX-06H),C
LD (IX-05H),B
; 7: c = a * b
LD E,(IX-04H)
LD D,(IX-03H)
LD C,(IX-02H)
LD B,(IX-01H)
PUSH BC
PUSH DE
LD E,(IX-08H)
LD D,(IX-07H)
LD C,(IX-06H)
LD B,(IX-05H)
CALL M201
LD (IX-0CH),E
LD (IX-0BH),D
LD (IX-0AH),C
LD (IX-09H),B
; 8:
; 9: Print 1, "Number ", a, CrLf
LD A,4EH
OUT (01H),A
LD A,75H
OUT (01H),A
LD A,6DH
OUT (01H),A
LD A,62H
OUT (01H),A
LD A,65H
OUT (01H),A
LD A,72H
OUT (01H),A
LD A,20H
OUT (01H),A
LD BC,0001H
LD (IX+01H),C
LD (IX+02H),B
LD C,07H
LD (IX+03H),C
LD E,(IX-04H)
LD D,(IX-03H)
LD C,(IX-02H)
LD B,(IX-01H)
CALL P401
LD A,0DH
OUT (01H),A
LD A,0AH
OUT (01H),A
; 10: Print 1, "multiplied by ", b, CrLf
LD A,6DH
OUT (01H),A
LD A,75H
OUT (01H),A
LD A,6CH
OUT (01H),A
LD A,74H
OUT (01H),A
LD A,69H
OUT (01H),A
LD A,70H
OUT (01H),A
LD A,6CH
OUT (01H),A
LD A,69H
OUT (01H),A
LD A,65H
OUT (01H),A
LD A,64H
OUT (01H),A
LD A,20H
OUT (01H),A
LD A,62H
OUT (01H),A
LD A,79H
OUT (01H),A
LD A,20H
OUT (01H),A
LD BC,0001H
LD (IX+01H),C
LD (IX+02H),B
LD C,07H
LD (IX+03H),C
LD E,(IX-08H)
LD D,(IX-07H)
LD C,(IX-06H)
LD B,(IX-05H)
CALL P401
LD A,0DH
OUT (01H),A
LD A,0AH
OUT (01H),A
; 11: Print 1, "equals ", c, "!", CrLf
LD A,65H
OUT (01H),A
LD A,71H
OUT (01H),A
LD A,75H
OUT (01H),A
LD A,61H
OUT (01H),A
LD A,6CH
OUT (01H),A
LD A,73H
OUT (01H),A
LD A,20H
OUT (01H),A
LD BC,0001H
LD (IX+01H),C
LD (IX+02H),B
LD C,07H
LD (IX+03H),C
LD E,(IX-0CH)
LD D,(IX-0BH)
LD C,(IX-0AH)
LD B,(IX-09H)
CALL P401
LD A,21H
OUT (01H),A
LD A,0DH
OUT (01H),A
LD A,0AH
OUT (01H),A
; End of program
HALT
; Long Division Routine
D104: XOR A
SUB E
LD E,A
LD A,00H
SBC A,D
LD D,A
LD A,00H
SBC A,C
LD C,A
LD A,00H
SBC A,B
LD B,A
RET
D102: EXX
POP HL
POP DE
POP BC
PUSH HL
EXX
PUSH HL
CALL D103
EXX
POP HL
RET
D101: EXX
POP HL
POP DE
POP BC
PUSH HL
EXX
PUSH HL
CALL D103
POP HL
RET
D103: EXX
LD A,B
EXX
XOR B
EXX
LD A,B
PUSH AF
BIT 7,B
CALL NZ,D104
EXX
BIT 7,B
CALL NZ,D104
CALL D105
POP AF
JP P,D106
LD L,A
CALL M,D104
LD A,L
D106: OR A
RET P
EXX
CALL D104
EXX
RET
D105: EXX
PUSH BC
LD B,D
LD C,E
EXX
EX DE,HL
LD D,B
LD E,C
POP BC
PUSH HL
LD HL,0000H
EXX
POP DE
LD HL,0000H
LD A,20H
OR A
D108: RL C
RL B
EXX
RL C
RL B
EXX
ADC HL,HL
EXX
ADC HL,HL
EXX
SBC HL,DE
EXX
SBC HL,DE
EXX
JR NC,D107
ADD HL,DE
EXX
ADC HL,DE
EXX
D107: CCF
DEC A
JR NZ,D108
RL C
RL B
EXX
RL C
RL B
EXX
LD D,B
LD E,C
PUSH HL
EXX
POP DE
PUSH BC
LD B,H
LD C,L
EXX
POP BC
RET
; Single Precision Subtraction Routine
S201: LD A,B
XOR 80H
LD B,A
EXX
POP HL
POP DE
POP BC
PUSH HL
EXX
PUSH HL
CALL S202
CALL S203
POP HL
RET
S202: EXX
LD L,00H
LD H,E
LD E,D
LD D,C
SET 7,D
RL C
LD A,B
ADC A,A
LD C,A
EXX
LD L,00H
LD H,E
LD E,D
LD D,C
SET 7,D
RL C
LD A,B
ADC A,A
LD C,A
LD A,C
EXX
SUB C
JR Z,S204
JR NC,S205
NEG
EXX
S205: SRL D
RR E
RR H
RR L
INC C
DEC A
JR NZ,S205
S204: LD A,B
EXX
XOR B
EXX
JP M,S206
LD A,L
EXX
ADD A,L
EXX
LD L,A
LD A,H
EXX
ADC A,H
EXX
LD H,A
LD A,E
EXX
ADC A,E
EXX
LD E,A
LD A,D
EXX
ADC A,D
EXX
LD D,A
JR NC,S207
S210: LD A,D
RR D
RR E
RR H
RR L
OR C
OR E
OR H
OR L
JR Z,S207
INC C
JR S207
S206: LD A,D
EXX
CP D
JR C,S208
JR NZ,S209
LD A,E
EXX
CP E
JR C,S208
JR NZ,S209
LD A,H
EXX
CP H
JR C,S208
JR NZ,S209
LD A,L
EXX
CP L
JR C,S208
S209: EXX
S208: LD A,L
EXX
SUB L
EXX
LD L,A
LD A,H
EXX
SBC A,H
EXX
LD H,A
LD A,E
EXX
SBC A,E
EXX
LD E,A
LD A,D
EXX
SBC A,D
EXX
LD D,A
JR C,S210
S207: RET
S203: LD A,C
OR A
JR NZ,S211
S213: LD B,A
LD E,A
LD D,A
RET
S211: BIT 7,D
JR NZ,S212
LD A,C
OR A
JR Z,S213
DEC C
SLA L
RL H
RL E
RL D
JP S211
S212: LD A,L
ADD A,80H
LD A,H
ADC A,00H
LD L,A
LD A,E
ADC A,00H
LD H,A
LD A,D
ADC A,00H
JR NC,S214
INC C
S214: ADD A,A
SRL C
RRA
LD E,A
LD A,B
AND 80H
OR C
LD D,A
LD B,D
LD C,E
EX DE,HL
RET
; Single Precision Multiplication Routine
M201: EXX
POP HL
POP DE
POP BC
PUSH HL
EXX
PUSH HL
EXX
LD L,00H
LD H,E
LD E,D
LD D,C
SET 7,D
RL C
LD A,B
ADC A,A
LD C,A
JR Z,M202
EXX
LD L,00H
LD H,E
LD E,D
LD D,C
SET 7,D
RL C
LD A,B
ADC A,A
LD C,A
JR Z,M202
CALL M203
M202: CALL M204
POP HL
RET
M203: LD A,B
EXX
XOR B
LD B,A
LD A,C
EXX
SUB 7FH
LD B,A
LD A,C
SUB 7FH
ADD A,B
JP PO,M205
EXX
LD HL,0002H
LD (0FF00H),HL
LD C,0FFH
JR NC,M206
INC C
M206: LD D,C
LD E,C
LD H,C
LD L,00H
RET
M205: ADD A,80H
EXX
LD C,A
PUSH BC
PUSH DE
LD B,H
LD C,L
EXX
POP BC
PUSH HL
EXX
POP DE
LD A,20H
M208: DEC C
INC C
JR NZ,M207
CP 09H
JR C,M207
SUB 08H
PUSH AF
EXX
LD A,C
LD C,B
LD B,00H
EXX
LD C,B
LD B,A
EXX
LD A,L
LD L,H
LD H,00H
EXX
LD L,H
LD H,A
POP AF
JR M208
M207: EXX
SRL B
RR C
EXX
RR B
RR C
JR NC,M209
ADD HL,DE
EXX
ADC HL,DE
EXX
M209: EXX
RR H
RR L
EXX
RR H
RR L
DEC A
JR NZ,M208
EXX
PUSH HL
EXX
POP DE
POP BC
RET
M204: LD A,C
OR A
JR NZ,M210
M212: LD B,A
LD E,A
LD D,A
RET
M210: BIT 7,D
JR NZ,M211
LD A,C
OR A
JR Z,M212
DEC C
SLA L
RL H
RL E
RL D
JP M210
M211: LD A,L
ADD A,80H
LD A,H
ADC A,00H
LD L,A
LD A,E
ADC A,00H
LD H,A
LD A,D
ADC A,00H
JR NC,M213
INC C
M213: ADD A,A
SRL C
RRA
LD E,A
LD A,B
AND 80H
OR C
LD D,A
LD B,D
LD C,E
EX DE,HL
RET
; Single To Long Conversion Routine
X001: PUSH HL
LD L,00H
LD H,E
LD E,D
LD D,C
SET 7,D
RL C
LD A,B
ADC A,A
LD C,A
LD A,C
SUB 7FH
JR NC,X002
X005: LD BC,0000H
LD D,C
LD E,C
JR X003
X002: NEG
ADD A,1FH
JR Z,X004
CP 20H
JR NC,X005
X006: SRL D
RR E
RR H
RR L
DEC A
JR NZ,X006
X004: BIT 7,B
LD B,D
LD C,E
EX DE,HL
JR Z,X003
CALL X007
X003: POP HL
RET
X007: XOR A
SUB E
LD E,A
LD A,00H
SBC A,D
LD D,A
LD A,00H
SBC A,C
LD C,A
LD A,00H
SBC A,B
LD B,A
RET
; Long To Single Conversion Routine
X101: PUSH HL
LD A,B
BIT 7,B
JR Z,X102
CALL X103
LD A,80H
X102: EX DE,HL
LD E,C
LD D,B
LD B,A
LD C,9EH
CALL X104
POP HL
RET
X104: LD A,C
OR A
JR NZ,X105
X107: LD B,A
LD E,A
LD D,A
RET
X105: BIT 7,D
JR NZ,X106
LD A,C
OR A
JR Z,X107
DEC C
SLA L
RL H
RL E
RL D
JP X105
X106: LD A,L
ADD A,80H
LD A,H
ADC A,00H
LD L,A
LD A,E
ADC A,00H
LD H,A
LD A,D
ADC A,00H
JR NC,X108
INC C
X108: ADD A,A
SRL C
RRA
LD E,A
LD A,B
AND 80H
OR C
LD D,A
LD B,D
LD C,E
EX DE,HL
RET
X103: XOR A
SUB E
LD E,A
LD A,00H
SBC A,D
LD D,A
LD A,00H
SBC A,C
LD C,A
LD A,00H
SBC A,B
LD B,A
RET
; Single Print Routine
P401: BIT 7,B
JR Z,P402
LD A,2DH
PUSH BC
LD C,(IX+01H)
OUT (C),A
POP BC
RES 7,B
P402: PUSH BC
RLC C
RL B
LD A,6AH
SUB B
JP P,P403
LD A,95H
SUB B
JP M,P403
JR P404
P403: LD A,45H
LD C,(IX+01H)
OUT (C),A
POP BC
JP P405
P404: POP BC
PUSH BC
PUSH DE
CALL X001
PUSH BC
PUSH DE
LD BC,000FH
LD DE,4240H
CALL D101
CALL P406
PUSH BC
PUSH DE
LD BC,0001H
LD DE,86A0H
CALL D101
CALL P406
PUSH BC
PUSH DE
LD BC,0000H
LD DE,2710H
CALL D101
CALL P406
PUSH BC
PUSH DE
LD BC,0000H
LD DE,03E8H
CALL D101
CALL P406
PUSH BC
PUSH DE
LD BC,0000H
LD DE,0064H
CALL D101
CALL P406
PUSH BC
PUSH DE
LD BC,0000H
LD DE,000AH
CALL D101
CALL P406
LD B,(IX+02H)
LD A,E
LD B,30H
ADD A,B
LD C,(IX+01H)
OUT (C),A
LD C,(IX+03H)
DEC C
JP Z,P405
LD (IX+02H),B
LD (IX+03H),C
LD A,2EH
LD C,(IX+01H)
OUT (C),A
POP DE
POP BC
RES 7,B
PUSH BC
PUSH DE
CALL X001
CALL X101
CALL S201
PUSH BC
PUSH DE
LD BC,4974H
LD DE,2400H
CALL M201
CALL X001
PUSH BC
PUSH DE
LD BC,0001H
LD DE,86A0H
CALL D101
CALL P409
JR Z,P405
EXX
PUSH BC
PUSH DE
LD BC,0000H
LD DE,2710H
CALL D101
CALL P409
JR Z,P405
EXX
PUSH BC
PUSH DE
LD BC,0000H
LD DE,03E8H
CALL D101
CALL P409
JR Z,P405
EXX
PUSH BC
PUSH DE
LD BC,0000H
LD DE,0064H
CALL D101
CALL P409
JR Z,P405
EXX
PUSH BC
PUSH DE
LD BC,0000H
LD DE,000AH
CALL D101
CALL P409
JR Z,P405
EXX
LD B,(IX+02H)
LD A,E
ADD A,B
LD C,(IX+01H)
OUT (C),A
LD C,(IX+03H)
DEC C
LD (IX+03H),C
P405:
RET
P406: LD B,(IX+02H)
LD A,E
CP 00H
JR Z,P407
LD B,30H
P407: ADD A,B
LD (IX+02H),B
JR Z,P408
LD C,(IX+01H)
OUT (C),A
LD C,(IX+03H)
DEC C
LD (IX+03H),C
P408: EXX
RET
P409: LD B,(IX+02H)
LD A,E
ADD A,B
LD C,(IX+01H)
OUT (C),A
LD C,(IX+03H)
DEC C
LD (IX+03H),C
RET
; End of listing
.END

11
files/basprint.bas Normal file
View File

@ -0,0 +1,11 @@
Dim a As Single
Dim b As Single
Dim c As Single
a = 9.876543 'First number
b = 2.345678 'Second number
c = a * b
Print 1, "Number ", a, CrLf
Print 1, "multiplied by ", b, CrLf
Print 1, "equals ", c, "!", CrLf

93
files/basprint.hex Normal file
View File

@ -0,0 +1,93 @@
:10000000DD2100FF31F4FE3E00DD77FCDD77FDDD14
:1000100077FEDD77FF3E00DD77F8DD77F9DD77FAF3
:10002000DD77FB3E00DD77F4DD77F5DD77F6DD7714
:10003000F7011E41115206DD73FCDD72FDDD71FE1C
:10004000DD70FF01164011971FDD73F8DD72F9DDD9
:1000500071FADD70FBDD5EFCDD56FDDD4EFEDD463A
:10006000FFC5D5DD5EF8DD56F9DD4EFADD46FBCD88
:10007000DB02DD73F4DD72F5DD71F6DD70F73E4E07
:10008000D3013E75D3013E6DD3013E62D3013E657F
:10009000D3013E72D3013E20D301010100DD710185
:1000A000DD70020E07DD7103DD5EFCDD56FDDD4E09
:1000B000FEDD46FFCD61043E0DD3013E0AD3013E75
:1000C0006DD3013E75D3013E6CD3013E74D3013E26
:1000D00069D3013E70D3013E6CD3013E69D3013E2A
:1000E00065D3013E64D3013E20D3013E62D3013E7D
:1000F00079D3013E20D301010100DD7101DD7002E1
:100100000E07DD7103DD5EF8DD56F9DD4EFADD46E2
:10011000FBCD61043E0DD3013E0AD3013E65D30100
:100120003E71D3013E75D3013E61D3013E6CD301D4
:100130003E73D3013E20D301010100DD7101DD706A
:10014000020E07DD7103DD5EF4DD56F5DD4EF6DDF2
:1001500046F7CD61043E21D3013E0DD3013E0AD3C3
:100160000176AF935F3E009A573E00994F3E00984C
:1001700047C9D9E1D1C1E5D9E5CD8B01D9E1C9D9CB
:10018000E1D1C1E5D9E5CD8B01E1C9D978D9A8D9AB
:1001900078F5CB78C46201D9CB78C46201CDB101C6
:1001A000F1F2A9016FFC62017DB7F0D9CD6201D9EE
:1001B000C9D9C5424BD9EB5059C1E5210000D9D16D
:1001C0002100003E20B7CB11CB10D9CB11CB10D9D9
:1001D000ED6AD9ED6AD9ED52D9ED52D9300519D968
:1001E000ED5AD93F3D20DFCB11CB10D9CB11CB102D
:1001F000D95059E5D9D1C5444DD9C1C978EE804708
:10020000D9E1D1C1E5D9E5CD0F02CDA002E1C9D92F
:100210002E00635A51CBFACB11788F4FD92E006341
:100220005A51CBFACB11788F4F79D99128113003DD
:10023000ED44D9CB3ACB1BCB1CCB1D0C3D20F47825
:10024000D9A8D9FA6E027DD985D96F7CD98CD967A6
:100250007BD98BD95F7AD98AD95730437ACB1ACBDD
:100260001BCB1CCB1DB1B3B4B528340C18317AD9D3
:10027000BA381620137BD9BB380F200C7CD9BC3878
:100280000820057DD9BD3801D97DD995D96F7CD994
:100290009CD9677BD99BD95F7AD99AD95738BDC980
:1002A00079B72004475F57C9CB7A201079B728F473
:1002B0000DCB25CB14CB13CB12C3A8027DC6807CFB
:1002C000CE006F7BCE00677ACE0030010C87CB3931
:1002D0001F5F78E680B157424BEBC9D9E1D1C1E548
:1002E000D9E5D92E00635A51CBFACB11788F4F281C
:1002F00012D92E00635A51CBFACB11788F4F2803B5
:10030000CD0803CD7B03E1C978D9A84779D9D67F39
:100310004779D67F80E22A03D92102002200FF0E0E
:10032000FF30010C5159612E00C9C680D94FC5D587
:10033000444DD9C1E5D9D13E200D0C201AFE093813
:1003400016D608F5D979480600D94847D97D6C26D4
:1003500000D96C67F118E2D9CB38CB19D9CB18CBBF
:1003600019300519D9ED5AD9D9CB1CCB1DD9CB1CC5
:10037000CB1D3D20C4D9E5D9D1C1C979B7200447E7
:100380005F57C9CB7A201079B728F40DCB25CB1451
:10039000CB13CB12C383037DC6807CCE006F7BCE94
:1003A00000677ACE0030010C87CB391F5F78E6807A
:1003B000B157424BEBC9E52E00635A51CBFACB1132
:1003C000788F4F79D67F30070100005159181FED03
:1003D00044C61F280FFE2030EFCB3ACB1BCB1CCBE3
:1003E0001D3D20F5CB78424BEB2803CDF003E1C94E
:1003F000AF935F3E009A573E00994F3E009847C921
:10040000E578CB782805CD51043E80EB5950470E56
:100410009ECD1604E1C979B72004475F57C9CB7A4E
:10042000201079B728F40DCB25CB14CB13CB12C3F6
:100430001E047DC6807CCE006F7BCE00677ACE0026
:1004400030010C87CB391F5F78E680B157424BEB08
:10045000C9AF935F3E009A573E00994F3E009847C0
:10046000C9CB78280B3E2DC5DD4E01ED79C1CBB847
:10047000C5CB01CB103E6A90F283043E9590FA837F
:1004800004180B3E45DD4E01ED79C1C38B05C1C596
:10049000D5CDB603C5D5010F00114042CD7F01CDAA
:1004A0008C05C5D501010011A086CD7F01CD8C053D
:1004B000C5D5010000111027CD7F01CD8C05C5D514
:1004C00001000011E803CD7F01CD8C05C5D50100E9
:1004D00000116400CD7F01CD8C05C5D50100001150
:1004E0000A00CD7F01CD8C05DD46027B063080DD24
:1004F0004E01ED79DD4E030DCA8B05DD7002DD7115
:10050000033E2EDD4E01ED79D1C1CBB8C5D5CDB6B8
:1005100003CD0004CDFC01C5D5017449110024CDE3
:10052000DB02CDB603C5D501010011A086CD7F0148
:10053000CDAA052856D9C5D5010000111027CD7FB9
:1005400001CDAA052845D9C5D501000011E803CD84
:100550007F01CDAA052834D9C5D50100001164005A
:10056000CD7F01CDAA052823D9C5D5010000110AE8
:1005700000CD7F01CDAA052812D9DD46027B80DDA2
:100580004E01ED79DD4E030DDD7103C9DD46027BC1
:10059000FE002802063080DD7002280CDD4E01EDE1
:1005A00079DD4E030DDD7103D9C9DD46027B80DDA7
:0C05B0004E01ED79DD4E030DDD7103C935
:00000001FF

901
files/basprint.lst Normal file
View File

@ -0,0 +1,901 @@
0001 0000 ; Compiled with: Z80 Simulator IDE v9.70
0002 0000 ;
0003 0000 ; Begin
0004 0000 DD 21 00 FF LD IX,0FF00H
0005 0004 31 F4 FE LD SP,0FEF4H
0006 0007 ; The address of 'a' (single) (global) is FEFCH (IX-4)
0007 0007 a: EQU 0FEFCH
0008 0007 ; The address of 'b' (single) (global) is FEF8H (IX-8)
0009 0007 b: EQU 0FEF8H
0010 0007 ; The address of 'c' (single) (global) is FEF4H (IX-12)
0011 0007 c: EQU 0FEF4H
0012 0007 ; Begin of program
0013 0007 ; 1: Dim a As Single
0014 0007 3E 00 LD A,00H
0015 0009 DD 77 FC LD (IX-04H),A
0016 000C DD 77 FD LD (IX-03H),A
0017 000F DD 77 FE LD (IX-02H),A
0018 0012 DD 77 FF LD (IX-01H),A
0019 0015 ; 2: Dim b As Single
0020 0015 3E 00 LD A,00H
0021 0017 DD 77 F8 LD (IX-08H),A
0022 001A DD 77 F9 LD (IX-07H),A
0023 001D DD 77 FA LD (IX-06H),A
0024 0020 DD 77 FB LD (IX-05H),A
0025 0023 ; 3: Dim c As Single
0026 0023 3E 00 LD A,00H
0027 0025 DD 77 F4 LD (IX-0CH),A
0028 0028 DD 77 F5 LD (IX-0BH),A
0029 002B DD 77 F6 LD (IX-0AH),A
0030 002E DD 77 F7 LD (IX-09H),A
0031 0031 ; 4:
0032 0031 ; 5: a = 9.876543 'First number
0033 0031 01 1E 41 LD BC,411EH
0034 0034 11 52 06 LD DE,0652H
0035 0037 DD 73 FC LD (IX-04H),E
0036 003A DD 72 FD LD (IX-03H),D
0037 003D DD 71 FE LD (IX-02H),C
0038 0040 DD 70 FF LD (IX-01H),B
0039 0043 ; 6: b = 2.345678 'Second number
0040 0043 01 16 40 LD BC,4016H
0041 0046 11 97 1F LD DE,1F97H
0042 0049 DD 73 F8 LD (IX-08H),E
0043 004C DD 72 F9 LD (IX-07H),D
0044 004F DD 71 FA LD (IX-06H),C
0045 0052 DD 70 FB LD (IX-05H),B
0046 0055 ; 7: c = a * b
0047 0055 DD 5E FC LD E,(IX-04H)
0048 0058 DD 56 FD LD D,(IX-03H)
0049 005B DD 4E FE LD C,(IX-02H)
0050 005E DD 46 FF LD B,(IX-01H)
0051 0061 C5 PUSH BC
0052 0062 D5 PUSH DE
0053 0063 DD 5E F8 LD E,(IX-08H)
0054 0066 DD 56 F9 LD D,(IX-07H)
0055 0069 DD 4E FA LD C,(IX-06H)
0056 006C DD 46 FB LD B,(IX-05H)
0057 006F CD DB 02 CALL M201
0058 0072 DD 73 F4 LD (IX-0CH),E
0059 0075 DD 72 F5 LD (IX-0BH),D
0060 0078 DD 71 F6 LD (IX-0AH),C
0061 007B DD 70 F7 LD (IX-09H),B
0062 007E ; 8:
0063 007E ; 9: Print 1, "Number ", a, CrLf
0064 007E 3E 4E LD A,4EH
0065 0080 D3 01 OUT (01H),A
0066 0082 3E 75 LD A,75H
0067 0084 D3 01 OUT (01H),A
0068 0086 3E 6D LD A,6DH
0069 0088 D3 01 OUT (01H),A
0070 008A 3E 62 LD A,62H
0071 008C D3 01 OUT (01H),A
0072 008E 3E 65 LD A,65H
0073 0090 D3 01 OUT (01H),A
0074 0092 3E 72 LD A,72H
0075 0094 D3 01 OUT (01H),A
0076 0096 3E 20 LD A,20H
0077 0098 D3 01 OUT (01H),A
0078 009A 01 01 00 LD BC,0001H
0079 009D DD 71 01 LD (IX+01H),C
0080 00A0 DD 70 02 LD (IX+02H),B
0081 00A3 0E 07 LD C,07H
0082 00A5 DD 71 03 LD (IX+03H),C
0083 00A8 DD 5E FC LD E,(IX-04H)
0084 00AB DD 56 FD LD D,(IX-03H)
0085 00AE DD 4E FE LD C,(IX-02H)
0086 00B1 DD 46 FF LD B,(IX-01H)
0087 00B4 CD 61 04 CALL P401
0088 00B7 3E 0D LD A,0DH
0089 00B9 D3 01 OUT (01H),A
0090 00BB 3E 0A LD A,0AH
0091 00BD D3 01 OUT (01H),A
0092 00BF ; 10: Print 1, "multiplied by ", b, CrLf
0093 00BF 3E 6D LD A,6DH
0094 00C1 D3 01 OUT (01H),A
0095 00C3 3E 75 LD A,75H
0096 00C5 D3 01 OUT (01H),A
0097 00C7 3E 6C LD A,6CH
0098 00C9 D3 01 OUT (01H),A
0099 00CB 3E 74 LD A,74H
0100 00CD D3 01 OUT (01H),A
0101 00CF 3E 69 LD A,69H
0102 00D1 D3 01 OUT (01H),A
0103 00D3 3E 70 LD A,70H
0104 00D5 D3 01 OUT (01H),A
0105 00D7 3E 6C LD A,6CH
0106 00D9 D3 01 OUT (01H),A
0107 00DB 3E 69 LD A,69H
0108 00DD D3 01 OUT (01H),A
0109 00DF 3E 65 LD A,65H
0110 00E1 D3 01 OUT (01H),A
0111 00E3 3E 64 LD A,64H
0112 00E5 D3 01 OUT (01H),A
0113 00E7 3E 20 LD A,20H
0114 00E9 D3 01 OUT (01H),A
0115 00EB 3E 62 LD A,62H
0116 00ED D3 01 OUT (01H),A
0117 00EF 3E 79 LD A,79H
0118 00F1 D3 01 OUT (01H),A
0119 00F3 3E 20 LD A,20H
0120 00F5 D3 01 OUT (01H),A
0121 00F7 01 01 00 LD BC,0001H
0122 00FA DD 71 01 LD (IX+01H),C
0123 00FD DD 70 02 LD (IX+02H),B
0124 0100 0E 07 LD C,07H
0125 0102 DD 71 03 LD (IX+03H),C
0126 0105 DD 5E F8 LD E,(IX-08H)
0127 0108 DD 56 F9 LD D,(IX-07H)
0128 010B DD 4E FA LD C,(IX-06H)
0129 010E DD 46 FB LD B,(IX-05H)
0130 0111 CD 61 04 CALL P401
0131 0114 3E 0D LD A,0DH
0132 0116 D3 01 OUT (01H),A
0133 0118 3E 0A LD A,0AH
0134 011A D3 01 OUT (01H),A
0135 011C ; 11: Print 1, "equals ", c, "!", CrLf
0136 011C 3E 65 LD A,65H
0137 011E D3 01 OUT (01H),A
0138 0120 3E 71 LD A,71H
0139 0122 D3 01 OUT (01H),A
0140 0124 3E 75 LD A,75H
0141 0126 D3 01 OUT (01H),A
0142 0128 3E 61 LD A,61H
0143 012A D3 01 OUT (01H),A
0144 012C 3E 6C LD A,6CH
0145 012E D3 01 OUT (01H),A
0146 0130 3E 73 LD A,73H
0147 0132 D3 01 OUT (01H),A
0148 0134 3E 20 LD A,20H
0149 0136 D3 01 OUT (01H),A
0150 0138 01 01 00 LD BC,0001H
0151 013B DD 71 01 LD (IX+01H),C
0152 013E DD 70 02 LD (IX+02H),B
0153 0141 0E 07 LD C,07H
0154 0143 DD 71 03 LD (IX+03H),C
0155 0146 DD 5E F4 LD E,(IX-0CH)
0156 0149 DD 56 F5 LD D,(IX-0BH)
0157 014C DD 4E F6 LD C,(IX-0AH)
0158 014F DD 46 F7 LD B,(IX-09H)
0159 0152 CD 61 04 CALL P401
0160 0155 3E 21 LD A,21H
0161 0157 D3 01 OUT (01H),A
0162 0159 3E 0D LD A,0DH
0163 015B D3 01 OUT (01H),A
0164 015D 3E 0A LD A,0AH
0165 015F D3 01 OUT (01H),A
0166 0161 ; End of program
0167 0161 76 HALT
0168 0162 ; Long Division Routine
0169 0162 AF D104: XOR A
0170 0163 93 SUB E
0171 0164 5F LD E,A
0172 0165 3E 00 LD A,00H
0173 0167 9A SBC A,D
0174 0168 57 LD D,A
0175 0169 3E 00 LD A,00H
0176 016B 99 SBC A,C
0177 016C 4F LD C,A
0178 016D 3E 00 LD A,00H
0179 016F 98 SBC A,B
0180 0170 47 LD B,A
0181 0171 C9 RET
0182 0172 D9 D102: EXX
0183 0173 E1 POP HL
0184 0174 D1 POP DE
0185 0175 C1 POP BC
0186 0176 E5 PUSH HL
0187 0177 D9 EXX
0188 0178 E5 PUSH HL
0189 0179 CD 8B 01 CALL D103
0190 017C D9 EXX
0191 017D E1 POP HL
0192 017E C9 RET
0193 017F D9 D101: EXX
0194 0180 E1 POP HL
0195 0181 D1 POP DE
0196 0182 C1 POP BC
0197 0183 E5 PUSH HL
0198 0184 D9 EXX
0199 0185 E5 PUSH HL
0200 0186 CD 8B 01 CALL D103
0201 0189 E1 POP HL
0202 018A C9 RET
0203 018B D9 D103: EXX
0204 018C 78 LD A,B
0205 018D D9 EXX
0206 018E A8 XOR B
0207 018F D9 EXX
0208 0190 78 LD A,B
0209 0191 F5 PUSH AF
0210 0192 CB 78 BIT 7,B
0211 0194 C4 62 01 CALL NZ,D104
0212 0197 D9 EXX
0213 0198 CB 78 BIT 7,B
0214 019A C4 62 01 CALL NZ,D104
0215 019D CD B1 01 CALL D105
0216 01A0 F1 POP AF
0217 01A1 F2 A9 01 JP P,D106
0218 01A4 6F LD L,A
0219 01A5 FC 62 01 CALL M,D104
0220 01A8 7D LD A,L
0221 01A9 B7 D106: OR A
0222 01AA F0 RET P
0223 01AB D9 EXX
0224 01AC CD 62 01 CALL D104
0225 01AF D9 EXX
0226 01B0 C9 RET
0227 01B1 D9 D105: EXX
0228 01B2 C5 PUSH BC
0229 01B3 42 LD B,D
0230 01B4 4B LD C,E
0231 01B5 D9 EXX
0232 01B6 EB EX DE,HL
0233 01B7 50 LD D,B
0234 01B8 59 LD E,C
0235 01B9 C1 POP BC
0236 01BA E5 PUSH HL
0237 01BB 21 00 00 LD HL,0000H
0238 01BE D9 EXX
0239 01BF D1 POP DE
0240 01C0 21 00 00 LD HL,0000H
0241 01C3 3E 20 LD A,20H
0242 01C5 B7 OR A
0243 01C6 CB 11 D108: RL C
0244 01C8 CB 10 RL B
0245 01CA D9 EXX
0246 01CB CB 11 RL C
0247 01CD CB 10 RL B
0248 01CF D9 EXX
0249 01D0 ED 6A ADC HL,HL
0250 01D2 D9 EXX
0251 01D3 ED 6A ADC HL,HL
0252 01D5 D9 EXX
0253 01D6 ED 52 SBC HL,DE
0254 01D8 D9 EXX
0255 01D9 ED 52 SBC HL,DE
0256 01DB D9 EXX
0257 01DC 30 05 JR NC,D107
0258 01DE 19 ADD HL,DE
0259 01DF D9 EXX
0260 01E0 ED 5A ADC HL,DE
0261 01E2 D9 EXX
0262 01E3 3F D107: CCF
0263 01E4 3D DEC A
0264 01E5 20 DF JR NZ,D108
0265 01E7 CB 11 RL C
0266 01E9 CB 10 RL B
0267 01EB D9 EXX
0268 01EC CB 11 RL C
0269 01EE CB 10 RL B
0270 01F0 D9 EXX
0271 01F1 50 LD D,B
0272 01F2 59 LD E,C
0273 01F3 E5 PUSH HL
0274 01F4 D9 EXX
0275 01F5 D1 POP DE
0276 01F6 C5 PUSH BC
0277 01F7 44 LD B,H
0278 01F8 4D LD C,L
0279 01F9 D9 EXX
0280 01FA C1 POP BC
0281 01FB C9 RET
0282 01FC ; Single Precision Subtraction Routine
0283 01FC 78 S201: LD A,B
0284 01FD EE 80 XOR 80H
0285 01FF 47 LD B,A
0286 0200 D9 EXX
0287 0201 E1 POP HL
0288 0202 D1 POP DE
0289 0203 C1 POP BC
0290 0204 E5 PUSH HL
0291 0205 D9 EXX
0292 0206 E5 PUSH HL
0293 0207 CD 0F 02 CALL S202
0294 020A CD A0 02 CALL S203
0295 020D E1 POP HL
0296 020E C9 RET
0297 020F D9 S202: EXX
0298 0210 2E 00 LD L,00H
0299 0212 63 LD H,E
0300 0213 5A LD E,D
0301 0214 51 LD D,C
0302 0215 CB FA SET 7,D
0303 0217 CB 11 RL C
0304 0219 78 LD A,B
0305 021A 8F ADC A,A
0306 021B 4F LD C,A
0307 021C D9 EXX
0308 021D 2E 00 LD L,00H
0309 021F 63 LD H,E
0310 0220 5A LD E,D
0311 0221 51 LD D,C
0312 0222 CB FA SET 7,D
0313 0224 CB 11 RL C
0314 0226 78 LD A,B
0315 0227 8F ADC A,A
0316 0228 4F LD C,A
0317 0229 79 LD A,C
0318 022A D9 EXX
0319 022B 91 SUB C
0320 022C 28 11 JR Z,S204
0321 022E 30 03 JR NC,S205
0322 0230 ED 44 NEG
0323 0232 D9 EXX
0324 0233 CB 3A S205: SRL D
0325 0235 CB 1B RR E
0326 0237 CB 1C RR H
0327 0239 CB 1D RR L
0328 023B 0C INC C
0329 023C 3D DEC A
0330 023D 20 F4 JR NZ,S205
0331 023F 78 S204: LD A,B
0332 0240 D9 EXX
0333 0241 A8 XOR B
0334 0242 D9 EXX
0335 0243 FA 6E 02 JP M,S206
0336 0246 7D LD A,L
0337 0247 D9 EXX
0338 0248 85 ADD A,L
0339 0249 D9 EXX
0340 024A 6F LD L,A
0341 024B 7C LD A,H
0342 024C D9 EXX
0343 024D 8C ADC A,H
0344 024E D9 EXX
0345 024F 67 LD H,A
0346 0250 7B LD A,E
0347 0251 D9 EXX
0348 0252 8B ADC A,E
0349 0253 D9 EXX
0350 0254 5F LD E,A
0351 0255 7A LD A,D
0352 0256 D9 EXX
0353 0257 8A ADC A,D
0354 0258 D9 EXX
0355 0259 57 LD D,A
0356 025A 30 43 JR NC,S207
0357 025C 7A S210: LD A,D
0358 025D CB 1A RR D
0359 025F CB 1B RR E
0360 0261 CB 1C RR H
0361 0263 CB 1D RR L
0362 0265 B1 OR C
0363 0266 B3 OR E
0364 0267 B4 OR H
0365 0268 B5 OR L
0366 0269 28 34 JR Z,S207
0367 026B 0C INC C
0368 026C 18 31 JR S207
0369 026E 7A S206: LD A,D
0370 026F D9 EXX
0371 0270 BA CP D
0372 0271 38 16 JR C,S208
0373 0273 20 13 JR NZ,S209
0374 0275 7B LD A,E
0375 0276 D9 EXX
0376 0277 BB CP E
0377 0278 38 0F JR C,S208
0378 027A 20 0C JR NZ,S209
0379 027C 7C LD A,H
0380 027D D9 EXX
0381 027E BC CP H
0382 027F 38 08 JR C,S208
0383 0281 20 05 JR NZ,S209
0384 0283 7D LD A,L
0385 0284 D9 EXX
0386 0285 BD CP L
0387 0286 38 01 JR C,S208
0388 0288 D9 S209: EXX
0389 0289 7D S208: LD A,L
0390 028A D9 EXX
0391 028B 95 SUB L
0392 028C D9 EXX
0393 028D 6F LD L,A
0394 028E 7C LD A,H
0395 028F D9 EXX
0396 0290 9C SBC A,H
0397 0291 D9 EXX
0398 0292 67 LD H,A
0399 0293 7B LD A,E
0400 0294 D9 EXX
0401 0295 9B SBC A,E
0402 0296 D9 EXX
0403 0297 5F LD E,A
0404 0298 7A LD A,D
0405 0299 D9 EXX
0406 029A 9A SBC A,D
0407 029B D9 EXX
0408 029C 57 LD D,A
0409 029D 38 BD JR C,S210
0410 029F C9 S207: RET
0411 02A0 79 S203: LD A,C
0412 02A1 B7 OR A
0413 02A2 20 04 JR NZ,S211
0414 02A4 47 S213: LD B,A
0415 02A5 5F LD E,A
0416 02A6 57 LD D,A
0417 02A7 C9 RET
0418 02A8 CB 7A S211: BIT 7,D
0419 02AA 20 10 JR NZ,S212
0420 02AC 79 LD A,C
0421 02AD B7 OR A
0422 02AE 28 F4 JR Z,S213
0423 02B0 0D DEC C
0424 02B1 CB 25 SLA L
0425 02B3 CB 14 RL H
0426 02B5 CB 13 RL E
0427 02B7 CB 12 RL D
0428 02B9 C3 A8 02 JP S211
0429 02BC 7D S212: LD A,L
0430 02BD C6 80 ADD A,80H
0431 02BF 7C LD A,H
0432 02C0 CE 00 ADC A,00H
0433 02C2 6F LD L,A
0434 02C3 7B LD A,E
0435 02C4 CE 00 ADC A,00H
0436 02C6 67 LD H,A
0437 02C7 7A LD A,D
0438 02C8 CE 00 ADC A,00H
0439 02CA 30 01 JR NC,S214
0440 02CC 0C INC C
0441 02CD 87 S214: ADD A,A
0442 02CE CB 39 SRL C
0443 02D0 1F RRA
0444 02D1 5F LD E,A
0445 02D2 78 LD A,B
0446 02D3 E6 80 AND 80H
0447 02D5 B1 OR C
0448 02D6 57 LD D,A
0449 02D7 42 LD B,D
0450 02D8 4B LD C,E
0451 02D9 EB EX DE,HL
0452 02DA C9 RET
0453 02DB ; Single Precision Multiplication Routine
0454 02DB D9 M201: EXX
0455 02DC E1 POP HL
0456 02DD D1 POP DE
0457 02DE C1 POP BC
0458 02DF E5 PUSH HL
0459 02E0 D9 EXX
0460 02E1 E5 PUSH HL
0461 02E2 D9 EXX
0462 02E3 2E 00 LD L,00H
0463 02E5 63 LD H,E
0464 02E6 5A LD E,D
0465 02E7 51 LD D,C
0466 02E8 CB FA SET 7,D
0467 02EA CB 11 RL C
0468 02EC 78 LD A,B
0469 02ED 8F ADC A,A
0470 02EE 4F LD C,A
0471 02EF 28 12 JR Z,M202
0472 02F1 D9 EXX
0473 02F2 2E 00 LD L,00H
0474 02F4 63 LD H,E
0475 02F5 5A LD E,D
0476 02F6 51 LD D,C
0477 02F7 CB FA SET 7,D
0478 02F9 CB 11 RL C
0479 02FB 78 LD A,B
0480 02FC 8F ADC A,A
0481 02FD 4F LD C,A
0482 02FE 28 03 JR Z,M202
0483 0300 CD 08 03 CALL M203
0484 0303 CD 7B 03 M202: CALL M204
0485 0306 E1 POP HL
0486 0307 C9 RET
0487 0308 78 M203: LD A,B
0488 0309 D9 EXX
0489 030A A8 XOR B
0490 030B 47 LD B,A
0491 030C 79 LD A,C
0492 030D D9 EXX
0493 030E D6 7F SUB 7FH
0494 0310 47 LD B,A
0495 0311 79 LD A,C
0496 0312 D6 7F SUB 7FH
0497 0314 80 ADD A,B
0498 0315 E2 2A 03 JP PO,M205
0499 0318 D9 EXX
0500 0319 21 02 00 LD HL,0002H
0501 031C 22 00 FF LD (0FF00H),HL
0502 031F 0E FF LD C,0FFH
0503 0321 30 01 JR NC,M206
0504 0323 0C INC C
0505 0324 51 M206: LD D,C
0506 0325 59 LD E,C
0507 0326 61 LD H,C
0508 0327 2E 00 LD L,00H
0509 0329 C9 RET
0510 032A C6 80 M205: ADD A,80H
0511 032C D9 EXX
0512 032D 4F LD C,A
0513 032E C5 PUSH BC
0514 032F D5 PUSH DE
0515 0330 44 LD B,H
0516 0331 4D LD C,L
0517 0332 D9 EXX
0518 0333 C1 POP BC
0519 0334 E5 PUSH HL
0520 0335 D9 EXX
0521 0336 D1 POP DE
0522 0337 3E 20 LD A,20H
0523 0339 0D M208: DEC C
0524 033A 0C INC C
0525 033B 20 1A JR NZ,M207
0526 033D FE 09 CP 09H
0527 033F 38 16 JR C,M207
0528 0341 D6 08 SUB 08H
0529 0343 F5 PUSH AF
0530 0344 D9 EXX
0531 0345 79 LD A,C
0532 0346 48 LD C,B
0533 0347 06 00 LD B,00H
0534 0349 D9 EXX
0535 034A 48 LD C,B
0536 034B 47 LD B,A
0537 034C D9 EXX
0538 034D 7D LD A,L
0539 034E 6C LD L,H
0540 034F 26 00 LD H,00H
0541 0351 D9 EXX
0542 0352 6C LD L,H
0543 0353 67 LD H,A
0544 0354 F1 POP AF
0545 0355 18 E2 JR M208
0546 0357 D9 M207: EXX
0547 0358 CB 38 SRL B
0548 035A CB 19 RR C
0549 035C D9 EXX
0550 035D CB 18 RR B
0551 035F CB 19 RR C
0552 0361 30 05 JR NC,M209
0553 0363 19 ADD HL,DE
0554 0364 D9 EXX
0555 0365 ED 5A ADC HL,DE
0556 0367 D9 EXX
0557 0368 D9 M209: EXX
0558 0369 CB 1C RR H
0559 036B CB 1D RR L
0560 036D D9 EXX
0561 036E CB 1C RR H
0562 0370 CB 1D RR L
0563 0372 3D DEC A
0564 0373 20 C4 JR NZ,M208
0565 0375 D9 EXX
0566 0376 E5 PUSH HL
0567 0377 D9 EXX
0568 0378 D1 POP DE
0569 0379 C1 POP BC
0570 037A C9 RET
0571 037B 79 M204: LD A,C
0572 037C B7 OR A
0573 037D 20 04 JR NZ,M210
0574 037F 47 M212: LD B,A
0575 0380 5F LD E,A
0576 0381 57 LD D,A
0577 0382 C9 RET
0578 0383 CB 7A M210: BIT 7,D
0579 0385 20 10 JR NZ,M211
0580 0387 79 LD A,C
0581 0388 B7 OR A
0582 0389 28 F4 JR Z,M212
0583 038B 0D DEC C
0584 038C CB 25 SLA L
0585 038E CB 14 RL H
0586 0390 CB 13 RL E
0587 0392 CB 12 RL D
0588 0394 C3 83 03 JP M210
0589 0397 7D M211: LD A,L
0590 0398 C6 80 ADD A,80H
0591 039A 7C LD A,H
0592 039B CE 00 ADC A,00H
0593 039D 6F LD L,A
0594 039E 7B LD A,E
0595 039F CE 00 ADC A,00H
0596 03A1 67 LD H,A
0597 03A2 7A LD A,D
0598 03A3 CE 00 ADC A,00H
0599 03A5 30 01 JR NC,M213
0600 03A7 0C INC C
0601 03A8 87 M213: ADD A,A
0602 03A9 CB 39 SRL C
0603 03AB 1F RRA
0604 03AC 5F LD E,A
0605 03AD 78 LD A,B
0606 03AE E6 80 AND 80H
0607 03B0 B1 OR C
0608 03B1 57 LD D,A
0609 03B2 42 LD B,D
0610 03B3 4B LD C,E
0611 03B4 EB EX DE,HL
0612 03B5 C9 RET
0613 03B6 ; Single To Long Conversion Routine
0614 03B6 E5 X001: PUSH HL
0615 03B7 2E 00 LD L,00H
0616 03B9 63 LD H,E
0617 03BA 5A LD E,D
0618 03BB 51 LD D,C
0619 03BC CB FA SET 7,D
0620 03BE CB 11 RL C
0621 03C0 78 LD A,B
0622 03C1 8F ADC A,A
0623 03C2 4F LD C,A
0624 03C3 79 LD A,C
0625 03C4 D6 7F SUB 7FH
0626 03C6 30 07 JR NC,X002
0627 03C8 01 00 00 X005: LD BC,0000H
0628 03CB 51 LD D,C
0629 03CC 59 LD E,C
0630 03CD 18 1F JR X003
0631 03CF ED 44 X002: NEG
0632 03D1 C6 1F ADD A,1FH
0633 03D3 28 0F JR Z,X004
0634 03D5 FE 20 CP 20H
0635 03D7 30 EF JR NC,X005
0636 03D9 CB 3A X006: SRL D
0637 03DB CB 1B RR E
0638 03DD CB 1C RR H
0639 03DF CB 1D RR L
0640 03E1 3D DEC A
0641 03E2 20 F5 JR NZ,X006
0642 03E4 CB 78 X004: BIT 7,B
0643 03E6 42 LD B,D
0644 03E7 4B LD C,E
0645 03E8 EB EX DE,HL
0646 03E9 28 03 JR Z,X003
0647 03EB CD F0 03 CALL X007
0648 03EE E1 X003: POP HL
0649 03EF C9 RET
0650 03F0 AF X007: XOR A
0651 03F1 93 SUB E
0652 03F2 5F LD E,A
0653 03F3 3E 00 LD A,00H
0654 03F5 9A SBC A,D
0655 03F6 57 LD D,A
0656 03F7 3E 00 LD A,00H
0657 03F9 99 SBC A,C
0658 03FA 4F LD C,A
0659 03FB 3E 00 LD A,00H
0660 03FD 98 SBC A,B
0661 03FE 47 LD B,A
0662 03FF C9 RET
0663 0400 ; Long To Single Conversion Routine
0664 0400 E5 X101: PUSH HL
0665 0401 78 LD A,B
0666 0402 CB 78 BIT 7,B
0667 0404 28 05 JR Z,X102
0668 0406 CD 51 04 CALL X103
0669 0409 3E 80 LD A,80H
0670 040B EB X102: EX DE,HL
0671 040C 59 LD E,C
0672 040D 50 LD D,B
0673 040E 47 LD B,A
0674 040F 0E 9E LD C,9EH
0675 0411 CD 16 04 CALL X104
0676 0414 E1 POP HL
0677 0415 C9 RET
0678 0416 79 X104: LD A,C
0679 0417 B7 OR A
0680 0418 20 04 JR NZ,X105
0681 041A 47 X107: LD B,A
0682 041B 5F LD E,A
0683 041C 57 LD D,A
0684 041D C9 RET
0685 041E CB 7A X105: BIT 7,D
0686 0420 20 10 JR NZ,X106
0687 0422 79 LD A,C
0688 0423 B7 OR A
0689 0424 28 F4 JR Z,X107
0690 0426 0D DEC C
0691 0427 CB 25 SLA L
0692 0429 CB 14 RL H
0693 042B CB 13 RL E
0694 042D CB 12 RL D
0695 042F C3 1E 04 JP X105
0696 0432 7D X106: LD A,L
0697 0433 C6 80 ADD A,80H
0698 0435 7C LD A,H
0699 0436 CE 00 ADC A,00H
0700 0438 6F LD L,A
0701 0439 7B LD A,E
0702 043A CE 00 ADC A,00H
0703 043C 67 LD H,A
0704 043D 7A LD A,D
0705 043E CE 00 ADC A,00H
0706 0440 30 01 JR NC,X108
0707 0442 0C INC C
0708 0443 87 X108: ADD A,A
0709 0444 CB 39 SRL C
0710 0446 1F RRA
0711 0447 5F LD E,A
0712 0448 78 LD A,B
0713 0449 E6 80 AND 80H
0714 044B B1 OR C
0715 044C 57 LD D,A
0716 044D 42 LD B,D
0717 044E 4B LD C,E
0718 044F EB EX DE,HL
0719 0450 C9 RET
0720 0451 AF X103: XOR A
0721 0452 93 SUB E
0722 0453 5F LD E,A
0723 0454 3E 00 LD A,00H
0724 0456 9A SBC A,D
0725 0457 57 LD D,A
0726 0458 3E 00 LD A,00H
0727 045A 99 SBC A,C
0728 045B 4F LD C,A
0729 045C 3E 00 LD A,00H
0730 045E 98 SBC A,B
0731 045F 47 LD B,A
0732 0460 C9 RET
0733 0461 ; Single Print Routine
0734 0461 CB 78 P401: BIT 7,B
0735 0463 28 0B JR Z,P402
0736 0465 3E 2D LD A,2DH
0737 0467 C5 PUSH BC
0738 0468 DD 4E 01 LD C,(IX+01H)
0739 046B ED 79 OUT (C),A
0740 046D C1 POP BC
0741 046E CB B8 RES 7,B
0742 0470 C5 P402: PUSH BC
0743 0471 CB 01 RLC C
0744 0473 CB 10 RL B
0745 0475 3E 6A LD A,6AH
0746 0477 90 SUB B
0747 0478 F2 83 04 JP P,P403
0748 047B 3E 95 LD A,95H
0749 047D 90 SUB B
0750 047E FA 83 04 JP M,P403
0751 0481 18 0B JR P404
0752 0483 3E 45 P403: LD A,45H
0753 0485 DD 4E 01 LD C,(IX+01H)
0754 0488 ED 79 OUT (C),A
0755 048A C1 POP BC
0756 048B C3 8B 05 JP P405
0757 048E C1 P404: POP BC
0758 048F C5 PUSH BC
0759 0490 D5 PUSH DE
0760 0491 CD B6 03 CALL X001
0761 0494 C5 PUSH BC
0762 0495 D5 PUSH DE
0763 0496 01 0F 00 LD BC,000FH
0764 0499 11 40 42 LD DE,4240H
0765 049C CD 7F 01 CALL D101
0766 049F CD 8C 05 CALL P406
0767 04A2 C5 PUSH BC
0768 04A3 D5 PUSH DE
0769 04A4 01 01 00 LD BC,0001H
0770 04A7 11 A0 86 LD DE,86A0H
0771 04AA CD 7F 01 CALL D101
0772 04AD CD 8C 05 CALL P406
0773 04B0 C5 PUSH BC
0774 04B1 D5 PUSH DE
0775 04B2 01 00 00 LD BC,0000H
0776 04B5 11 10 27 LD DE,2710H
0777 04B8 CD 7F 01 CALL D101
0778 04BB CD 8C 05 CALL P406
0779 04BE C5 PUSH BC
0780 04BF D5 PUSH DE
0781 04C0 01 00 00 LD BC,0000H
0782 04C3 11 E8 03 LD DE,03E8H
0783 04C6 CD 7F 01 CALL D101
0784 04C9 CD 8C 05 CALL P406
0785 04CC C5 PUSH BC
0786 04CD D5 PUSH DE
0787 04CE 01 00 00 LD BC,0000H
0788 04D1 11 64 00 LD DE,0064H
0789 04D4 CD 7F 01 CALL D101
0790 04D7 CD 8C 05 CALL P406
0791 04DA C5 PUSH BC
0792 04DB D5 PUSH DE
0793 04DC 01 00 00 LD BC,0000H
0794 04DF 11 0A 00 LD DE,000AH
0795 04E2 CD 7F 01 CALL D101
0796 04E5 CD 8C 05 CALL P406
0797 04E8 DD 46 02 LD B,(IX+02H)
0798 04EB 7B LD A,E
0799 04EC 06 30 LD B,30H
0800 04EE 80 ADD A,B
0801 04EF DD 4E 01 LD C,(IX+01H)
0802 04F2 ED 79 OUT (C),A
0803 04F4 DD 4E 03 LD C,(IX+03H)
0804 04F7 0D DEC C
0805 04F8 CA 8B 05 JP Z,P405
0806 04FB DD 70 02 LD (IX+02H),B
0807 04FE DD 71 03 LD (IX+03H),C
0808 0501 3E 2E LD A,2EH
0809 0503 DD 4E 01 LD C,(IX+01H)
0810 0506 ED 79 OUT (C),A
0811 0508 D1 POP DE
0812 0509 C1 POP BC
0813 050A CB B8 RES 7,B
0814 050C C5 PUSH BC
0815 050D D5 PUSH DE
0816 050E CD B6 03 CALL X001
0817 0511 CD 00 04 CALL X101
0818 0514 CD FC 01 CALL S201
0819 0517 C5 PUSH BC
0820 0518 D5 PUSH DE
0821 0519 01 74 49 LD BC,4974H
0822 051C 11 00 24 LD DE,2400H
0823 051F CD DB 02 CALL M201
0824 0522 CD B6 03 CALL X001
0825 0525 C5 PUSH BC
0826 0526 D5 PUSH DE
0827 0527 01 01 00 LD BC,0001H
0828 052A 11 A0 86 LD DE,86A0H
0829 052D CD 7F 01 CALL D101
0830 0530 CD AA 05 CALL P409
0831 0533 28 56 JR Z,P405
0832 0535 D9 EXX
0833 0536 C5 PUSH BC
0834 0537 D5 PUSH DE
0835 0538 01 00 00 LD BC,0000H
0836 053B 11 10 27 LD DE,2710H
0837 053E CD 7F 01 CALL D101
0838 0541 CD AA 05 CALL P409
0839 0544 28 45 JR Z,P405
0840 0546 D9 EXX
0841 0547 C5 PUSH BC
0842 0548 D5 PUSH DE
0843 0549 01 00 00 LD BC,0000H
0844 054C 11 E8 03 LD DE,03E8H
0845 054F CD 7F 01 CALL D101
0846 0552 CD AA 05 CALL P409
0847 0555 28 34 JR Z,P405
0848 0557 D9 EXX
0849 0558 C5 PUSH BC
0850 0559 D5 PUSH DE
0851 055A 01 00 00 LD BC,0000H
0852 055D 11 64 00 LD DE,0064H
0853 0560 CD 7F 01 CALL D101
0854 0563 CD AA 05 CALL P409
0855 0566 28 23 JR Z,P405
0856 0568 D9 EXX
0857 0569 C5 PUSH BC
0858 056A D5 PUSH DE
0859 056B 01 00 00 LD BC,0000H
0860 056E 11 0A 00 LD DE,000AH
0861 0571 CD 7F 01 CALL D101
0862 0574 CD AA 05 CALL P409
0863 0577 28 12 JR Z,P405
0864 0579 D9 EXX
0865 057A DD 46 02 LD B,(IX+02H)
0866 057D 7B LD A,E
0867 057E 80 ADD A,B
0868 057F DD 4E 01 LD C,(IX+01H)
0869 0582 ED 79 OUT (C),A
0870 0584 DD 4E 03 LD C,(IX+03H)
0871 0587 0D DEC C
0872 0588 DD 71 03 LD (IX+03H),C
0873 058B P405:
0874 058B C9 RET
0875 058C DD 46 02 P406: LD B,(IX+02H)
0876 058F 7B LD A,E
0877 0590 FE 00 CP 00H
0878 0592 28 02 JR Z,P407
0879 0594 06 30 LD B,30H
0880 0596 80 P407: ADD A,B
0881 0597 DD 70 02 LD (IX+02H),B
0882 059A 28 0C JR Z,P408
0883 059C DD 4E 01 LD C,(IX+01H)
0884 059F ED 79 OUT (C),A
0885 05A1 DD 4E 03 LD C,(IX+03H)
0886 05A4 0D DEC C
0887 05A5 DD 71 03 LD (IX+03H),C
0888 05A8 D9 P408: EXX
0889 05A9 C9 RET
0890 05AA DD 46 02 P409: LD B,(IX+02H)
0891 05AD 7B LD A,E
0892 05AE 80 ADD A,B
0893 05AF DD 4E 01 LD C,(IX+01H)
0894 05B2 ED 79 OUT (C),A
0895 05B4 DD 4E 03 LD C,(IX+03H)
0896 05B7 0D DEC C
0897 05B8 DD 71 03 LD (IX+03H),C
0898 05BB C9 RET
0899 05BC ; End of listing
0900 05BC .END
Number of errors = 0

BIN
files/basprint.obj Normal file

Binary file not shown.

30
files/bin2bcd.asm Normal file
View File

@ -0,0 +1,30 @@
START: LD SP,STACK ;initialize stack pointer
LD HL,BINBYT ;point HL index to where binary number is stored
LD A,(HL) ;transfer byte
LD HL,OUTBUF ;point HL index to output-buffer memory
CALL BINBCD
HALT
BINBCD:
LD B,100 ;load 100 into register B (power of ten holding register)
CALL BCD ;call conversion for BCD3
LD B,10 ;load 10 into register B
CALL BCD ;call conversion for BCD2
LD (HL),A ;store BCD1
RET
BCD:
LD (HL),0FFH ;load buffer with -1
STORE: INC (HL) ;clear buffer first and increment for each subtraction
SUB B ;subtract power of ten from binary number
JR NC,STORE ;if number is larger than power of ten, go back and add 1 to buffer
ADD A,B ;if no, add power of ten to get back remainder
INC HL ;go to next buffer location
RET
.ORG 0100H
BINBYT .DB 234 ;example binary number to be converted into a BCD number
OUTBUF ;output-buffer memory location
STACK .EQU 0FFFFH ;definition of stack pointer initialization address
.END

5
files/bin2bcd.hex Normal file
View File

@ -0,0 +1,5 @@
:1000000031FFFF2100017E210101CD0E0076066443
:10001000CD1A00060ACD1A0077C936FF349030FC9D
:100020008023C90000000000000000000000000064
:01010000EA14
:00000001FF

31
files/bin2bcd.lst Normal file
View File

@ -0,0 +1,31 @@
0001 0000 31 FF FF START: LD SP,STACK ;initialize stack pointer
0002 0003 21 00 01 LD HL,BINBYT ;point HL index to where binary number is stored
0003 0006 7E LD A,(HL) ;transfer byte
0004 0007 21 01 01 LD HL,OUTBUF ;point HL index to output-buffer memory
0005 000A CD 0E 00 CALL BINBCD
0006 000D 76 HALT
0007 000E
0008 000E BINBCD:
0009 000E 06 64 LD B,100 ;load 100 into register B (power of ten holding register)
0010 0010 CD 1A 00 CALL BCD ;call conversion for BCD3
0011 0013 06 0A LD B,10 ;load 10 into register B
0012 0015 CD 1A 00 CALL BCD ;call conversion for BCD2
0013 0018 77 LD (HL),A ;store BCD1
0014 0019 C9 RET
0015 001A
0016 001A BCD:
0017 001A 36 FF LD (HL),0FFH ;load buffer with -1
0018 001C 34 STORE: INC (HL) ;clear buffer first and increment for each subtraction
0019 001D 90 SUB B ;subtract power of ten from binary number
0020 001E 30 FC JR NC,STORE ;if number is larger than power of ten, go back and add 1 to buffer
0021 0020 80 ADD A,B ;if no, add power of ten to get back remainder
0022 0021 23 INC HL ;go to next buffer location
0023 0022 C9 RET
0024 0023
0025 0023 .ORG 0100H
0026 0100 EA BINBYT .DB 234 ;example binary number to be converted into a BCD number
0027 0101 OUTBUF ;output-buffer memory location
0028 0101
0029 0101 STACK .EQU 0FFFFH ;definition of stack pointer initialization address
0030 0101 .END
Number of errors = 0

BIN
files/bin2bcd.obj Normal file

Binary file not shown.

26
files/interrupt.asm Normal file
View File

@ -0,0 +1,26 @@
JP 0100H ;jump to main routine
.ORG 0038H ;interrupt routine
IN A,(01H) ;get the value from port 01H
OUT (02H),A ;echo that value to port 02H
EI ;enable interrupts
RETI ;return from interrupt
.ORG 0100H ;main rountine
JR L1 ;jump over data area
L2: .DB 0AH ;data byte 1
.DB 0BH ;data byte 2
.DB 0CH ;data byte 3
.DB 0DH ;data byte 4
.DB 0EH ;data byte 5
L1: LD D,05H ;load counter register D
LD BC,L2 ;load pointer register pair BC
L3: LD A,(BC) ;get the data byte
OUT (02H),A ;send it to port 02H
INC BC ;increment pointer BC
DEC D ;decrement counter D
JP NZ,L3 ;loop until all data bytes are sent
IM 1 ;set interrupt mode 1
EI ;enable interrupts
L4: JP L4 ;loop forever
.END

5
files/interrupt.hex Normal file
View File

@ -0,0 +1,5 @@
:10000000C30001000000000000000000000000002C
:100030000000000000000000DB01D302FBED4D00DA
:1001000018050A0B0C0D0E16050102010AD3020395
:0A01100015C20C01ED56FBC31701E8
:00000001FF

27
files/interrupt.lst Normal file
View File

@ -0,0 +1,27 @@
0001 0000 C3 00 01 JP 0100H ;jump to main routine
0002 0003
0003 0003 .ORG 0038H ;interrupt routine
0004 0038 DB 01 IN A,(01H) ;get the value from port 01H
0005 003A D3 02 OUT (02H),A ;echo that value to port 02H
0006 003C FB EI ;enable interrupts
0007 003D ED 4D RETI ;return from interrupt
0008 003F
0009 003F .ORG 0100H ;main rountine
0010 0100 18 05 JR L1 ;jump over data area
0011 0102 0A L2: .DB 0AH ;data byte 1
0012 0103 0B .DB 0BH ;data byte 2
0013 0104 0C .DB 0CH ;data byte 3
0014 0105 0D .DB 0DH ;data byte 4
0015 0106 0E .DB 0EH ;data byte 5
0016 0107 16 05 L1: LD D,05H ;load counter register D
0017 0109 01 02 01 LD BC,L2 ;load pointer register pair BC
0018 010C 0A L3: LD A,(BC) ;get the data byte
0019 010D D3 02 OUT (02H),A ;send it to port 02H
0020 010F 03 INC BC ;increment pointer BC
0021 0110 15 DEC D ;decrement counter D
0022 0111 C2 0C 01 JP NZ,L3 ;loop until all data bytes are sent
0023 0114 ED 56 IM 1 ;set interrupt mode 1
0024 0116 FB EI ;enable interrupts
0025 0117 C3 17 01 L4: JP L4 ;loop forever
0026 011A .END
Number of errors = 0

BIN
files/interrupt.obj Normal file

Binary file not shown.

9
files/memfill.asm Normal file
View File

@ -0,0 +1,9 @@
LD A,0FFH ;initial value in register A
LD BC,0FF00H ;initial value in register pair BC
L1: LD (BC),A ;load value in A to the memory location addressed by BC
INC BC ;increment BC
DEC A ;decrement A
JP NZ,L1 ;loop until value in A is zero
LD (BC),A ;load value 00H to memory location FFFFH
HALT ;halt cpu
.END

2
files/memfill.hex Normal file
View File

@ -0,0 +1,2 @@
:0D0000003EFF0100FF02033DC20500027635
:00000001FF

10
files/memfill.lst Normal file
View File

@ -0,0 +1,10 @@
0001 0000 3E FF LD A,0FFH ;initial value in register A
0002 0002 01 00 FF LD BC,0FF00H ;initial value in register pair BC
0003 0005 02 L1: LD (BC),A ;load value in A to the memory location addressed by BC
0004 0006 03 INC BC ;increment BC
0005 0007 3D DEC A ;decrement A
0006 0008 C2 05 00 JP NZ,L1 ;loop until value in A is zero
0007 000B 02 LD (BC),A ;load value 00H to memory location FFFFH
0008 000C 76 HALT ;halt cpu
0009 000D .END
Number of errors = 0

BIN
files/memfill.obj Normal file

Binary file not shown.

10
files/memfill2.asm Normal file
View File

@ -0,0 +1,10 @@
L2: IN A,(01H) ;get value on port 01H to be used for memory fill
LD D,0FFH ;initial value in counter register D
LD BC,0FF00H ;initial value in pointer register pair BC
L1: LD (BC),A ;load value in A to the memory location addressed by BC
INC BC ;increment pointer BC
DEC D ;decrement counter D
JP NZ,L1 ;loop until value in D is zero
LD (BC),A ;fill the last memory location FFFFH
JP L2 ;repeat routine
.END

3
files/memfill2.hex Normal file
View File

@ -0,0 +1,3 @@
:10000000DB0116FF0100FF020315C2070002C30057
:0100100000EF
:00000001FF

11
files/memfill2.lst Normal file
View File

@ -0,0 +1,11 @@
0001 0000 DB 01 L2: IN A,(01H) ;get value on port 01H to be used for memory fill
0002 0002 16 FF LD D,0FFH ;initial value in counter register D
0003 0004 01 00 FF LD BC,0FF00H ;initial value in pointer register pair BC
0004 0007 02 L1: LD (BC),A ;load value in A to the memory location addressed by BC
0005 0008 03 INC BC ;increment pointer BC
0006 0009 15 DEC D ;decrement counter D
0007 000A C2 07 00 JP NZ,L1 ;loop until value in D is zero
0008 000D 02 LD (BC),A ;fill the last memory location FFFFH
0009 000E C3 00 00 JP L2 ;repeat routine
0010 0011 .END
Number of errors = 0

BIN
files/memfill2.obj Normal file

Binary file not shown.

View File

@ -0,0 +1,397 @@
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>Z80 Simulator IDE BASIC Compiler Reference Manual</title>
</head>
<body>
<center>
<table width='600' border='0' cellpadding='5' cellspacing='0' cols='1'>
<tr><td valign='top'>
<p align='center'>
<font face='Microsoft Sans Serif' size=+2><b>
<br>Z80 Simulator IDE
<br>BASIC Compiler Reference Manual
</b></font>
</p>
<p align='left'>
<font face='Microsoft Sans Serif' size=-1>
<br><b>Table Of Contents:</b>
<br><br><a href='#0'><font color='#0000C8'><b>General info</b></font></a>
<br><a href='#6'><font color='#0000E6'>Show Warnings</font></a>,
<a href='#9'><font color='#0000E6'>Do Not Compile Unused Code</font></a>,
<a href='#12'><font color='#0000E6'>Initialize Variables On Declaration</font></a>,
<a href='#15'><font color='#0000E6'>Optimize Variables Declaration</font></a>,
<br><br><a href='#18'><font color='#0000C8'><b>About variables</b></font></a>
<br><a href='#18'><font color='#0000E6'>Dim</font></a>,
<a href='#18'><font color='#0000E6'>As</font></a>,
<a href='#18'><font color='#0000E6'>Boolean</font></a>,
<a href='#18'><font color='#0000E6'>Short</font></a>,
<a href='#18'><font color='#0000E6'>Integer</font></a>,
<a href='#18'><font color='#0000E6'>Long</font></a>,
<a href='#18'><font color='#0000E6'>Single</font></a>,
<a href='#45'><font color='#0000E6'>True</font></a>,
<a href='#45'><font color='#0000E6'>False</font></a>,
<a href='#54'><font color='#0000E6'>Const</font></a>,
<a href='#61'><font color='#0000E6'>ASM</font></a>,
<a href='#71'><font color='#0000E6'>IncludeASM</font></a>,
<br><br><a href='#73'><font color='#0000C8'><b>Mathematical and logical operations</b></font></a>
<br><a href='#73'><font color='#0000E6'>Mod</font></a>,
<a href='#84'><font color='#0000E6'>Sqr</font></a>,
<a href='#84'><font color='#0000E6'>Sin</font></a>,
<a href='#84'><font color='#0000E6'>Cos</font></a>,
<a href='#84'><font color='#0000E6'>Tan</font></a>,
<a href='#84'><font color='#0000E6'>Exp</font></a>,
<a href='#84'><font color='#0000E6'>Ln</font></a>,
<a href='#84'><font color='#0000E6'>Log</font></a>,
<a href='#89'><font color='#0000E6'>Not</font></a>,
<a href='#89'><font color='#0000E6'>And</font></a>,
<a href='#89'><font color='#0000E6'>Or</font></a>,
<a href='#89'><font color='#0000E6'>Xor</font></a>,
<a href='#89'><font color='#0000E6'>Nand</font></a>,
<a href='#89'><font color='#0000E6'>Nor</font></a>,
<a href='#89'><font color='#0000E6'>Nxor</font></a>,
<br><br><a href='#109'><font color='#0000C8'><b>Standard Basic language elements</b></font></a>
<br><a href='#109'><font color='#0000E6'>Goto</font></a>,
<a href='#117'><font color='#0000E6'>For</font></a>,
<a href='#117'><font color='#0000E6'>To</font></a>,
<a href='#117'><font color='#0000E6'>Step</font></a>,
<a href='#117'><font color='#0000E6'>Next</font></a>,
<a href='#117'><font color='#0000E6'>Exit For</font></a>,
<a href='#117'><font color='#0000E6'>While</font></a>,
<a href='#117'><font color='#0000E6'>Wend</font></a>,
<a href='#117'><font color='#0000E6'>If</font></a>,
<a href='#117'><font color='#0000E6'>Then</font></a>,
<a href='#117'><font color='#0000E6'>Else</font></a>,
<a href='#117'><font color='#0000E6'>Endif</font></a>,
<br><br><a href='#147'><font color='#0000C8'><b>Memory access</b></font></a>
<br><a href='#147'><font color='#0000E6'>Poke</font></a>,
<a href='#147'><font color='#0000E6'>Peek</font></a>,
<br><br><a href='#159'><font color='#0000C8'><b>Subroutines</b></font></a>
<br><a href='#159'><font color='#0000E6'>End</font></a>,
<a href='#159'><font color='#0000E6'>Gosub</font></a>,
<a href='#159'><font color='#0000E6'>Return</font></a>,
<br><br><a href='#177'><font color='#0000C8'><b>Bit-oriented language elements</b></font></a>
<br><a href='#177'><font color='#0000E6'>SetBit</font></a>,
<a href='#177'><font color='#0000E6'>ResetBit</font></a>,
<a href='#185'><font color='#0000E6'>TestBit</font></a>,
<a href='#185'><font color='#0000E6'>MakeBit</font></a>,
<br><br><a href='#191'><font color='#0000C8'><b>Communication with I/O ports</b></font></a>
<br><a href='#191'><font color='#0000E6'>Get</font></a>,
<a href='#197'><font color='#0000E6'>Put</font></a>,
<a href='#202'><font color='#0000E6'>Print</font></a>,
<a href='#202'><font color='#0000E6'>Qt</font></a>,
<a href='#202'><font color='#0000E6'>CrLf</font></a>,
<a href='#202'><font color='#0000E6'>Lf</font></a>,
<br><br><a href='#214'><font color='#0000C8'><b>Structured language support (procedures and functions)</b></font></a>
<br><a href='#214'><font color='#0000E6'>Proc</font></a>,
<a href='#214'><font color='#0000E6'>End Proc</font></a>,
<a href='#214'><font color='#0000E6'>Call</font></a>,
<a href='#214'><font color='#0000E6'>Exit</font></a>,
<a href='#227'><font color='#0000E6'>Function</font></a>,
<a href='#227'><font color='#0000E6'>End Function</font></a>,
<a href='#239'><font color='#0000E6'>Include</font></a>,
</font>
</p>
<p align='left'>
<font face='Microsoft Sans Serif' size=-1>
<a name='0'></a>
<br><font color='#0000C8'><b>&#9679; <u>General info</u></b></font>
<br>
<br>Basic compiler editor is composed of editor panel (for user program editing) and source explorer (for easy navigation through all elements of user program - variables, symbols, constants, subroutines, procedures and functions). Editor formats and colorizes entered lines of user program, that simplifies the debugging process.
<br>
<br>The primary output of the compiler is an assembler source file. However, with an appropriate command from the menu it can be assembled and even loaded in the simulator with a single click. Menu commands and options are rich, as well as the commands from the right-click popup menus for the editor and source explorer. Basic compiler's assembler output contains many useful comment lines, that makes it very helpful for educational purposes, also.
<br>
<a name='6'></a>
<br><font color='#0000E6'>Show Warnings</font>
<br>If Show Warnings option is enabled, in the Warnings window Basic compiler will show information about unused declarations, subroutines, procedures and functions in the user basic program.
<br>
<a name='9'></a>
<br><font color='#0000E6'>Do Not Compile Unused Code</font>
<br>If this option is enabled, Basic compiler will not compile unused declarations, subroutines, procedures and functions, in order to save memory resources.
<br>
<a name='12'></a>
<br><font color='#0000E6'>Initialize Variables On Declaration</font>
<br>If this option is enabled, Basic compiler will reset to zero all memory locations allocated for variables, at the position of their declaration in the basic program. This option is useful for beginners, because RAM memory is filled with random values at device power-up, and it is easy to make a mistake to assume that all variables are reset to zero at power-up. Experienced users can save some program memory, by disabling this option and taking control of variable initial values by user program where necessary.
<br>
<a name='15'></a>
<br><font color='#0000E6'>Optimize Variables Declaration</font>
<br>This option will turn on the compiler internal routine that will optimize the variables declaration order based on the usage frequency of the variables. In this way, the most frequently used variables will be stored in higher RAM memory locations, resulting in possibly smaller size of the generated code.
<br>
<a name='18'></a>
<br><font color='#0000C8'><b>&#9679; <u>About variables</u></b></font>
<br>
<br>Five data types are supported:
<br><font color='#6400C8'><u>Boolean</u></font> - 1-byte, True or False
<br><font color='#6400C8'><u>Short</u></font> - 1-byte integers in the range -128 to 127
<br><font color='#6400C8'><u>Integer</u></font> - 2-byte integers in the range -32,768 to 32,767
<br><font color='#6400C8'><u>Long</u></font> - 4-byte integers in the range -2,147,483,648 to 2,147,483,647
<br><font color='#6400C8'><u>Single</u></font> - 4-byte single precision floating point numbers, 7 digits precision, IEEE754 standard
<br>
<br>Variables can be global (declared in the main program, before the End statement) or local (declared in subroutines, procedures and functions). Variable name used for a variable with global scope can be used again for local variable names. The compiler will reserve separate memory locations for them. There are no other limits for the total number of variables, but 64K RAM memory. Variables are declared using DIM statement:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim c As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim d As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim e As Single</font>
<br>
<br>It is possible to use one-dimensional arrays for all variable types. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a(100) As Integer</font>
<br>declares an array of 100 Integer variables with array index in the range [0-99].
<br>
<br>It is possible to make conversions between all data types (except Boolean) by simple assignment statements:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Single</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = 123.456</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = b</font>
<br>This will result in variable A holding integer value 123.
<br>
<a name='45'></a>
<br>Constants can be used in decimal number system with no special marks, in hexadecimal number system with leading 0x or leading $ notation (or with H at the end) and in binary system with leading % mark (or with B at the end). ASCII value of a character can be expressed in string format (e.g. "A"). Keywords True and False are also available for Boolean type constants. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim c As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = True</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = %01010101</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = 0x55aa</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = "C"</font>
<br>
<a name='54'></a>
<br>Constants can be assigned to symbolic names using CONST directive. Constants can be global or local. One example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Single</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Const pi = 3.14159</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = pi</font>
<br>
<br>It is possible to use comments in basic source programs. The comments must begin with single quote symbol (') and may be placed anywhere in the program.
<br>
<a name='61'></a>
<br>Lines of assembler source code may be placed anywhere in basic source program and must begin with ASM: prefix. If labels are used, no space should be left between the ASM: prefix and the label. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;ASM:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NOP</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;ASM:LABEL1: LD A,(BC)</font>
<br>
<br>Symbolic names of all variables and constants (global and local) can be used as arguments of assembler statements. The compiler will replace that symbolic name with the proper variable address or constant value:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim varname As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;varname = 0</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;ASM:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LD A,55H</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;ASM:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LD (VARNAME),A</font>
<br>
<a name='71'></a>
<br>If large amount of assembler code should be used, it can be loaded from an external assembler file and included to the current program by using IncludeASM directive. Its only argument is a string containing the path to the external .ASM file. This can be the full path or only the file name, if the external file is located in the same folder as the current basic program file. During the compilation process the external assembler code will be appended to the current program at its end, and not at the position of the directive. Multiple files can be included with separate IncludeASM directives. External assembler files should not contain ASM: prefix used for inline assembler code. It is also strongly suggested not to use ORG directives in the external assembler code.
<br>
<a name='73'></a>
<br><font color='#0000C8'><b>&#9679; <u>Mathematical and logical operations</u></b></font>
<br>
<br>Five arithmetic operations (+, -, *, /, MOD) are available for integer data types. MOD operation is not applicable for Single data type variables. The compiler is able to compile all possible complex arithmetic expressions, including those containing math functions and user defined functions. Arithmetic operations are allowed only in assignment statements and all variables in one such statement must be of the same data type. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim c As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 1234</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = 2345</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = a * b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a * 100 - (a + b)</font>
<br>
<a name='84'></a>
<br>There are seven single precision mathematical functions (SQR, SIN, COS, TAN, EXP, LN, LOG) that can be used with Single data type variables. All math functions can also be used in complex math expressions. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Single</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 2</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = Sqr(a)</font>
<br>
<a name='89'></a>
<br>For Boolean and Short data type variables seven basic logical operations are supported. It is possible to make only one logical operation in one single statement. Logical operations are allowed only in assignment statements. For example:
<br><font color='#009600'>Example 1:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim c As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = True</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = False</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = Not a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a And b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a Or b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a Xor b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a Nand b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a Nor b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;c = a Nxor b</font>
<br>
<br><font color='#009600'>Example 2:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 0x55</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = Not a</font>
<br>
<a name='109'></a>
<br><font color='#0000C8'><b>&#9679; <u>Standard Basic language elements</u></b></font>
<br>
<br>Unconditional jumps are performed by GOTO statement. It uses line label name as argument. Line labels can be global or local. Line labels must be followed by colon mark ':'. Here is one example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 0</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;loop: a = a + 1</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Goto loop</font>
<br>
<a name='117'></a>
<br>Three standard BASIC statements are supported: FOR-TO-STEP-NEXT, WHILE-WEND and IF-THEN-ELSE-ENDIF. In FOR-TO-STEP-NEXT statement all variables must be Integer data type. Here are several examples:
<br><font color='#009600'>Example 1:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b(100) As Single</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For a = 0 To 99</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b(a) = a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next a</font>
<br>
<br><font color='#009600'>Example 2:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Long</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 100000</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;While a > 0</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a = a - 1</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Wend</font>
<br>
<br><font color='#009600'>Example 3:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For a = 0 To 10000</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If a < 1000 Then</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b = a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b = 1000</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Endif</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next a</font>
<br>
<br>For statement will accept all available variable types for the running variable. Exit For statement provides a way to exit a For-Next loop. It transfers control to the statement following the Next statement.
<br>
<br>After IF-THEN statement in the same line can be placed almost every other possible statement and then ENDIF is not used. Six standard comparison operators are available: =, <>, >, >=, <, <=. There are no limits for the number of nested statements of any kind.
<br>
<a name='147'></a>
<br><font color='#0000C8'><b>&#9679; <u>Memory access</u></b></font>
<br>
<br>Standard BASIC elements for accessing memory are available: POKE statement and PEEK function. They can be used with integer constants and also with variables of Short, Integer or Long data type. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim c As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For a = 0 To 15</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b = Peek(a)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c = 240 + a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Poke c, b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next a</font>
<br>
<a name='159'></a>
<br><font color='#0000C8'><b>&#9679; <u>Subroutines</u></b></font>
<br>
<br>Structured programs can be written using subroutine calls with GOSUB statements that use line label names as arguments. Return from a subroutine is performed by a RETURN statement. Users need to take care that the program structure is consistent. When using subroutines, the main routine must end with an END statement. The END statement is compiled as a HALT instruction. Here is an example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Integer</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = 100</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Gosub fillmemory</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = 101</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Gosub fillmemory</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;fillmemory:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For a = 20000 To 21000</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Poke a, b</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Return</font>
<br>
<a name='177'></a>
<br><font color='#0000C8'><b>&#9679; <u>Bit-oriented language elements</u></b></font>
<br>
<br>SETBIT and RESETBIT statements can be used to set or reset the individual bits in Short data type variables. The first argument is a Short variable that will be the target of the operation, and the second argument is target bit number and it must be a constant in the range 0-7.
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 0xf0</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;SetBit a, 0</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;ResetBit a, 7</font>
<br>
<a name='185'></a>
<br>By using TESTBIT and MAKEBIT functions it is possible to assign a Boolean data type variable the value contained in the specific bit of a Short data type variable, and vice versa, to copy the value of a Boolean data type variable to the specific bit of a Short data type variable. The first argument of these functions is target bit number and it must be a constant in the range 0-7. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Boolean</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim b As Short</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = TestBit(0, b)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;b = MakeBit(7, a)</font>
<br>
<a name='191'></a>
<br><font color='#0000C8'><b>&#9679; <u>Communication with I/O ports</u></b></font>
<br>
<br>The communication with the outside world is done using GET function and PUT and PRINT statements. The argument of the GET function is port number and must be a constant value in the range [0-255]. It can be used to assign the value received on the port to a variable of Short, Integer or Long data type. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = Get(10)</font>
<br>
<a name='197'></a>
<br>PUT statement can be used to send data to the specified port. The data can be a constant value in the range [0-255] or contained in a variable of Short, Integer or Long data type. Only the lowest byte of the variable is sent to the port. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 200</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Put 10, a</font>
<br>
<a name='202'></a>
<br>PRINT statement can be used to send string constants and decimal string representations of any supported data type variables to the specified port.
<br>String constants should begin and end with the opening and closing double quotation mark. There are three symbolic string constants available: Qt (or """") for the double quotation mark (ASCII code 34), CrLf for the carriage return - line feed sequence (ASCII codes 13-10) and Lf for the line feed character (ASCII code 10).
<br>Here is an example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim a As Single</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;a = 123.456</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Print 10, "THE NUMBER IS "</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Print 10, a</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Print 10, CrLf</font>
<br>
<br>This can also be done using only one PRINT statement:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Print 10, "THE NUMBER IS ", a, CrLf</font>
<br>
<a name='214'></a>
<br><font color='#0000C8'><b>&#9679; <u>Structured language support (procedures and functions)</u></b></font>
<br>
<br>Procedures can be declared with PROC statement. They can contain up to 5 arguments (comma separated list) and all available data types can be used for argument variables. Argument variables are declared locally, so they do not need to have unique names in relation to the rest of user basic program, that makes very easy to re-use once written procedures in other basic programs. The procedures can be exited with EXIT statement. They must be ended with END PROC statement and must be placed after the END statement in program. Calls to procedures are implemented with CALL statement. The list of passed arguments can contain both variables and numeric constants. For example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim x As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For x = 0 To 255</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call port_display(x)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next x</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Proc port_display(arg1 As Integer)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Print 10, "THE NUMBER IS ", arg1, CrLf</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End Proc</font>
<br>
<a name='227'></a>
<br>All facts stated for procedures are valid for functions, also. Functions can be declared with FUNCTION statement. They can contain up to 5 arguments and argument variables are declared locally. Functions can be exited with EXIT statement and must be ended with END FUNCTION. The name of the function is declared as a global variable, so if the function is called with CALL statement, after its execution the function variable will contain the result. Standard way of function calls in assignment statements can be used, also. One simple example:
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim x As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim y As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For x = 0 To 100</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y = square(x)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next x</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Function square(arg1 As Integer) As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;square = arg1 * arg1</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End Function</font>
<br>
<a name='239'></a>
<br>Basic source code from an external file can be included to the current program by using INCLUDE directive. Its only argument is a string containing the path to the external .BAS file. This can be the full path or only the file name, if the external file is located in the same folder as the current basic program file. During the compilation process the external basic source will be appended to the current program. Multiple files can be included with separate INCLUDE directives. To maintain the overall basic code structure, it is strongly suggested that the external file contains global declarations, subroutines, procedures and functions, only. Here is one very simple example for the demonstration:
<br><font color='#009600'>main.bas:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim i As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim j As Integer</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Include "inc1.bas"</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Include "inc2.bas"</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;For i = 1 To 10</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = func1(i, 100)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call proc1(j)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Next i</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End</font>
<br>
<br><font color='#009600'>inc1.bas:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Dim total As Integer</font>
<br>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Proc proc1(i As Integer)</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;total = total + i</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End Proc</font>
<br>
<br><font color='#009600'>inc2.bas:</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;Function func1(i As Integer, j As Integer) As Integer</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;func1 = i + j</font>
<br><font face='Lucida Console' color='#0096C8'>&nbsp;&nbsp;&nbsp;End Function</font>
<br>
</font>
</p>
</td></tr>
</table>
</center>
</body>
</html>

View File

@ -0,0 +1,284 @@
<topic>General info
Basic compiler editor is composed of editor panel (for user program editing) and source explorer (for easy navigation through all elements of user program - variables, symbols, constants, subroutines, procedures and functions). Editor formats and colorizes entered lines of user program, that simplifies the debugging process.
The primary output of the compiler is an assembler source file. However, with an appropriate command from the menu it can be assembled and even loaded in the simulator with a single click. Menu commands and options are rich, as well as the commands from the right-click popup menus for the editor and source explorer. Basic compiler's assembler output contains many useful comment lines, that makes it very helpful for educational purposes, also.
<subtopic>Show Warnings
If Show Warnings option is enabled, in the Warnings window Basic compiler will show information about unused declarations, subroutines, procedures and functions in the user basic program.
<subtopic>Do Not Compile Unused Code
If this option is enabled, Basic compiler will not compile unused declarations, subroutines, procedures and functions, in order to save memory resources.
<subtopic>Initialize Variables On Declaration
If this option is enabled, Basic compiler will reset to zero all memory locations allocated for variables, at the position of their declaration in the basic program. This option is useful for beginners, because RAM memory is filled with random values at device power-up, and it is easy to make a mistake to assume that all variables are reset to zero at power-up. Experienced users can save some program memory, by disabling this option and taking control of variable initial values by user program where necessary.
<subtopic>Optimize Variables Declaration
This option will turn on the compiler internal routine that will optimize the variables declaration order based on the usage frequency of the variables. In this way, the most frequently used variables will be stored in higher RAM memory locations, resulting in possibly smaller size of the generated code.
<topic>About variables
<keywords1>Dim,As,Boolean,Short,Integer,Long,Single,
Five data types are supported:
<style3>Boolean - 1-byte, True or False
<style3>Short - 1-byte integers in the range -128 to 127
<style3>Integer - 2-byte integers in the range -32,768 to 32,767
<style3>Long - 4-byte integers in the range -2,147,483,648 to 2,147,483,647
<style3>Single - 4-byte single precision floating point numbers, 7 digits precision, IEEE754 standard
Variables can be global (declared in the main program, before the End statement) or local (declared in subroutines, procedures and functions). Variable name used for a variable with global scope can be used again for local variable names. The compiler will reserve separate memory locations for them. There are no other limits for the total number of variables, but 64K RAM memory. Variables are declared using DIM statement:
<style1>Dim a As Boolean
<style1>Dim b As Short
<style1>Dim c As Integer
<style1>Dim d As Long
<style1>Dim e As Single
It is possible to use one-dimensional arrays for all variable types. For example:
<style1>Dim a(100) As Integer
declares an array of 100 Integer variables with array index in the range [0-99].
It is possible to make conversions between all data types (except Boolean) by simple assignment statements:
<style1>Dim a As Long
<style1>Dim b As Single
<style1>b = 123.456
<style1>a = b
This will result in variable A holding integer value 123.
<keywords2>True,False,
Constants can be used in decimal number system with no special marks, in hexadecimal number system with leading 0x or leading $ notation (or with H at the end) and in binary system with leading % mark (or with B at the end). ASCII value of a character can be expressed in string format (e.g. "A"). Keywords True and False are also available for Boolean type constants. For example:
<style1>Dim a As Boolean
<style1>Dim b As Short
<style1>Dim c As Integer
<style1>a = True
<style1>b = %01010101
<style1>c = 0x55aa
<style1>c = "C"
<keywords2>Const,
Constants can be assigned to symbolic names using CONST directive. Constants can be global or local. One example:
<style1>Dim a As Single
<style1>Const pi = 3.14159
<style1>a = pi
It is possible to use comments in basic source programs. The comments must begin with single quote symbol (') and may be placed anywhere in the program.
<keywords2>ASM,
Lines of assembler source code may be placed anywhere in basic source program and must begin with ASM: prefix. If labels are used, no space should be left between the ASM: prefix and the label. For example:
<style1>ASM: NOP
<style1>ASM:LABEL1: LD A,(BC)
Symbolic names of all variables and constants (global and local) can be used as arguments of assembler statements. The compiler will replace that symbolic name with the proper variable address or constant value:
<style1>Dim varname As Short
<style1>varname = 0
<style1>ASM: LD A,55H
<style1>ASM: LD (VARNAME),A
<keywords2>IncludeASM,
If large amount of assembler code should be used, it can be loaded from an external assembler file and included to the current program by using IncludeASM directive. Its only argument is a string containing the path to the external .ASM file. This can be the full path or only the file name, if the external file is located in the same folder as the current basic program file. During the compilation process the external assembler code will be appended to the current program at its end, and not at the position of the directive. Multiple files can be included with separate IncludeASM directives. External assembler files should not contain ASM: prefix used for inline assembler code. It is also strongly suggested not to use ORG directives in the external assembler code.
<topic>Mathematical and logical operations
<keywords1>Mod,
Five arithmetic operations (+, -, *, /, MOD) are available for integer data types. MOD operation is not applicable for Single data type variables. The compiler is able to compile all possible complex arithmetic expressions, including those containing math functions and user defined functions. Arithmetic operations are allowed only in assignment statements and all variables in one such statement must be of the same data type. For example:
<style1>Dim a As Long
<style1>Dim b As Long
<style1>Dim c As Long
<style1>a = 1234
<style1>b = 2345
<style1>b = a * b
<style1>c = a * 100 - (a + b)
<keywords2>Sqr,Sin,Cos,Tan,Exp,Ln,Log,
There are seven single precision mathematical functions (SQR, SIN, COS, TAN, EXP, LN, LOG) that can be used with Single data type variables. All math functions can also be used in complex math expressions. For example:
<style1>Dim a As Single
<style1>a = 2
<style1>a = Sqr(a)
<keywords2>Not,And,Or,Xor,Nand,Nor,Nxor,
For Boolean and Short data type variables seven basic logical operations are supported. It is possible to make only one logical operation in one single statement. Logical operations are allowed only in assignment statements. For example:
<style2>Example 1:
<style1>Dim a As Boolean
<style1>Dim b As Boolean
<style1>Dim c As Boolean
<style1>a = True
<style1>b = False
<style1>c = Not a
<style1>c = a And b
<style1>c = a Or b
<style1>c = a Xor b
<style1>c = a Nand b
<style1>c = a Nor b
<style1>c = a Nxor b
<style2>Example 2:
<style1>Dim a As Short
<style1>a = 0x55
<style1>a = Not a
<topic>Standard Basic language elements
<keywords1>Goto,
Unconditional jumps are performed by GOTO statement. It uses line label name as argument. Line labels can be global or local. Line labels must be followed by colon mark ':'. Here is one example:
<style1>Dim a As Long
<style1>a = 0
<style1>loop: a = a + 1
<style1>Goto loop
<keywords2>For,To,Step,Next,Exit For,While,Wend,If,Then,Else,Endif,
Three standard BASIC statements are supported: FOR-TO-STEP-NEXT, WHILE-WEND and IF-THEN-ELSE-ENDIF. In FOR-TO-STEP-NEXT statement all variables must be Integer data type. Here are several examples:
<style2>Example 1:
<style1>Dim a As Integer
<style1>Dim b(100) As Single
<style1>For a = 0 To 99
<style1> b(a) = a
<style1>Next a
<style2>Example 2:
<style1>Dim a As Long
<style1>a = 100000
<style1>While a > 0
<style1> a = a - 1
<style1>Wend
<style2>Example 3:
<style1>Dim a As Integer
<style1>Dim b As Integer
<style1>For a = 0 To 10000
<style1> If a < 1000 Then
<style1> b = a
<style1> Else
<style1> b = 1000
<style1> Endif
<style1>Next a
For statement will accept all available variable types for the running variable. Exit For statement provides a way to exit a For-Next loop. It transfers control to the statement following the Next statement.
After IF-THEN statement in the same line can be placed almost every other possible statement and then ENDIF is not used. Six standard comparison operators are available: =, <>, >, >=, <, <=. There are no limits for the number of nested statements of any kind.
<topic>Memory access
<keywords1>Poke,Peek,
Standard BASIC elements for accessing memory are available: POKE statement and PEEK function. They can be used with integer constants and also with variables of Short, Integer or Long data type. For example:
<style1>Dim a As Integer
<style1>Dim b As Integer
<style1>Dim c As Integer
<style1>For a = 0 To 15
<style1> b = Peek(a)
<style1> c = 240 + a
<style1> Poke c, b
<style1>Next a
<topic>Subroutines
<keywords1>End,Gosub,Return,
Structured programs can be written using subroutine calls with GOSUB statements that use line label names as arguments. Return from a subroutine is performed by a RETURN statement. Users need to take care that the program structure is consistent. When using subroutines, the main routine must end with an END statement. The END statement is compiled as a HALT instruction. Here is an example:
<style1>Dim a As Integer
<style1>Dim b As Integer
<style1>b = 100
<style1>Gosub fillmemory
<style1>b = 101
<style1>Gosub fillmemory
<style1>End
<style1>fillmemory:
<style1>For a = 20000 To 21000
<style1> Poke a, b
<style1>Next a
<style1>Return
<topic>Bit-oriented language elements
<keywords1>SetBit,ResetBit,
SETBIT and RESETBIT statements can be used to set or reset the individual bits in Short data type variables. The first argument is a Short variable that will be the target of the operation, and the second argument is target bit number and it must be a constant in the range 0-7.
<style1>Dim a As Short
<style1>a = 0xf0
<style1>SetBit a, 0
<style1>ResetBit a, 7
<keywords2>TestBit,MakeBit,
By using TESTBIT and MAKEBIT functions it is possible to assign a Boolean data type variable the value contained in the specific bit of a Short data type variable, and vice versa, to copy the value of a Boolean data type variable to the specific bit of a Short data type variable. The first argument of these functions is target bit number and it must be a constant in the range 0-7. For example:
<style1>Dim a As Boolean
<style1>Dim b As Short
<style1>a = TestBit(0, b)
<style1>b = MakeBit(7, a)
<topic>Communication with I/O ports
<keywords1>Get,
The communication with the outside world is done using GET function and PUT and PRINT statements. The argument of the GET function is port number and must be a constant value in the range [0-255]. It can be used to assign the value received on the port to a variable of Short, Integer or Long data type. For example:
<style1>Dim a As Integer
<style1>a = Get(10)
<keywords2>Put,
PUT statement can be used to send data to the specified port. The data can be a constant value in the range [0-255] or contained in a variable of Short, Integer or Long data type. Only the lowest byte of the variable is sent to the port. For example:
<style1>Dim a As Integer
<style1>a = 200
<style1>Put 10, a
<keywords2>Print,Qt,CrLf,Lf,
PRINT statement can be used to send string constants and decimal string representations of any supported data type variables to the specified port.
String constants should begin and end with the opening and closing double quotation mark. There are three symbolic string constants available: Qt (or """") for the double quotation mark (ASCII code 34), CrLf for the carriage return - line feed sequence (ASCII codes 13-10) and Lf for the line feed character (ASCII code 10).
Here is an example:
<style1>Dim a As Single
<style1>a = 123.456
<style1>Print 10, "THE NUMBER IS "
<style1>Print 10, a
<style1>Print 10, CrLf
This can also be done using only one PRINT statement:
<style1>Print 10, "THE NUMBER IS ", a, CrLf
<topic>Structured language support (procedures and functions)
<keywords1>Proc,End Proc,Call,Exit,
Procedures can be declared with PROC statement. They can contain up to 5 arguments (comma separated list) and all available data types can be used for argument variables. Argument variables are declared locally, so they do not need to have unique names in relation to the rest of user basic program, that makes very easy to re-use once written procedures in other basic programs. The procedures can be exited with EXIT statement. They must be ended with END PROC statement and must be placed after the END statement in program. Calls to procedures are implemented with CALL statement. The list of passed arguments can contain both variables and numeric constants. For example:
<style1>Dim x As Integer
<style1>For x = 0 To 255
<style1> Call port_display(x)
<style1>Next x
<style1>End
<style1>Proc port_display(arg1 As Integer)
<style1>Print 10, "THE NUMBER IS ", arg1, CrLf
<style1>End Proc
<keywords2>Function,End Function,
All facts stated for procedures are valid for functions, also. Functions can be declared with FUNCTION statement. They can contain up to 5 arguments and argument variables are declared locally. Functions can be exited with EXIT statement and must be ended with END FUNCTION. The name of the function is declared as a global variable, so if the function is called with CALL statement, after its execution the function variable will contain the result. Standard way of function calls in assignment statements can be used, also. One simple example:
<style1>Dim x As Integer
<style1>Dim y As Integer
<style1>For x = 0 To 100
<style1> y = square(x)
<style1>Next x
<style1>End
<style1>Function square(arg1 As Integer) As Integer
<style1>square = arg1 * arg1
<style1>End Function
<keywords2>Include,
Basic source code from an external file can be included to the current program by using INCLUDE directive. Its only argument is a string containing the path to the external .BAS file. This can be the full path or only the file name, if the external file is located in the same folder as the current basic program file. During the compilation process the external basic source will be appended to the current program. Multiple files can be included with separate INCLUDE directives. To maintain the overall basic code structure, it is strongly suggested that the external file contains global declarations, subroutines, procedures and functions, only. Here is one very simple example for the demonstration:
<style2>main.bas:
<style1>Dim i As Integer
<style1>Dim j As Integer
<style1>Include "inc1.bas"
<style1>Include "inc2.bas"
<style1>For i = 1 To 10
<style1> j = func1(i, 100)
<style1> Call proc1(j)
<style1>Next i
<style1>End
<style2>inc1.bas:
<style1>Dim total As Integer
<style1>Proc proc1(i As Integer)
<style1>total = total + i
<style1>End Proc
<style2>inc2.bas:
<style1>Function func1(i As Integer, j As Integer) As Integer
<style1>func1 = i + j
<style1>End Function

Binary file not shown.

View File

@ -0,0 +1,91 @@
<topic>General info
Z80 Simulator IDE is an automation (ActiveX) server/client application. This feature enables communication with external simulation modules that can be developed by home developers and third parties using various Development Systems for Windows.
<subtopic>z80simulatoride.server
External client application can access Z80 Simulator IDE server services by creating an ActiveX object using z80simulatoride.server class.
<topic>Functions and procedures
Here is the list of functions and procedures available for external client applications:
<subtopic>- getmem
getmem(address) function will return the value in the memory location specified by 'address' argument [0-65535].
<subtopic>- setmem
setmem(address,value) procedure will put the 'value' argument [0-255] in the memory location specified by 'address' argument [0-65535].
<subtopic>- getio
getio(address) function will return the value on the I/O port specified by 'address' argument [0-255].
<subtopic>- setio
setio(address,value) procedure will put the 'value' argument [0-255] on the I/O port specified by 'address' argument [0-255].
<subtopic>- z80nmi
z80nmi() procedure with no arguments will generate NMI interrupt signal.
<subtopic>- z80int
z80int() procedure with no arguments will generate INT interrupt signal.
<subtopic>- z80reset
z80reset() procedure with no arguments will generate RESET signal.
<subtopic>- gethalt
gethalt() function with no arguments will return the HALT state [0-1].
<subtopic>- getinst
getinst() function with no arguments will return the mnemonics of last executed instruction [string].
<subtopic>- getcrystal
getcrystal() function with no arguments will return the clock frequency parameter [string].
<subtopic>- getclockcycles
getclockcycles() function with no arguments will return the number of clock cycles passed after the start of the simulation. The last two functions will enable the external client application to develop a real time behavior if needed.
<subtopic>- geta
geta() function will return the value in A register.
<subtopic>- getf
getf() function will return the value in F (flag) register.
<subtopic>- getb
getb() function will return the value in B register.
<subtopic>- getc
getc() function will return the value in C register.
<subtopic>- getd
getd() function will return the value in D register.
<subtopic>- gete
gete() function will return the value in E register.
<subtopic>- geth
geth() function will return the value in H register.
<subtopic>- getl
getl() function will return the value in L register.
<subtopic>- getix
getix() function will return the value in IX register.
<subtopic>- getiy
getiy() function will return the value in IY register.
<subtopic>- getsp
getsp() function will return the value in SP register.
<subtopic>- getpc
getpc() function will return the value in PC register.
<subtopic>- geti
geti() function will return the value in I register.
<subtopic>- getr
getr() function will return the value in R register.
<subtopic>- geta1
geta1() function will return the value in alternate A' register.
<subtopic>- getf1
getf1() function will return the value in alternate F' register.
<subtopic>- getb1
getb1() function will return the value in alternate B' register.
<subtopic>- getc1
getc1() function will return the value in alternate C' register.
<subtopic>- getd1
getd1() function will return the value in alternate D' register.
<subtopic>- gete1
gete1() function will return the value in alternate E' register.
<subtopic>- geth1
geth1() function will return the value in alternate H' register.
<subtopic>- getl1
getl1() function will return the value in alternate L' register.
<topic>External client/servers
Full support and full synchronization is available for external applications with client/server capabilities. External server module should provide the following procedures:
<subtopic>- objectinit
objectinit() procedure will be called at the beginning of the simulation in Z80 Simulator IDE. With this procedure external module should be initialized to a known initial state.
<subtopic>- objectrefresh
objectrefresh() procedure will be called after every simulated instruction.
<subtopic>- writeio
writeio(port,data) procedure will be called after every simulated OUT instruction and its arguments will be available for the external module.
<subtopic>- readio
readio(port,data) procedure will be called during the simulation of every IN instruction and the external module should assign the non-negative value [0-255] to the second argument (that should be addressed by reference and not by value) only if it is assigned to the specified port argument.
<subtopic>- objectterm
objectterm() procedure needs to contain the code to terminate external module application (typically End statement).
<subtopic>External modules interface
The class name should be set using External Modules interface available from Tools menu of Z80 Simulator IDE. External client/server applications will be started and terminated automatically with Z80 Simulator IDE.

BIN
files/z80gettingstarted.pdf Normal file

Binary file not shown.

BIN
files/z80helptopics.pdf Normal file

Binary file not shown.

130
files/z80helptopics.txt Normal file
View File

@ -0,0 +1,130 @@
<topic>General info
Z80 Simulator IDE is powerful application that supplies Z80 microprocessor users and educators with user-friendly graphical development environment for Windows with integrated simulator (emulator), z80 basic compiler, assembler, disassembler and debugger for the Zilog Z80 8-bit microprocessor.
The main application window shows Z80 microprocessor internal registers (and flags) structure, mnemonics of the last executed instruction, mnemonics of the next instruction that will be executed, clock cycles and instructions counter and interrupt interface.
<topic>File menu
<subtopic>- Clear Memory
This command restores the initial state of the 64K memory with address range 0000H-FFFFH assumed to be attached to the CPU. The whole memory is filled with NOPs with opcode 00H.
<subtopic>- Load Program
This command loads program file into CPU memory. The program file must be in Intel HEX format or binary image (OBJ extension) of the memory starting from address 0000H with maximum length of 64K. Once loaded program file can be quickly reloaded by clicking on its location field on the main program interface.
<subtopic>- Save Memory
This command saves the contents of the memory to a file.
<topic>Simulation menu
<subtopic>- Start
Z80 Simulator IDE enters simulation mode and begins the execution of instructions starting from the memory location that corresponds to starting address parameter. The default value for this parameter is 0000H and this value can be changed using Change Starting Address command from the Options menu.
<subtopic>- Step
This command is enabled only when Step By Step simulation rate is selected. Next instruction is executed on every click on keyboard shortcut F2.
<subtopic>- Stop
Z80 Simulator IDE exits simulation mode and presents the information about the total number of executed instructions, duration of the simulation and real-time duration of the simulation in clock cycles.
<topic>Rate menu
It enables user to change the simulation rate. It is accessible during the simulation, also.
<subtopic>- Step By Step
The interval between consecutive instructions is at user will. When the simulator is in Step By Step mode, it is possible to change the values in all CPU internal registers, by clicking on the appropriate fields on the program interface. When this simulation rate is selected new main menu item 'STEP' will appear on the program interface. That will enable an easy access to Step command from the Simulation menu.
<subtopic>- Slow
The interval is 1500 ms.
<subtopic>- Normal
The interval is 250 ms.
<subtopic>- Fast
The interval is around 50 ms.
<subtopic>- Extremely Fast
The interval is very short and is linearly dependent on the overall computer performance.
<subtopic>- Ultimate
The main simulator window is not continuously refreshed after every simulated instruction that significantly improve the simulation performance. The refresh interval can be changed using Change Ultimate Rate Refresh Interval command in Options menu.
<topic>Tools menu
<subtopic>- Memory Editor
This is access to the graphical interface for the Z80 Simulator CPU 64K memory. It has a scroll bar and is very easy to use. The value in the specific memory location can be changed by clicking on it. When the entered value is confirmed by pressing Enter key, edit box will automatically move to the next memory location. Edit box can be moved freely over the memory table using arrow keys and it can be closed by Esc key.
<subtopic>- Disassembler
Z80 Simulator IDE has very powerful internal disassembler that is started by this command. Disassembler is independent from the simulator and it has its own program memory. So, it is necessary to load the program file (Intel HEX file or binary image) into disassembler memory first. The disassembling process is initiated by an appropriate command from the disassembler menu. The disassembler will always start from the address 0000H. After the operation is completed disassembler will display the output listing file. The generated listing can be saved to disk. User will be prompted to enter the name for the output file. Default extension is LST.
<subtopic>- Peripheral Devices
This is useful tool to monitor and control IN and OUT instructions. Up to four basic I/O peripheral devices can be setup and there is also one output terminal useful for viewing ASCII characters sent to one of the ports. The bytes sent with OUT instructions are displayed graphically showing individual bits. If the device is configured as an input device, the value it supplies can be set either by entering it directly after click on value label or by toggling individual bits of graphical representation.
<subtopic>- I/O Ports Editor
This is access to the graphical interface for the control over the complete I/O ports range. The value at the specific I/O port can be changed by clicking on it. When the entered value is confirmed pressing Enter key, edit box will automatically move to the next I/O port. Edit box can be moved freely over the I/O ports table using arrow keys and it can be closed by Esc key. Information in the I/O Ports Editor window is consistent with the Peripheral Devices window.
<subtopic>- Memory Editor 2
This command starts another Memory Editor tool with the same features.
<subtopic>- Memory Editor 3
This command starts yet another Memory Editor tool with the same features. So, it is possible to simultaneously view/edit three different memory ranges during the simulation.
<subtopic>- Assembler
This command starts integrated assembler. Assembler source files can be edited, directly assembled and finally loaded into memory in the same graphical environment. Default extension is ASM. After the successful assembly process two new files are generated. One with OBJ extension that is binary image of the program and that can be directly loaded into CPU memory and the other with LST extension that is assembler listing used with the debugger. If Generate HEX File Also option is selected then program file in Intel HEX format will also be generated. It is not only possible to use the internal assembler - this window can also be used as the graphical interface for the external TASM assembler. It is only necessary to locate the executable file of the TASM assembler before the first use. If TASM assembler is used from the command line, -80 -b options will generate OBJ file.
<subtopic>- Breakpoints Manager
This command starts integrated debugger that can be used to debug and monitor the program execution. If the assembler listing file of the program in memory do not exist useable alternative listing will be generated by the internal disassembler. It is possible to define up to 10 breakpoints by clicking on individual lines in the loaded program listing. When the simulation starts in faster rate modes it will automatically switch to Step By Step mode when reaching any of these breakpoints. The breakpoints are marked by red circles, and the current value of the PC register is marked by yellow arrow. There is an option to keep the PC pointer in focus during the simulation.
<subtopic>- BASIC Compiler
Integrated BASIC compiler editor window will be opened. More information available in BASIC Compiler Reference Manual. It can be accessed from the Help menu of the main application window or from the BASIC compiler editor window.
<subtopic>- IEEE 754 Conversion Tool
This command starts the tool that converts real numbers to their four byte IEEE 754 single precision floating point representation. That representation is used for 'Single' data type by BASIC compiler.
<subtopic>- Simulation Log Viewer
This command starts integrated graphical tool that will log all simulated instructions together with Z80 registers and flags status. This is very useful tool for debugging process.
<subtopic>- Interactive Assembler Editor
This command starts integrated graphical tool that will enable beginners to write their first assembler routines interactively without having to memorize the mnemonics of individual instructions from Z80 rich instruction set. This is a great tool for educational purposes.
<subtopic>- Watch Variables
During the simulation of programs written using integrated basic compiler, this tool can be used to watch the current values of all variables declared in the simulated basic program. It is also possible to add user defined variables to the list to monitor other memory locations of interest during the simulation. This feature is useful for memory monitoring for simulated program files, that are not compiled with the integrated basic compiler. User added variables will be remembered between sessions as long as the same program file is loaded in the simulator. Variables from the watch list can be easily removed with the Delete Variable command, so the list can contain variables of special interest only. Other commands and options include: Change Variable Value (can be also started by a single-click on the variable from the list), Display HEX Values, Confirm Delete.
<subtopic>- External Modules
This tool should be used to establish automation interface with up to five external client/server modules. It is required to enter the class name supplied by external device in the form ApplicationName.ObjectName in order to establish connection with it. External client/server applications will be started and terminated automatically with Z80 Simulator IDE. More information available in External Modules Manual. It can be accessed from the Help menu of the main application window.
<topic>Options menu
<subtopic>- Enable Logging
This option will force the simulator to log to LOG.TXT file in the application folder all simulated instructions together with Z80 registers and flags status. This option do not interfere with the integrated graphical Simulation Log Viewer.
<subtopic>- Shortcuts Panel Configuration
This option command opens an easy to use interface for turning on and customizing the fancy-looking shortcuts panel on the main IDE window, for an easy access to the most frequently used menu commands. The panel can contain up to three lines of menu item shortcuts. All main IDE window menu items are available to be placed on the panel.
<subtopic>- HALT Stops Simulation
If this option is selected the simulation will automatically stop when HALT instruction is reached. If it is not selected, the simulator will, just as real Z80 CPU does, execute this instruction repeatedly until it receives an interrupt. After the return from interrupt the execution will continue with next instruction.
<subtopic>- FF Power On Defaults
Toggling this option will switch between 00H and FFH initial values for Z80 CPU registers.
<subtopic>- Refresh Memory Editor
If this option is selected and Memory Editor is started, the displayed memory range will be refreshed after every simulated instruction, in all simulation rate modes. This is useful if you want to monitor what is going on on the stack or elsewhere in the memory during the simulation.
<subtopic>- Refresh Breakpoints Manager
If this option is selected and Breakpoints Manager is started, it will be refreshed after every simulated instruction. If Hold PC In Focus option is also selected, that will enable user to watch live presentation of the program execution.
<subtopic>- Save Positions
With this option selected, the positions of the windows on the screen will be remembered.
<subtopic>- Save Always On Top
With this option selected, the Always On Top setting for all of the windows with this feature will be remembered.
<subtopic>- Auto Start Options
With this utility users can define actions that will be performed on the application startup. These actions include automatic opening of various tools and simulation interfaces from the Tools menu and automatic loading of the last used files in the simulator, assembler and basic compiler.
<subtopic>- Change Clock Frequency
This command allows user to change the frequency parameter that is used for the calculation of the real-time duration of the simulation. The entered value in MHz is remembered for the future sessions. The default value is 4 MHz.
<subtopic>- Change Starting Address
This command allows user to change the starting address for the simulation. The entered value is remembered for the future sessions. The default value is 0000H.
<subtopic>- Change Offset Address For OBJ Files Loading
Allows user to change the starting address that will be used for binary image files (OBJ extension) loading into the 64K memory buffer. The entered value is remembered for the future sessions. The default value is 0000H. This parameter is ignored for HEX files loading.
<subtopic>- Enable Unofficial Instructions
This option will turn on the simulation of documented unofficial Z80 instructions.
<subtopic>- Prompt For Value Before IN Instruction
This option will force the program to always prompt user to manually enter every incoming byte on all ports. If it is off the value will be taken from Peripheral Devices or I/O Ports Editor window.
<subtopic>- Enable IN/OUT Instructions Logging
When this option is enabled the program will log all IN and OUT instructions in IO.TXT file located in application folder. Every IN and OUT instruction will append a new line in that file.
<subtopic>- Show Confirmation Boxes
When this option is enabled the confirmation boxes showing results of operations will be displayed and will require user response to be closed.
<subtopic>- Change Registers Arrangement
This command will change the arrangement of labels on the main and alternate registers panels. There are two different arrangements available.
<subtopic>- Change Ultimate Rate Refresh Interval
This command allows user to change the refresh interval (in milliseconds) for the main simulation interface when the simulation is running at Ultimate rate. Its value however does not affect the simulation performance considerably. The default value is 500ms.
<subtopic>- Editor Setup
With this setup tool it is possible to change various properties of basic compiler and assembler code editors.
<subtopic>- Change Color Theme
This command will open a dialog with the rich list of available color themes, so that user can change application appearance.
<topic>Help menu
<subtopic>- Help Topics
This command will display Help Topics. This help file contains general information about the application with description of all menu items.
Help viewer window features navigation panel showing topics and subtopics of the displayed help file. Right-click on the navigation panel will show popup menu with Show All Subtopics and Hide All Subtopics commands. Single-click on the item from the navigation panel will move focus on the display panel to the appropriate position. Double-click on the topic item will show/hide its subtopics. The display panel shows the content of the loaded help file. Right-click will display popup menu containing various options and commands including: Copy, Copy RTF, Copy HTML, Print, Font Increase, Font Decrease, Font Reset, Always On Top. Help viewer window is resizable and will remember both its position and size. The vertical separator between navigation and display panels is moveable and its position will also be saved after the viewer is closed.
<subtopic>- BASIC Compiler Reference Manual
BASIC Compiler Reference Manual will be displyed in the help viewer.
<subtopic>- External Modules Manual
External Modules Manual will be displyed in the help viewer.
<subtopic>- Check For Updates
This tool will enable user to establish connection with OshonSoft.com web site to check out if there is a new software release available for download. Version log file will be displayed after the response from the web site has been received.
<subtopic>- Bug Report Interface
This interface should be used to send the reports about possible bugs in software to OshonSoft.com. In addition to the user written part the full report will contain a part that is generated by software (system report).
<subtopic>- About
This command will display the basic information about the software package.
<subtopic>- View License Information
This command will display the information about the installed license for the software.
<topic>Interrupts info
All possible interrupts are supported: non-maskable interrupt (NMI) and three modes of maskable interrupts (INT mode 0, INT mode 1, INT mode 2). NMI jumps to restart location 0066H. INT mode 0 prompts user to enter the RST instruction supplied by the peripheral device and then initiates a call to the selected one of eight restart locations. INT mode 1 jumps to the restart location 0038H. INT mode 2 prompts user to enter the 8-bit vector supplied by the peripheral device, and then forms a pointer using this byte as the lower 8 bits and the contents of the I register as the upper 8 bits. This points to an entry in the table of addresses for interrupt service routines, and the simulator jumps to the routine at that address. Interrupts are triggered by pressing NMI and INT buttons on the interrupt interface. The simulation can be reset by pressing the RESET button.
<topic>Assembler info
Internal assembler is excellent solution for assembling source files with size up to 20K. For larger files the assembly process can take some time, but there are no limits in file size. Its limits are that labels can be a maximum of 32 characters long and that only .ORG (ORG), .EQU (EQU), .DB (DB, .DEFB, DEFB), .DW (DW, .DEFW, DEFW), .DS (DS, .DEFS, DEFS) and .END (END) assembler directives are supported. If better performance is needed, the graphical interface for TASM assembler can be used. Shareware version of the TASM assembler can be downloaded from http://home.comcast.net/~tasm/

BIN
files/z80simulatoride.exe Normal file

Binary file not shown.