News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_roudoudou

Rasm Z80 assembler

Started by roudoudou, 08:58, 22 February 17

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

krusty_benediction

It is currently only a library ;not an executable able to assemble any file.I have not implemented all the mnemonics and directives. Only the things I needed to advance.
I have a parser that generates tokens from a source code. These same tokens can be generated (to noyt code the effect myseld) or manipulated (to optimize or inject specific code at specific place/moment) by my other demotools.
And I have the assembler that transform these tokens in a stream of bytes. My other tools inject them in a snapshot.
So barely useable by someone else ;) If you are curious, everything is there: https://github.com/cpcsdk/rust.cpclib/tree/master/src/assembler

roudoudou

Quote from: krusty_benediction on 00:19, 28 December 18
There is a simple routine that must be played at a certain frequency. Usually we manually compute the number of nops it takes in order to add filling instructions to have the right duration.Its booooring, especially when you forget the timing. So I have added 2 directives to delegate the job to the assembler:- stableticker that counts the number of nops and store them in a variable- duration that can be used in any expression and provide the number of nops of its instruction
I've done the ticker  ;)
update v0.105- bugfix wrong error with operator+non decimal negative value
- do not allow CALL (IX) or CALL (IY) syntax
- added comments begining with //
- added SIZEOF support for fields of structures
- new directive TICKER to count instruction duration
New French and English documentation by Siko (Stéphane S.) in the first post 8)

My pronouns are RASM and ACE


roudoudou

update v0.106

- multi-line comments with /*  */

update v0.107
- colored output with Unix terminal- trigger error if a (VOID) arg is used with a macro which has parameter(s)
- added Vasm syntax ENDREP and ENDREPEAT to end a REPEAT block
- enforce zero result when there is an error in a calculation
- new directives NOEXPORT/ENOEXPORT to disable/enable on demand symbol export
My pronouns are RASM and ACE

norecess464

My personal website: https://norecess.cpcscene.net
My current project is Sonic GX, a remake of Sonic the Hedgehog for the awesome Amstrad GX-4000 game console!

HAL6128

Really cool progress. Would it also possible to have (oldschool) .PHASE and .DEPHASE directives , like in the M80 assembler?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

roudoudou

Quote from: HAL 6128 on 20:20, 16 January 19
Really cool progress. Would it also possible to have (oldschool) .PHASE and .DEPHASE directives , like in the M80 assembler?
I may add it in the next release, but you can do it already with macros  ;D
macro phase adr
org {adr},$
mend
macro dephase
org $
mend
My pronouns are RASM and ACE

HAL6128

...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Targhan

#183
What would you think the best way to emulate the MAP feature of SJAsmPlus:



   MAP 8
Label # 2     ; Label=8
Kip   # 3     ; Kip=10
Kop   #       ; Kop=13
Kop2  # 1     ; Kop2=13

I would like to avoid doing this:
Start equ #4000
Stuff1 equ Start + 0
Stuff2 equ Start + 1
Stuff3 equ Start + 3
...
Ideally, I'd like to declare the size of each item:
Start <struct> #4000
stuff1 <declare byte>     ;stuff1=#4000
stuff2 <declare word>    ;stuff2=#4001
stuff3 <declare word>    ;stuff3=#4003
...
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

roudoudou

you have the STRUCT directive

struct targhan
stuff1 defs 1
stuff2 defs 4
stuff3 defs 2
stuff4
endstruct

nocode
org #4000
struct targhan m4
code

; m4.stuff1=#4000
; m4.stuff2=#4001
; m4.stuff3=#4005
; m4.stuff4=#4007
My pronouns are RASM and ACE

Targhan

Ahhhh good. I knew about Struct, but forgot about the "nocode" directive. Thanks!!
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime


roudoudou

Quote from: krusty_benediction on 13:35, 23 January 19
I think it is not documented; I discovered it in the post
These directives are obsolete. They were used in Maxam in order to create kind of structures.
I realize now that we can have a more modern usage  :D
My pronouns are RASM and ACE

GUNHED

Well, IMHO nocode is really useful, every assembler should understand it. I work with Z80, I have my style and I don't need anything modern.  ;D ;) :)
RASM is great, and Maxam compatibility is (for me) the most important thing.  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Targhan

It works, but makes the code a bit complicated :). The ORG change is problematic, so I have to save it and restore it then:
SaveOrg = $
...
org SaveOrg


