» Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
I am thinking about making an compiler on-calc similar to TASM oncalc. I just made an asm program that will copy program data into a string (even if it's archived Wink ), and I'm wondering if anyone has any good compiling techniques I could use.

BTW, I'm going to try to accomplish relative addressing.

Update: Now at v1, here's the link
Features so far:
    File types:
  • Source files
  • Include files
  • Includable headers
  • Supports archived files
    Immediate values:
  • Decimal
  • Binary
  • Hexadecimal
  • Equates
  • ASCII
    Assembling:
  • ix/iy can be used wherever hl can
  • (ix/iy +/- value) can be used wherever (hl) can
  • Supports jr/djnz
  • Many commands are included in the main program to save space
  • Memory-saving techniques are used while compiling
  • Skips empty lines
  • Supports Ion/MirageOS/DCS6
  • Comments
  • No case sensitivity
  • Brackets no longer needed
  • Error catching
    Coming Soon...
  • Ideas, please?
I will add more to the list when I have time.
What sort of compiler? A Z80 compiler? Some new language? Why store it to a string?
A Z80 compiler (after all, this is the Z80 asm forum).
The main compiler will be in BASIC, so it will copy the source and include files to strings to manipulate them easier.
You are trying to make a Z80 compiler in BASIC? I'd reconsider that in a hurry, and make the compiler in ASM, too
So, you decided to learn ASM?

Sounds good, except the part about it being mainly in basic, but I didn't learn enough ASM to be of much use to you here...

Not sure how you'll do it.

Good luck creating it and I hope you can complete it.

Wow, there are 15 users online: 8 members, 2 guests and 5 bots!!! Earlier, there were still 15 users, but only 3 bots (4 guests).
The TASM oncalc guy accomplished it in BASIC, and I'm trying to make a better version.

Edit: Please notice my request for good techniques, it seems that everyone's missed that.
calc84maniac wrote:
The TASM oncalc guy accomplished it in BASIC, and I'm trying to make a better version.

Edit: Please notice my request for good techniques, it seems that everyone's missed that.


You will note that he also uses an ASM program (atleast from what I can remember...).

Just wondering, is ASMEXEC( to run asm? ( something like ASMEXEC(A75385FE6C) and no, this is not real ASM hex (asfar as I know Rolling Eyes )
Harq wrote:
Just wondering, is ASMEXEC( to run asm? ( something like ASMEXEC(A75385FE6C) and no, this is not real ASM hex (asfar as I know )

With Omnicalc, yes.

My version will be much more memory-efficient because it will support archived source/include files.

Does anyone at least know of a site which can give me techniques? When I Google it, it just gives me compilers that other people have made.
The biggest challenge with oncalc ASM is text labels and the equates table, for example _clrgrbuf = NNNNh. With a lot of labels, the compilation tables far exceed the amount of RAM even an empty z80 has.
You *could* potentially get around that by making several tables, and using the first letter or two as a table index.... I think that would work, although it would still take up alot of archive space
Success! The only things mine doesn't support now are:
  • set/res/bit
  • binary
And maybe a couple others that I forgot.
Program size: 2077
calc84maniac wrote:
Success! The only things mine doesn't support now are:
  • set/res/bit
  • binary
And maybe a couple others that I forgot.
Program size: 2077


That was fast Surprised
I'll attach the files if someone tells me how (so you can beta test it).
Never mind, I figured it out on my own.
Here's the link.
I assume no responsibility for any RAM resets.
calc84maniac wrote:
Never mind, I figured it out on my own.
Here's the link.
I assume no responsibility for any RAM resets.


Use edit from now on please
Okay. BTW, here are the built-in commands: (no include file needed for these)
ld 8-bit-reg,
add a,
adc a,
sub
sbc
and
xor
or
cp
Could you post the source code?
BASIC Code wrote:
:ClrHome
:Disp "COMPILER v0.5
:Input "prgm",Str0
:Str0
:DelVar Str0Asm(prgmZCOMPILE
:Str0
:DelVar Str0Ans→Str1
:sub(Ans,inString(Ans,"prgm")-1,1→Str8
:Ans→Str9
:Str1+Ans→Str1
:Repeat "prgm"=sub(Str1,1,1
:sub(Str1,1,inString(Str1,Str8)-1
:Asm(prgmZCOMPILE
:Str0
:DelVar Str0Str9+Ans+Str8→Str9
:inString(Str1,Str8
:sub(Str1,Ans+1,length(Str1)-Ans→Str1
:End
:inString(Str1,Str8
:sub(Str1,Ans,length(Str1)-Ans+1→Str1
:"ZCOMPIL2
:Asm(prgmZCOMPILE
:inString(Str1,"(hl)
:While Ans
:sub(Str1,1,Ans-1)+"g"+sub(Str1,Ans+4,length(Str1)-Ans-3→Str1
:inString(Str1,"(hl)
:End
:"AsmPrgm"+Str8→Str7
:40341→M
:"ld b,ld c,ld d,ld e,ld h,ld l,ld g,ld a,add a,adc a,sub sbc and xor or cp →Str3
:cumSum(1,5,5,5,5,5,5,5,5,6,6,4,4,4,4,3,3→L3
:Disp "PART 1:0
:1→B
:Repeat B=length(Str1
:B+1→A
:inString(Str1,Str8,A→B
:sub(Str1,A,B-A→Str2
:Output(8,1,Ans+"
:length(Str2
:If sub(Str2,Ans,1)=":
:Then
:Str9+sub(Str2,1,Ans-1→Str9
:int(M/256
:Str9+expr(Str0→Str9
:256fPart(M/256
:Str9+expr(Str0)+Str8→Str9
:Else
:If inString(Str2,".db
:Then
:5→C
:inString(Str2,",→D
:If not(Ans
:1+length(Str2→D
:Repeat C>length(Str2
:sub(Str2,C,D-C→Str4
:If "h"=sub(Ans,length(Ans),1
:Then
:If 2=length(Ans
:"0"+Ans→Str4
:Str7+sub(Str4,1,2→Str7
:M+1→M
:Else
:If inString("0123456789",sub(Str4,1,1
:Then
:expr(Str4
:Str7+expr(Str0→Str7
:M+1→M
:Else
:expr(Str4→Str4
:M+length(Ans→M
:For(F,1,length(Str4
:Output(7,1,sub(Str4,F,1
:0
:Asm(prgmZCOMPILE
:Str7+expr(Str0→Str7
:End
:End
:End
:D+1→C
:inString(Str2,",",C→D
:If not(Ans
:1+length(Str2→D
:End
:Output(7,1,"
:Else
:If inString(Str2," ([
:Then
:If inString(Str2,"out
:Then
:Str7+"D3??→Str7
:M+2→M
:Else
:If inString(Str2,"]),a
:Then
:Str7+"32????→Str7
:Else
:Str7+"22????→Str7
:End
:M+3→M
:End
:Else
:inString(Str2,"[
:If Ans
:sub(Str2,1,Ans→Str2
:0→C
:Repeat C=16 or Ans
:C+1→C
:inString(Str2,sub(Str3,L3(C),L3(C+1)-L3(C
:End
:If Ans and not(inString(Str2,"(
:Then
:If inString(Str2,"[
:Then
:8C-2+128(C>8
:Str7+expr(Str0)+"??→Str7
:M+2→M
:Else
:55+8C+inString("bcdehlga",sub(Str2,L3(C+1)-L3(C)+1,1
:Str7+expr(Str0→Str7
:M+1→M
:End
:Else
:inString(Str9,Str2→C
:If Ans
:Then
:expr(sub(Str9,C-1,1→D
:C+length(Str2→E
:inString(Str9,Str8,C
:If Ans≠E
:Then
:sub(Str9,E,Ans-E→Str4
:Str7+Ans→Str7
:Else
:"→Str4
:End
:2D-length(Str4
:If Ans
:Str7+sub("????",1,Ans→Str7
:M+D→M
:End
:End
:End
:End
:End
:Output(3,8,int(BE2/length(Str1
:End
:Disp "PART 2:
:Str7+Str8→Str7
:0→B
:While inString(Str7,"?
:inString(Str7,"?→A
:Output(4,8,int(AE2/length(Str7
:sub(Str7,Ans+2,1)="?→F
:inString(Str1,"[",B+1→B
:inString(Str1,"]",B
:sub(Str1,B+1,Ans-B-1→Str2
:Output(8,1,Ans+"
:inString(Str9,Str8+Ans→C
:If C and not(inString("0123456789",sub(Str2,1,1
:Then
:inString(Str9,Str8,C+1→D
:C+1+length(Str2
:sub(Str9,Ans,D-Ans)+"h→Str2
:End
:B-6
:If Ans≤0
:1
:inString(Str1,"jr",Ans),inString(Str1,"djnz",Ans
:If max(Ans and Ans<B
:Then
:sum(seq(16^(4-X)(inString("0123456789ABCDEF",sub(Str2,X,1))-1),X,1,4))-40341-.5(A-1
:If Ans<0
:Ans+256
:sub(Str7,1,A-1)+expr(Str0)+sub(Str7,A+2,length(Str7)-A-1→Str7
:Else
:If inString(Str2,"h
:Then
:While 5≠length(Str2
:"0"+Str2→Str2
:End
:sub(Str7,1,A-1)+sub(Str2,3,2
:If F
:Ans+sub(Str2,1,2
:Ans+sub(Str7,A+2+2F,length(Str7)-A-2F-1→Str7
:Else
:expr(Str2→D
:256fPart(D/256
:expr(Str0→Str2
:If F
:Then
:int(D/256
:Str2+expr(Str0→Str2
:End
:sub(Str7,1,A-1)+Str2+sub(Str7,A+length(Str2),length(Str7)-A+1-length(Str2→Str7
:End
:End
:End
:Output(4,8,E2
:DelVar Str1DelVar Str2DelVar Str3DelVar Str8DelVar Str9DelVar L1DelVar L2DelVar L3sub(Str7,1,length(Str7)-1→Str7
Generated by SourceCoder, © 2005 Cemetech
What is zcompile?
It's the asm subroutine.
Inputs:
String: Copies program whose name is in string into Str0.
Otherwise: Returns the ASCII code for whatever is at row 7, col 1. (For use with .db)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
Page 1 of 9
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement