flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > eZ80 includes for fasmg

Author
Thread Post new topic Reply to topic
jacobly



Joined: 04 Feb 2016
Posts: 44
jacobly 30 May 2016, 03:43
I started working on an ez80 include for fasmg a while back due to a lack of good ez80 assemblers. I finally got it working, and have successfully tested it with every ez80 instruction. The code is at https://github.com/jacobly0/fasmg-ez80. It could even be used to compile z80 code if the
Code:
assume adl = 0    
directive is used, and all of the ez80 specific instructions are avoided. I will probably go back and clean it up at some point, and add more specific errors, but it works which is good enough for now.
Post 30 May 2016, 03:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 30 May 2016, 03:46
I'm wondering if this should be in the "Non-x86 architectures" forum?
Post 30 May 2016, 03:46
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 30 May 2016, 10:32
revolution wrote:
I'm wondering if this should be in the "Non-x86 architectures" forum?
Perhaps the problem might be that people are looking for a specific forum dedicated to fasmg. But I think that "fasmg" in the thread title should be enough, plenty of topics are marked this way already. I moved this thread but left the reference in the original forum.

jacobly: great work! I see that you used many nice tricks that are very different from anything I have done in my samples. I wanted to have a diverse set of examples, but still mine are a bit schematic and repetitious - therefore I'm really glad to see people able to contribute in such interesting ways.
Post 30 May 2016, 10:32
View user's profile Send private message Visit poster's website Reply with quote
connor



Joined: 07 Jun 2016
Posts: 79
connor 10 Jun 2016, 04:53
Does it 8080?

_________________
cars tech weed bitches country & thug life
Post 10 Jun 2016, 04:53
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Jun 2016, 10:12
for 8080 look there
Post 13 Jun 2016, 10:12
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 27 Jul 2016, 09:15
In some spare time I was trying to build the Z80 compiler myself...
Good that I was so slow: this version is much better of current mine!
I'm trying to recompile with it a little modified version of the Super Micro Chess ZX81! Smile
Bravo jacobly!!
Post 27 Jul 2016, 09:15
View user's profile Send private message Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 28 Jul 2016, 17:56
I managed to compile the first version of the source! Smile

Two notes for information:

1. @jacobly: don't know why but long addresses were always outputted as long instead of word. I had to force word changing the macro ez80.word:

Code:
macro ez80.word value
;       if ez80.il
;               ez80.long value
;       else
                dw value
;       end if
end macro
    


2. @Tomasz: I used the listing macro discussed in the other topic, but if you redirect output to listing file you loose the compiler output, and if not redirect they are mixed with listing. One possible solution might be to redirect compiler output and "display" instruction output (I use for some info) on stderr
(PS: I was using as legacy windows version since FASMW, now I can move to linux one! Smile)
Post 28 Jul 2016, 17:56
View user's profile Send private message Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 28 Jul 2016, 18:18
PS for point 2: proposed solution do not work since also listing macro use display!!
Another solution have to be found, as for example giving an optional parameter to display instruction to indicate a file to write
Post 28 Jul 2016, 18:18
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2016, 18:48
marste wrote:
PS for point 2: proposed solution do not work since also listing macro use display!!
Another solution have to be found, as for example giving an optional parameter to display instruction to indicate a file to write
The listing macro could be supplemented to override the "display" instruction and gather all these texts to display them in a separate block.
Post 28 Jul 2016, 18:48
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2016, 19:17
Actually, the quickest solution would be to define a macro like this:
Code:
define ldisplay 13,10,10,'LISTING',13,10,10

macro ldisplay args&
        define ldisplay. args
end macro

postpone
        irpv d, ldisplay
                display d
        end irpv
end postpone    
and then in the listing macros replace every occurrence of "display" with "ldisplay". This will separate the listing from all the other displayed texts.
Post 28 Jul 2016, 19:17
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 01 Aug 2016, 16:19
For some reason seems postpone is very much postponed... but I cannot say how to change:

Code:
include 'ez80.inc'

;-----------------

define Listing

define ldisplay 13,10,10,'LISTING',13,10,10

macro ldisplay args&
        define ldisplay. args
end macro

postpone
        irpv d, ldisplay
                display d
        end irpv
end postpone

namespace Listing
        base = $$
        offset = $
        macro disphex number*,digits:8
                repeat digits
                        digit = ((number) shr ((%%-%) shl 2)) and 0Fh
                        if digit < 10
                                ldisplay '0'+digit
                        else
                                ldisplay 'A'+digit-10
                        end if
                end repeat
        end macro
end namespace