But it works :).
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

roudoudou

#190
Quote from: Targhan on 19:26, 23 January 19
It works, but makes the code a bit complicated :) . The ORG change is problematic, so I have to save it and restore it then:
SaveOrg = $
...
org SaveOrg


But it works :) .
I will read again the MAXAM doc about the behaviour of CODE/NOCODE

My pronouns are RASM and ACE

GUNHED

Assembling in RAM: NOCODE will stop putting bytes into RAM, when using CODE the bytes are again written in RAM, at the right address.

Assembling to disc: NOCODE stops writing bytes to the output file (binary), then the CODE command will again write the bytes to the file, but the gap in between will NOT be filles with zeros.

So after NOCODE and CODE the binary output file will have a gap and the bytes written after CODE are to early in the file.

Usage of NOCODE: Very nice when testing, but you don't want to write to RAM or file.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

roudoudou

Thanks Gunhed so the actual NOCODE is legacy but i may add an option to CODE to get the previous $
CODE NOGAP or something like this?
My pronouns are RASM and ACE

Targhan

Advice needed. The Arkos Tracker players have duplicated code (for each channel). I'd like to avoid this, but this is tricky. Maybe one of you can enlighten me on how to improve this.

I know I can use macro and local labels.

MACRO ManageNote
ld hl,(@stuff + 1)
@stuff ld de,#4000
ENDM

ManageNote ;For channel 1
ManageNote ;For channel 2
ManageNote ;For channel 3

The problem is, I would like to have these macros to address labels from the related channel.

MACRO ManageTrack
ld hl,(@stuff + 1)     ;From the macro above!!
ld de,12
add hl,de
ENDM

ManageTrack ;For channel 1
ManageTrack ;For channel 2
ManageTrack ;For channel 3

How is it possible? I should be able to generate labels, maybe from placeholder and parameters in the macro, but it probably won't work...
... After testing... YES IT WORKS!! Damn, this is great!

        MACRO test chan
         defb {chan}
stuff{chan} ld a,0
        ENDM
       
        test 1     ; This generated a "stuff1" label!
        test 2     ; This generated a "stuff2" label!

This is amazing!! Well done Roudoudou!! This is crazy stuff. Ok, I guess I have found my solution, but if anyone want to add it 2 cents, thanks :).
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

roudoudou


update v0.108

- allow var name beginning with '_'

- CODE directive may retrieve last outputed byte adress



org #100
nocode
nop
code
print $ ; #101

org #200
nocode
nop
code skip
print $ ; #200

My pronouns are RASM and ACE

HAL6128

Hi roudoudou,
a question regarding the 'save' directive: what are the options for overwriting an existing file on a DSK?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

roudoudou

Quote from: HAL 6128 on 15:17, 28 January 19
Hi roudoudou,
a question regarding the 'save' directive: what are the options for overwriting an existing file on a DSK?
this is the -eo option with the command line
My pronouns are RASM and ACE

krusty_benediction

Here is another directive suggestion for rasm LOCOMOTIVE/ENDLOCOMOTIVE in order to generate basic bootstrap code that launches the binary file.I've just validated the concept with my prototype assembler.
Here is the sample file I have produced (and I have enclosed the generated file):

    LOCOMOTIVE code
10 ' Hello world
20 call {code}
    ENDLOCOMOTIVE

code

    di
        ld hl, 0xc9fb
        ld (0x38), hl
    ei
   
    ld bc, 0x7f10 : out (c), c
    ld a, 0x40 : out (c), a
    jp $


The assembler generates the tokens of the basic program.One of the instruction is call {code} where {code} is replaced by the value of the label {code} in the assembly code. So any {XXX} is replaced by the value of XXX in the symbole table if XXX is provided as an argument of LOCOMOTIVE

It is probalby interesting to add specific comments that contain tags asking to hide some basic lines (for a demo line 20 should be hidden).




roudoudou

#198
would be such a huuuuuuuuuuuge work

ps: PDF documentation updated!
My pronouns are RASM and ACE

roudoudou

Quote from: HAL 6128 on 15:17, 28 January 19
Hi roudoudou,
a question regarding the 'save' directive: what are the options for overwriting an existing file on a DSK?
I found an issue with file overwriting and DSK update
You should delete the dsk meanwhile i fix this
My pronouns are RASM and ACE

Powered by SMFPacks Menu Editor Mod