Memory Full

Forum / Development

SOME THOUGHTS FOR MODERN ASSEMBLER IN AMSTRAD WORLD

m_dr_m * 26 Oct 2021 16:45:47 * Modified at 16:47:05

« complex directives can have really different syntax »
As a mitigation, some assemblers accept different syntaxes (sometimes you have to set an option, which is a bit awkward).
Orgams team told us:
« We believe to have achieved best of both worlds: we accept different syntaxes without pesky options, and convert them to Orgams flavour. Lenient in input, yet consistent display (auto-formatting).

OTOH, Orgams doesn't recognise 0xBC00, since it's the most ugly. »

krusty * 07 Nov 2021 15:16:44

orgams is both an assembler and an ide, so it makes sense to it to reformat code. The others being only assemblers do not need such feature.

And what about the directives with plenty of parameters; for example, here is the documentation of

INCBIN

for rasm:

INCBIN ’file to read’[,offset[,size[,extended offset[,OFF]]]]
INCBIN ’file to read’,REVERT
INCBIN ’file to read’,REMAP,numcol
INCBIN ’file to read’,VTILES,numtiles
INCBIN ’file to read’,ITILES,width




This notation is really common and mainstream in the assemblers. I see several issues there: it is not easy to remember the order of parametes (IDE do not help as with modern langages). What about REVERT with an offset, size and so on ?

I would be in favor of using words instead of comma to better depict what is expected. wla-dx way of doing that is better in my opinion:

.INCBIN "kitten.bin" SKIP 10 READ 8 SWAP FSIZE size_of_kitten FILTER filtermacro



What about orgams for such kind of things ?

m_dr_m * 07 Nov 2021 18:24:06 * Modified at 18:25:13

I also plan to use keywords!
I have one additional constraint: line are parsed independently. So, if the options span over several line, I'll need:
- A way to group them.
- An non-ambiguous syntax.

Related: Passing parameters to imported files.

m_dr_m * 07 Nov 2021 18:28:49

I'm also considering using functions.

E.g.

  REVERT(SKIP(10, LOAD"filename"))



The advantage: would work for other data source, like array, import, ...

krusty * 08 Nov 2021 22:25:56

You see that functions are useful  ;)
Load should be an example too.

Anyway, I think I prefer this function way over a keyword one.

For basm, i use antislash to break a line in several lines.
It is not really nice to read and write

m_dr_m * 10 Nov 2021 05:54:04 * Modified at 05:54:25

« Load should be an example too. »
Not sure what you mean :)
I use LOAD rather than incbin, to match CPC legacy, and be consistent with SAVE.
For now, Orgams's LOAD doesn't accept parameters, but the sweet thing is that I'll be able to accept

LOAD"munch",&4000

and display automatically

LOAD"munch" start=&4000

(best of both world: easy to type, explicit to read).

For the record, the current way to achieve that is:

  ORG &4000:LOAD "munch"


which is pretty neat in my book.

krusty * 10 Nov 2021 11:03:25

sorray « Load should be a function too »

krusty * 19 Feb 2022 12:20:04

Here is an alternative implementation of your example that I can assemble with basm

	; Skip the {start} first element of list {l}
	FUNCTION SKIP, l, start
		pos = list_len({l})
		if {start} < pos
			return list_sublist({l}, {start}, pos)
		else
			return []
		endif
	ENDFUNCTION

	; Take the {amount} first element of list {l}
	FUNCTION TAKE, l, amount
		pos = list_len({l})
		return list_sublist({l}, 0, min({amount}, pos))
	ENDFUNCTION

	; Reverse list {l}
	FUNCTION REVERT, l
		new = []
		nb = list_len({l})
		for idx, 0, nb-1
			new = list_push(new, list_get({l}, nb-1-{idx}))
		endfor
		return new
	ENDFUNCTION

	; Various test to check appropriate behavior
	assert SKIP([1, 2, 3, 4], 2) == [3, 4]
	assert SKIP([1, 2, 3, 4], 5) == []

	assert TAKE([1, 2, 3, 4], 2) == [1, 2]
	assert TAKE([1, 2, 3, 4], 5) == [1, 2, 3, 4]

	assert REVERT([1, 2, 3, 4]) == [4, 3, 2, 1]
	assert list_len(load("hello.sna")) == 4674


	assert TAKE(load("hello.sna"), 8) == "MV - SNA"

	; Write in memory 8 bytes from the given file
	snapshot = load("hello.sna")
	header_id = TAKE(snapshot, 8)
	db header_id

	; Check that memory is correctly set
	assert peek(0) == "M"
	assert peek(7) == "A"