Hi all!
I'm looking for a way to have my code compatible between PASMO and WinAPE assembler (MAXAM compatible). I almost got it, except for the fact that I don't have REPT available (though REPEAT exists).
I'm defining macros for things I use in Pasmo that are different in Maxam (such as INCLUDE = READ). But I cannot figure out how to do so for REPT.
Can anybody help me? Is there a way of defining an alias or a macro so that I can have REPT in my code, and WinAPE interprets it as REPEAT?
I'm looking for documentation on MAXAM macros, but cannot find any... Can anybody point me in the right direction?
Thank you!
Quote from: AugustoRuiz on 08:30, 05 June 13
I'm looking for documentation on MAXAM macros, but cannot find any... Can anybody point me in the right direction?
Thank you!
http://www.cpcwiki.eu/index.php/Maxam_1.5 (http://www.cpcwiki.eu/index.php/Maxam_1.5)
Quote from: arnoldemu on 08:56, 05 June 13
http://www.cpcwiki.eu/index.php/Maxam_1.5 (http://www.cpcwiki.eu/index.php/Maxam_1.5)
Sorry, read both PDFs there, but couldn't find any info on macros (and still cannot)...
Quote from: AugustoRuiz on 09:14, 05 June 13
Sorry, read both PDFs there, but couldn't find any info on macros (and still cannot)...
I didn't read it fully :laugh:
Try this one:
Maxam 2 - CPCWiki (http://www.cpcwiki.eu/index.php/Maxam_2)
I see "Repeat" mentioned here.
Thank you!
In the end, I've done something horrible, but it works.
Two different entry points for assembler, one for pasmo, and another one for WinApe. In one of them I use REPEAT (WinAPE), and in another one I use REPT (Pasmo).
And in WinAPE I also have this:
MACRO INCLUDE fileName
READ fileName
ENDM
I'm not sure if it's exactly your case, but I use WinCPC for testing things out in an emulator and pasmo run from a Makefile for making the proper binary and compressing it.
As a result, I tend to use WinCPC syntax and have an extra conversion step that converts from wincpc format (which I think is similar to maxam) to pasmo, by running things through sed or perl. That way, you have a single "source" file but can still use two different assemblers.
Quote from: AugustoRuiz on 08:30, 05 June 13
I'm looking for documentation on MAXAM macros, but cannot find any... Can anybody point me in the right direction?
Well, Maxam and Maxam 1.5 do not have macros. If you want to use macros then please use Maxam II (it runs under CP/M Plus and is compatible with RAM disc and hard disc HD20).
Quote from: TFM/FS on 17:08, 06 June 13
Well, Maxam and Maxam 1.5 do not have macros. If you want to use macros then please use Maxam II (it runs under CP/M Plus and is compatible with RAM disc and hard disc HD20).
Well, I'm using WinAPE, as I don't have any physical CPC available :(. I develop mainly using an external text editor (Notepad++), and have some sort of empty source code file that includes the main source code file. I have the almost empty file open in WinAPE assembler, so I can edit the code with undo/redo...
In order to build my dsk, I use Pasmo, Img2CPC, DSKGen and Exomizer.
Well, I'm not aquanted to the assemblers of emulators. I usually still use Maxam when using an emulator (even if it is time consuming ;-)). But there is also JavaCPC having an assembler. I never used neither one of them, so I got no clue which one may provide better results.
WinAPE assembler has both REPEAT and WHILE macros. REPEAT is designed to do something a fixed number of times, eg:
REPEAT 64
LDI
REND
And WHILE will continue to produce code while a condition is true.
WHILE $ - #4020
NOP
WEND
A little offtopic however still about assembler in WinAPE (and I don't want to start a new topic for this)...:
How to load the high byte of an address into a register?
ld a,label loads the low byte...
Quote from: ssr86 on 20:47, 19 October 13
ld a,label loads the low byte...
LD HL,label
LD A,L
But isn't there a assembler function that recognizes which byte of a word you want to load?
I remember that turbo assembler for c64 had the signs < and > to do that (ldx #>label was the high byte). Because I know what the high byte is so I could just load the register with that but I use a label for that address and I would want to use that label when loading.
Quote from: ssr86 on 22:01, 19 October 13
But isn't there a assembler function that recognizes which byte of a word you want to load?
I remember that turbo assembler for c64 had the signs < and > to do that (ldx #>label was the high byte). Because I know what the high byte is so I could just load the register with that but I use a label for that address and I would want to use that label when loading.
Of course there is an more easy way:
LD H,label/256 will load the highbyte of the label in the register (H in this case).
Further the Bollawares did an assembler for the CPC that is very similar to the Turbo Assembler of the c64, check out their homepage:
http://www.bollaware.de (http://www.bollaware.de/)
TFM is correct, use
LD r,addr / 256
or
LD r,addr / #100
One more question....
Macros with arguments - are they supported in WinApe assembler? If yes, then what is the syntax?
Thanks.
Quote from: ssr86 on 12:05, 06 November 13
Macros with arguments - are they supported in WinApe assembler? If yes, then what is the syntax?
argument equ 1 (1 for true, 0 for false)
IF argument
...some code...
ENDIF
What I had in mind was something like this:
Macro (arg1, arg2)
ld a,arg1
and arg2
or (hl)
EndM
Quote from: ssr86 on 12:42, 06 November 13
What I had in mind was something like this:
From Grimware (http://www.grimware.org/doku.php/documentations/software/winape/start#macro-commands):
Macro local labels can be defined by prefixing with an @ symbol, they can be nested and may be called recursively. Macros can override reserved assembler symbols. The ! symbol is used to exclude the use of macros from a symbol. (eg. If the LDI symbol had been redefined, you can assemble a standard LDI using !LDI).
Macro
Syntax:
macro <name> [parameter1[,parameter2[...]]]
Define a new macro.
macro <name> [parameter1[,parameter2[...]]]
; some code
mend
Your macro MUST BE DEFINED BEFORE being used in the source!
Thank you - especially for the link. I didn't know about that there was a documentation for WinApe's assembler on grimware site.
I'd also forgotten there was some documentation on Grimware. btw, There is another form of write direct which allows writing directly to sectors on a disc image.
eg.
write direct sectors 3-4:c1-c9 5:c1-c2
Is it possible to write such a macro in Winape??:
macro load_A_with reg
ld a,reg
endm
So it can be used like:
load_A_with b
load_A_with c
load_A_with d
load_A_with e
where b,c,d,e are standard registers.
I'd need to write a macro with such functionality...but it doesn't seem to be possible...
Parameters can only be numbers or characters it seems.
I could write a macro for each register or use a couple of "ifs" but it would be a long and hard to read macro...
Maybe there is a better solution?
Depends on what you are trying to do with this.
Are you wanting to write IF reg =<> argument THEN ELSE type routines?
If you mean a Z80 register with reg, then this won't work. A conditional assembly depends ATMK at variables or constants of the source code, not the finished program running. If reg is something else never mind. :)
Yes, that is what I had in mind. Thanks for the answer.
It's not possible so I'll do it with nested 'ifs' instead...
Quote from: ssr86 on 18:13, 23 November 13
Is it possible to write such a macro in Winape??:
macro load_A_with reg
ld a,reg
endm
It is:
;;Define some of the 3-bit CPU register indexes as used by the LD r,r' instruction for convenience
_b EQU %000
_c EQU %001
_d EQU %010
_e EQU %011
_h EQU %100
_l EQU %101
;_z EQU %110
_a EQU %111
;; Add the 3-bit register index argument with the LD A,r opcode to make the final instruction
;; Note: the AND %111 is only here to sanitize the input, just in case.
macro load_a_with reg
db reg AND %111 + %01111000
mend
;; Macro usage:
load_a_with _b
load_a_with _c
load_a_with _d
load_a_with _e
load_a_with _h
load_a_with _l
load_a_with _a
Quote from: Executioner on 22:49, 07 November 13There is another form of write direct which allows writing directly to sectors on a disc image.
Aye! Duly noted cap'n! :)
Wah, thanks Grim :D
Quote from: ssr86 on 18:13, 23 November 13
Parameters can only be numbers or characters it seems.
Interesting... I think that's an oversight, perhaps I can change it for the next release.
Another question about Winape assembler...
Is there a way to use inequalities in conditional code...?
if par1<const
...
endif
Quote from: ssr86 on 23:11, 31 January 14
Is there a way to use inequalities in conditional code...?
Not directly, but you can use bitwise logical operators that produce a result of 'true' (not zero) or 'false' (zero), eg.:-
IF par1-const AND &8000
...
ENDIF
In this case, if par1-const is negative then bit 15 of the result will be set, so result AND &8000 will be true (not zero).
Thank you, it helped a lot:)
But is there a way to have two inequalities checked in one 'if', or do I have to go with two 'ifs' because I can't use brackets...?
if par1<const1 AND par2<const2
...
endif
Quote from: ssr86 on 13:49, 01 February 14
Thank you, it helped a lot:)
But is there a way to have two inequalities checked in one 'if', or do I have to go with two 'ifs' because I can't use brackets...
Expressions are evaluated in strict left to right order, so it may be possible in some cases but not easy. Best to just use nested ifs.
You can either use nested IFs, or use EQU for each of the conditions eg.
c1 equ par1 - const1 and #8000
c2 equ par2 - const2 and #8000
if c1 and c2
...
endif