flat assembler
Message board for the users of flat assembler.
Index
> Non-x86 architectures > FASM for Zilog Z80 CPU Goto page Previous 1, 2, 3 Next |
Author |
|
shutdownall 15 Jan 2012, 00:14
So here is a first version of FASM for Z80.
The instruction set is fully implemented and tested against Z80 documentation. So here I have to warn to use original document on Zilogs Website called UM0080. http://www.zilog.com/docs/z80/um0080.pdf This document has several errors in coding the instructions, mainly copy & paste errors while forgotten to edit the pasted code. I mailed the errors to Zilog in novembre and got some positive feedback and thanks but this document on the webserver is still unchanged. If you want to check please use this older document, called PS0178 which is only a PDF with scanned datasheet but the content is correct. The other one was new typed in good quality but with several mistakes. http://www.zilog.com/docs/z80/ps0178.pdf In the next days and weeks I will test this version against other cross assemblers with some big source listings. In my eyes the compiler is correct and all statements tested manually but you never know. So this is a pre release and marked with a special version string in the window title. "1.69.35.testversion-for-z80". And this version supports only Z80 instruction set and all preprocessor and macro definitions defined for the original FASM (x86 version). Zilog has a special syntax which is different from Intel syntax regarding memory referencing. Intel used [] for referencing memory while Zilog uses (). Due to compatibility to already written source code and to other cross assemblers this version supports both writings, either [] or (). I hope the code is intelligent enough to distinct immediate calculations with () in most cases but not sure for any possible (thinkable) case. Here are all versions (WIN / DOS / LIBC / LINUX) posted in one ZIP archive. It contains the actual version 1.69.35 of FASM (but changed for Z80). Tomorrow I will poste a short tutorial how to update / integrate this instruction set in later (newer) versions of FASM. I would appreciate any feedback, especially found errors with (maybe partly) source and what the result (output binary) should be.
|
|||||||||||
15 Jan 2012, 00:14 |
|
shutdownall 18 Jan 2012, 13:28
Here I have an instruction manual how to implement Z80 instruction set in newer version of FASM. Now it is implemented in the last version 1.69.35 or maybe somebody have for particular reason changed something in FASM.
By the way I corrected one error because syntax change from () to [] was prohibited when using definition like db 10h dup('0ffh') but only for db because funtion was looking for db definition only. The following definitions would give errors: dw 10h dup('0ffh') dd 10h dup('0ffh') dq 10h dup('0ffh') and so on. Now I am prooving for the 'dup' function not for db instruction. Because of futher testing I do not post a new version by now, think have to change maybe more but not sure. I want to avoid inflation of version. So keep this information as a known error.
|
|||||||||||
18 Jan 2012, 13:28 |
|
TmX 18 Jan 2012, 16:48
Looks interesting.
Can I use this on simulator? I don't have any Z80 devices. |
|||
18 Jan 2012, 16:48 |
|
shutdownall 18 Jan 2012, 17:50
Sure, if you have a simulator for Z80 you can create binary code and let it run on the simulator.
Now I am testing and I found some errors in some cases. So I will update this version in a few days. Errors: EX AF,AF' not supported, workaround use EX AF,AF If possible avoid use of $ as this could cause some errors when compiling when using special values. LD ($400C),A gives error, workaround use LD (400Ch),A INC (HL) INC (IX+n) INC (IY+n) not work, same with DEC Workaround: use [] instead of () So I found some side effects when changing syntax written before. All solved by now but I want to do more testing with Z80 source listings. These errors are found when compiling, so don't worry about code written into binary (is correct after successful compiling). |
|||
18 Jan 2012, 17:50 |
|
edfed 18 Jan 2012, 23:59
problem with () for mem addresing is:
example in x86 Code: mov eax,[10+90];here, ok, it is memory mov eax,(10+90);hem, immediate or memory, really confusing syntax... mov eax,10+90 ;here, ok, it is immediate that's just a question of syntax. if human cannot determine what it is, how a machine can do? syntax is not the cpu, nor it is the obsolete documentation about obsolete hw. then at least, you can try to strictlly use [] for memory in assembler. it is a very nice way to code it also, [] looks really like a memory case. () looks more like bubbles in comics, then is good for algebric expressions. |
|||
18 Jan 2012, 23:59 |
|
shutdownall 19 Jan 2012, 14:25
I think you never programmed a Z80 processor before, otherwise you would not think this way and would not ask these questions.
Code: mov eax,[10+90];here, ok, it is memory mov eax,(10+90);hem, immediate or memory, really confusing syntax... mov eax,10+90 ;here, ok, it is immediate It is not really confusing, Z80 supports for memory addressing only 2 forms, one with registers and one with a 16 Bit immediate. here are register options LD A,(HL) LD A,(IX+5) LD A,(IY-7) or a 16 bit memory address without register LD BC,(1234h) LD (5678h),SP As there is no register in the last two instructions, this is a memory referencing. For immediates, there are no brackets expected. I think people did calculation in assembler not in the line for memory movement and should use a variable. Problematic is only use of obselet brackets with numbers, which maybe interpreted as memory referencing but meaned are immediate values. LD BC,55AAh is immediate LD BC,(55AAh) is memory referencing LD BC,(1010h+40h)*2 is immediate LD BC,((1010h+40h)*2) is memory referencing Thats the way the parser works. Checks for value in brackets (without any other data/variable outside brackets). What it makes complicate are some optional white space in the code. But I could improve the parser in a few days. With respect, this is the first version. FASM also wasn't build in one day ore one week or one month. LD A , ( HL ) LD A, ( IX + 5 ) And it makes not much sense to tell Z80 programmers what syntax has to be used (this would reduce acceptance of FASM for Z80 developments significantly) and it is not compatible to existing source (which would also reduce acceptance significantly). Take a look at this listing. http://www.wearmouth.demon.co.uk/zx81.htm This will not work with the last uploaded code due to some corrections but I want to do further testing before releasing an official version. After some modifications last night this is compiled correctly the only thing is to change the 3 defines in the source (which are made for TASM). #define DEFB .BYTE ; TASM cross-assembler definitions #define DEFW .WORD #define EQU .EQU change to define DEFB db define DEFW dw ; define EQU (comment out) define .END (undefine .END as there is no statement for FASM) Maybe this could also be changed using a macro, if one macro expert want to help, any help is appreciated. FASM now accepts the coding for binary values like this %00011100 which is internally changed to 00011100b So I will keep on testing more this week and maybe post a release candidate on sunday evening. |
|||
19 Jan 2012, 14:25 |
|
edfed 19 Jan 2012, 14:50
Quote: syntax is not the cpu, nor it is the obsolete documentation about obsolete hw. then at least, you can try to strictlly use [] for memory in assembler. it is a very nice way to code it also, [] looks really like a memory case. () looks more like bubbles in comics, then is good for algebric expressions. + no need to code with to see the uglyness of this syntax, that's all. |
|||
19 Jan 2012, 14:50 |
|
shutdownall 20 Jan 2012, 12:22
edfed wrote:
Maybe - but this is not your choice. I think even MS OSes are ugly designed but who cares ? Take it or leave it - the same with Z80. Maybe it's not the CPU for you. But [] is still supported for memory referencing. |
|||
20 Jan 2012, 12:22 |
|
shoorick 20 Jan 2012, 13:06
yes, even if somebody will rewrite z80 syntax using same opcodes (similar like z80 inherits same i8080 opcodes with different mnemonics) - who then will use it: incompatible and confusing?
|
|||
20 Jan 2012, 13:06 |
|
shutdownall 20 Jan 2012, 13:36
Not sure what you mean but I will name [] support for memory addressing the "edfed-feature".
But now I found some more complex situations. 1. Use of undocumented (non-official but working) opcodes found in one source of the ZX Spectrum 2. Use of labels without ':' found in one big listing - Don't know by the way if these points are supported in other Z80 cross assemblers. |
|||
20 Jan 2012, 13:36 |
|
shutdownall 20 Jan 2012, 15:42
So here I publish the first release of FASM for Z80 instruction set.
Some errors where removed/corrected and was tested with some big source code listings: Sinclair ZX80 rom listing http://www.wearmouth.demon.co.uk/zx80.htm Sinclair ZX81 rom listing http://www.wearmouth.demon.co.uk/zx81.htm Jupiter Cantab Ace rom listing http://www.wearmouth.demon.co.uk/ace.htm Sinclair ZX Spectrum IF1 rom listing http://www.wearmouth.demon.co.uk/if1_2.htm The output binary was prooved against delivered binaries (rom codes) of the emulator EightyOne (EO), well known for 80's computer developpers. The binary from the source code extracted from this FASM version are 100% identical. http://www.aptanet.org/eightyone/ There are now 2 points open: 1. Only the official instruction set of Z80 is implemented now. Has some undocumented instructions which maybe added later. These instructions work on the CPU's but never official published by Zilog. 2. I found some source code listings which use labels without ':' character at the end. So this could be fixed by the pre-pre-processor to interprete all as label what starts at the first character of a line and expect minimum one whitespace character before entering instructions. In fact I am not 100% sure of it and asked some people very familiar with Z80 programming what they think about it and what other cross assemblers support.
|
|||||||||||
20 Jan 2012, 15:42 |
|
shoorick 22 Jan 2012, 17:57
i ment let it be as is is Z80 syntax good or not - we can not change the past
|
|||
22 Jan 2012, 17:57 |
|
shutdownall 22 Jan 2012, 19:24
Yes thats the point.
|
|||
22 Jan 2012, 19:24 |
|
revolution 24 Jan 2012, 12:44
edfed wrote: problem with () for mem addresing is: |
|||
24 Jan 2012, 12:44 |
|
shutdownall 09 Dec 2012, 14:47
So here is a new version of FASM for Z80, right before christmas.
I updated to the newer version 1.71.01 as this supports more flexibility for using virtual address spaces (copying codeblocks across). So this will be the base for my ZX81 IDE supporting mixed Z80 assembler and ZX81 BASIC instrucitons. Nothing to worry about, this version supports Z80 assembler only. I have some instructions/informations added in a README.TXT printed here for first information: Quote:
|
|||||||||||
09 Dec 2012, 14:47 |
|
shutdownall 09 Dec 2012, 21:02
Sorry but found some bug during further tests in the preprocessor extension for supporting () memory referencing with () and []. Did not use the latest version.
And forgot to attach one source file found right now when tried to recompile. So now it should be okay.
|
|||||||||||
09 Dec 2012, 21:02 |
|
prlaba 25 Jul 2013, 12:00
shutdownall,
I don't know if you're still following this thread, but I wanted to say thanks for the great job you did producing this z80 version of fasm! It's just what I've been searching for. All seems to be working great except the automatic listing file feature described in your README file. When I used the 'Build symbols + listing' menu option (Ctrl+, I end up with a binary (.bin) and symbol (.fas) file, but no listing (.lst) file. I can run LISTZ80.EXE from a command prompt to generate the listing file manually, but I can't seem to get the automatic listing to happen. Both the FASMW80.EXE and LISTZ80.EXE executables are in the same directory, as instructed in the README file. Any suggestions? |
|||
25 Jul 2013, 12:00 |
|
prlaba 25 Jul 2013, 14:09
Here's an oddity I just ran into with FASMWZ80 re binary (.bin) files:
I initially tested shutdownall's FASMWZ80 assembler by creating a very simple 2-line Z80 program, then used the 'Build symbols + listings' menu option to assemble the program. It produced two files: a binary (.bin) file and a symbols (.fas) file (it did not produce a list (.lst) file as expected; see my previous post). I opened the .bin file in a hex editor and confirmed that the file's contents were as expected. I then took an existing and more 'complex' Z80 program source file and, after making a bunch of changes to match fasm's directives (it was originally written for a different assembler), opened it in FASMWZ80. When I used the 'Build symbols + listings' menu option to assemble the program, it produced a .com file (?) and .fas file, but no .bin file. Huh? Can someone explain why FASMWZ80 generated .bin and .fas files for my simple 2-line program, but generated .com and .fas files (and no .bin file) for my longer program? |
|||
25 Jul 2013, 14:09 |
|
prlaba 25 Jul 2013, 14:19
I just answered my own question re the .bin file. It's the presence or absence of an 'org' directive in the source file that determines which file -- .com or .bin -- gets generated.
If the source file contains an org directive, then a .com file is generated. If no org directive is included, then a .bin file is generated. Not exactly sure if this is a bug or by design, but that appears to be how it works. |
|||
25 Jul 2013, 14:19 |
|
Goto page Previous 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.