-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advanced assembler #6
Comments
What is missing exactly? I have not integrated sjasmplus or fasm because there are external binaries. To make the VS Code extension work on any platform, I would have to compile and package those binaries for macOS, Linux and Windows. The embedded assembler is entirely written in Typescript so it does not have such a problem. |
For starting - and this is really the bare minimum - the complete usable instruction set (meaning also the "documented undocumented"). But there are also a lot of useful directives that are of real help in complex projects: conditional compilation, complex expressions (with a lot of operators and predefined symbols), advanced relocation facilities (eg DISP of sjasmplus), includes/macros, syntactic sugar (eg pseudo ops), structures, etc. (you can look here http://z00m128.github.io/sjasmplus/documentation.html and https://flatassembler.net/docs.php?article=fasmg_manual). Not everyone use everything, but believe me that even just myself in my last endeavor (the original 1k real chess) in the 10k lines source code I used a lot of those things during development. That said, with a proper subset it can be done with little additional effort or complexity, but some of them should be implemented to use this IDE for advanced projects. The portability and usability is surely a very good thing, maybe the cosmopolitan C compiler might help in case? (https://github.com/jart/cosmopolitan). |
Do you have a link to the original 1k chess so I can figure out what is needed? |
The source is a personal project and I have in another house. Anyway if you want you can contact me in private and I can send you the current files in few days. As said anyway my one is just an example, there are surely many people with different cases (e.g. looking also on the various cases they found for some of the issues open and closed in sjasmplus repo!). PS: not sure how complex it could be to extend at a proper level the assembler, but if you want to follow this endeavour I can at least be a tester :) |
I see two possibilities (one does not exclude the other):
So the only more complex features are struct and macros. They look quite feasible. I will think a little more about all this. |
I saw that in the meantime you have improved this already nice extension fork! Among the other things I saw that there is the support for sjasmplus, and I'm not sure if you also improved the internal assembler. I was trying to find some related documentation but I was not able to find it (i.e. how to use it with sjasmplus or the instructions/directives available for the internal one). There is already somewhere and I didn't find? |
Seems to work if I put a .sld and a .P with the same name already compiled with sjasmplus. Is this the way? Regarding the assembler I tried the undocumented instructions (e.g. ld iyh,1) but wasn't working. Anyway it compiled a pretty complex program (sample2.zx81.txt, found on forum and used just to test), even if at the end was not able to execute it, I think since it uses a starting approach that is not the standard (and simple) one proposed by the hello world. For this purpose maybe can be managed having another device directive to distinguish between the two options. |
yes
Undocumented instructions are not yet supported. |
If you want you can give me some indication and I can prepare a pull request with the draft update of the grammar and machinecode for the missing ones. |
It will take me more time than doing it myself.
As you can now use other assemblers (such as sjasmplus), I do not see the point of creating a PR now. I do not have the time to make such a review. I will enhance my assembler one day, but not in a short term. |
What abouth the "non standard" program startup (e.g. the sample2.zx81.txt mentioned above) ? |
More as a curiosity than real high expectations I tried to propose "Manus" the task with a simple prompt: "This link https://github.com/stevexyz/z80-assembler-andrivet points to a git hub repository of a Z80 assembler. I want you to propose the modifications needed to manage also the "undocumented Z80 documented" instructions." To you to judge the result!...(I'm pretty impressed!) Proposed Modifications for Supporting Undocumented Z80 InstructionsBased on my analysis of the Z80 assembler repository and research on undocumented Z80 instructions, I've identified the necessary modifications to support these instructions in the assembler. Overview of Undocumented Z80 InstructionsThe Z80 CPU contains several undocumented instructions that aren't officially documented by Zilog but are widely used in certain applications. These instructions include:
Required Modifications1. Modify LowLevel.tsThe // Add support for IXH, IXL, IYH, IYL in r_bits function
export function r_bits(r: string, offset = 0): byte {
switch(r.toLowerCase()) {
case 'b': return 0b000 << offset;
case 'c': return 0b001 << offset;
case 'd': return 0b010 << offset;
case 'e': return 0b011 << offset;
case 'h': return 0b100 << offset;
case 'l': return 0b101 << offset;
// Add undocumented registers
case 'ixh': return 0b100 << offset;
case 'ixl': return 0b101 << offset;
case 'iyh': return 0b100 << offset;
case 'iyl': return 0b101 << offset;
case 'a': return 0b111 << offset;
default: console.log(`Invalid register name: ${r}`); return 0;
}
} 2. Modify z80.peg Grammar FileThe 2.1 Add Register Definitions
2.2 Add Undocumented Load Instructions
2.3 Add Undocumented Arithmetic Instructions
2.4 Add SLL Instruction
2.5 Add Undocumented IN/OUT Instructions
3. Update z80.tsThe export enum ASTKinds {
// Existing kinds...
// Add new kinds for undocumented registers
IXH = "IXH",
IXL = "IXL",
IYH = "IYH",
IYL = "IYL",
} Implementation Strategy
Testing StrategyFor each phase of implementation:
ConclusionThe proposed modifications will enable the Z80 assembler to support the undocumented Z80 instructions. These changes primarily involve updating the grammar definitions in the |
@stevexyz Since those modifications are for the Z80 assembler, this is not the right repository for this. As I also mentioned, I do not have the time right now to look at this topic. I also do not understand why you have made a fork (without any modification) with my name in the name of the fork. This is confusing and a little disturbing. |
Sorry, I made a fork since I was thinking to try to change it myself. I've added your name to make clear that was your own one (Z80 assembler was pretty generic as a name). Since your feedback I deleted it. The above post was me surprised about the quality of current AI!.. Never mind. Sorry for the post. Happy hacking. |
Thanks for the clarification. I am not sure to fully understand your last message. You mean you generated the code you mentioned by AI ? |
Yes, I just simply said to Manus:
Above I pasted the "raw" output I've received after around 150 seconds of reasoning (that was already formatted in markdown, including "Proposed Modifications for Supporting Undocumented Z80 Instructions" title): for me is pretty impressive, I was just sharing the awareness of this capability and also curious to know your opinion about the result (since you know better your repository)!... |
I look a little at the code generated by AI and it is very wrong. The syntax does not make sense. This is the problem of LLM when using them for very specific (and niche) things such as custom languages. It looks promissing on the surface, but in fact, it makes more work to find all the mistakes than doing things from scratch. IMPORTANT: Please do not continue the conversation here. This is not the right repository. The Z80 Assembler is here: https://github.com/andrivet/z80-assembler |
This is a wonderful project. And surely very nice for a beginner to jump start ZX81 assembler development!
The main limitation I see is related to the assembler, unfortunately very underpowered for more advanced needs (e.g. I’m trying to create a new version of the 1K Real Chess for ZX81),.
Without reimplementing things (standard undocumented instructions, powerful directives, etc), would it be possible to integrate a more powerful ready one as for example sjasmplus (https://github.com/z00m128/sjasmplus) or fasm/fasmg (https://github.com/jacobly0/fasmg-z80)?
The text was updated successfully, but these errors were encountered: