@ervin
Here's a little M/C routine that you can use to inject your M/Code into BASIC. It calculates everything for you.
All you need to do is stick the M/Code routine where shown and then CALL &A000. The .BAS file is created for you.
ORG &170
.BASIC_Start
DEFB &0A,&00,&0A,&00,&83,&20,&1C,&00 ; 10 CALL &200
DEFB &02,&00,&00,&00,&00,&00,&00,&00
; Insert M/Code routine or Phactory code here!
; For now, here's your ABCD example
ORG &0200
LD A,65
CALL &BB5A
LD A,66
CALL &BB5A
LD A,67
CALL &BB5A
LD A,68
CALL &BB5A
RET
; This line needs to be left in!
.BASIC_End
; This calculates the overall size of the 'BASIC' file (ie, BASIC & M/C together)
.BASIC_Length equ BASIC_End-BASIC_Start
; BASIC file SAVE routine
ORG &A000
LD B,Filename_Length
LD HL,Filename_Start
LD DE,&0000
CALL &BC8C
LD HL,&0170
LD DE,BASIC_Length
LD BC,&0000
LD A,0
CALL &BC98
CALL &BC8F
RET
; Filename can be anything you want! The code auto calculates filename length.
.Filename_Start
defm "BASIC.BAS"
.Filename_End
.Filename_Length equ Filename_End-Filename_Start
NOTE: Do not edit the BASIC 'listing' (ie, 10 CALL &200) as it will shift the M/Code routine up a number of memory locations! This could be fatal if you're CALLing or JPing to specific locations!
Also, If you want to CALL another location (rather than &200) then change the last byte of the first line and the first byte of the second line of 'BASIC' data!