macro ? line&
        line
        namespace Listing
                if ~ $$ eq base
                        base = $$
                        offset = $$
                end if
                bytes = $ - offset
                if $ - bytes < $$
                        bytes = $ - $$
                end if
                offset = $
                disphex (offset scale 0)-bytes,8
                ldisplay ': '
                column = 0
                while bytes
                        if column = 8
                                column = 0
                                ldisplay 13,10,'          '
                        end if
                        load data:byte from $ - bytes
                        disphex data,2
                        ldisplay ' '
                        bytes = bytes - 1
                        column = column + 1
                end while
                repeat 8-column
                        ldisplay '   '
                end repeat
                ldisplay `line,13,10
        end namespace
end macro

;-----------------

        nop
        jp test
        nop
        jr test
        nop
        ld a,(test)
        nop
test:   nop
        nop
    



Result:
Code:
$ ./fasmg.exe test.asm test.bin
flat assembler g  version 0.97.1467376867


LISTING

>>>>>>>>: >>                      nop
>>>>>>>>: E> >E >>                jp test
>>>>>>>>: >>                      nop
>>>>>>>>: >> >>                   jr test
>>>>>>>>: >>                      nop
>>>>>>>>: >E >E >>                ld a,(test)
>>>>>>>E: >>                      nop
>>>>>>>E: >>                      test: nop
>>>>>>>E: >>                      nop

2 passes, 14 bytes.
    


Original output without "postponed" ldisplays:
Code:
$ ./fasmg.exe test_orig.asm test_orig.bin
flat assembler g  version 0.97.1467376867
00000000: 00                      nop
00000001: C3 0C 00                jp test
00000004: 00                      nop
00000005: 18 05                   jr test
00000007: 00                      nop
00000008: 3A 0C 00                ld a,(test)
0000000B: 00                      nop
0000000C: 00                      test: nop
0000000D: 00                      nop

2 passes, 14 bytes.
    
Post 01 Aug 2016, 16:19
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 01 Aug 2016, 17:29
Oh, right, postponed display of a variable does not work well. Smile
To fix it, replace the definition of "ldisplay" with this one:
Code:
macro ldisplay args&
        local str
        virtual at 0
                db args
                load str : $ from 0
        end virtual
        define ldisplay. str
end macro    
Post 01 Aug 2016, 17:29
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 04 Aug 2016, 16:13
Very good, like this is almost a normal listing! Smile

Thank you!!
Post 04 Aug 2016, 16:13
View user's profile Send private message Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 21 Mar 2017, 18:18
Another question that will be good for a debugger input: is possible to add the source filename and source line together with the current assembled address?

E.g. (just to give the idea, formatting can be different)
Code:
00000000 (pippo.asm,1):  00                      nop
00000001 (pippo.asm,2):  C3 0C 00                jp test
00000004 (pippo.asm,4):  00                      nop
00000005 (pippo.asm,5):  18 05                   jr test
00000007 (test.inc,1):   00                      nop
00000008 (test.inc,2):   3A 0C 00                ld a,(test)
0000000B (pippo.asm,8):  00                      nop
0000000C (pippo.asm,9):  00                      test: nop
0000000D (pippo.asm,10): 00                      nop
    
Post 21 Mar 2017, 18:18
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 21 Mar 2017, 19:12
Try replacing this line in listing macro:
Code:
                 ldisplay ': '    
with:
Code:
                repeat 1, n:__line__
                    ldisplay ' (',__file__,',',`n,'): '
                end repeat    
It uses fasm's "repeat 1" trick to convert the value of __line__ into a decimal string.
Post 21 Mar 2017, 19:12
View user's profile Send private message Visit poster's website Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 21 Mar 2017, 21:15
Tomasz Grysztar wrote:
Try replacing this line in listing macro:
Code:
                 ldisplay ': '    
with:
Code:
                repeat 1, n:__line__
                    ldisplay ' (',__file__,',',`n,'): '
                end repeat    
It uses fasm's "repeat 1" trick to convert the value of __line__ into a decimal string.


Seems working well! Smile

Let's see how it will be for debugging info of zesaurux.

In the meantime thank you again!!
Post 21 Mar 2017, 21:15
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 804
Location: Russian Federation, Sochi
ProMiNick 16 Jun 2017, 00:03
...ti84pceg.inc [37]:
include 'ti84pce.inc'
Processed: include 'ti84pce.inc'
Error: source file not found.

Where I can get this include?
Post 16 Jun 2017, 00:03
View user's profile Send private message Send e-mail Reply with quote
marste



Joined: 05 May 2015
Posts: 44
marste 16 Jun 2017, 08:59
ProMiNick wrote:
...ti84pceg.inc [37]:
include 'ti84pce.inc'
Processed: include 'ti84pce.inc'
Error: source file not found.

Where I can get this include?


I think this has nothing to do with ez80 includes nor with fasm. Probably TI Calc forums are a better place to ask.
Post 16 Jun 2017, 08:59
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 804
Location: Russian Federation, Sochi
ProMiNick 10 Jan 2018, 10:24
Jacobly, can you sent ROM Image (or couple of images) to play with?
(I interested not in ez80 exactly, but in architectures other than x86 with opensource emulator of that architecture in win32 or win64 environment (with everything needed to make it work, like ROM images in case of ez80) and opened (or already adapted to fasmg syntax) opcode set ) for playing (compiling src in fasmg & running it in native environment in emulator, and than exploring sources of emulator itself).

prominick.nvkz.sochi@gmail.com

no needed in ROM. I thought sharing it in internet is illegal. But found couple of ROMes.

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 10 Jan 2018, 10:24
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.