Page 1 of 1

pceas patch

Posted: Sun Jun 22, 2008 6:50 pm
by MooZ
Last year I modified pceas so that you can specify include paths via command line options. This way you can make nice Makefiles to compile your pce project :) I also cleaned up the option list.
You can grab the source patch [here].
The modification has been committed to the huc/pceas CVS.

The new pceas command line option:

Code: Select all

pceas [-options] [-h (for help)] infile
-s/S        : show segment usage
--segment/fullsegment
-l #        : listing file output level (0-3)
--listing #
-m          : force macro expansion in listing
--macro
--raw       : prevent adding a ROM header
-I          : add include path
--cd        : create a CD-ROM track image
--scd       : create a Super CD-ROM track image
--over(lay) : create an executable 'overlay' program segment
--dev(elo)  : assemble and run on the Develo Box
--mx        : create a Develo MX file
--srec      : create a Motorola S-record file
-h          : help. Displays this message
--help
infile      : file to be assembled
A little Makefile example:

Code: Select all

AS = bin/pceas
SRCDIR = src
INCLUDE = -I include -I src
EMU = mednafen

main.pce:
        $(AS) $(SRCDIR)/main.asm $(INCLUDE)

run:
        $(EMU) $(SRCDIR)/main.pce

clean:
        rm $(SRCDIR)/*.sym

Re: pceas patch

Posted: Fri Jul 18, 2008 1:07 pm
by MooZ
Just a quick note. In order not to break people's build script, I used getopt_long_only instead of getopt_long. This let you use long options with a simple '-' (just like old pceas).
Unfortunately, this function doesn't exist undes win32 (mingw32 and co). I added getopt sources (taken from the theora project) in huc (under test/getopt). I'll run some tests tonite and post a final patch (and commit it to CVS).

Anyway, I quickly read the manual of Kick Assembler (a java c64 assembler). And it has some nice features like '*' which returns the value of the current memory location and '.align' that aligns the current rom/program offset to a given interval.
That'll be cool to have such stuffs in our beloved assembler, no?

Re: pceas patch

Posted: Fri Jul 18, 2008 8:18 pm
by tomaitheous
So * would return the value of the current location? That would be nice, especially if you can add an offset to the pointer before it gets the value. The align directive sound useful as well.

Re: pceas patch

Posted: Sat Jul 19, 2008 8:34 pm
by MooZ
I checked pceas code and '*' is already supported :)
For example :

Code: Select all

    .org $E009
    jmp *
will produce:

Code: Select all

jmp $E009
You can also do:

Code: Select all

l0: nop
    nop
    bra    *-2    ; same as bra l0

Re: pceas patch

Posted: Mon Mar 08, 2010 1:47 pm
by MooZ
Hum, it seems that pceas has some support for proto sub structure thingy. Here's what's written in the doc:
  • RSSET - Set the internal counter of the RS directive to a specified value.
  • RS - Assign a value to a symbol; a bit like EQU but here the value assigned is taken from an internal counter, and after the assignation this counter is increased by the amount specified in the RS directive. This is a very handy way of defining structure member offsets, here's a small example:

    Code: Select all

    ; C:
    ; --
    ; struct {
    ;    short p_x;
    ;    short p_y;
    ;    byte p_color;
    ; } pixel;
    ;
    ; ASM:
    ; ----
    
    .rsset $0  ; set the initial value of RS counter
    P_X     .rs 2
    P_Y     .rs 2
    P_COLOR .rs 1
    You can later use these symbols as offsets in a 'pixel' struct:

    Code: Select all

    ldy #P_COLOR
    lda [pixel_ptr],Y
Has anyone ever used this?

Re: pceas patch

Posted: Wed Mar 24, 2010 6:14 am
by tomaitheous
I was able to do this:

Code: Select all

bmp	.macro								; <- test macro. Basically a struct define
	\1.size_x: .rs 2
	\1.size_y: .rs 2
	.endm

Code: Select all

	bmp pic2
	.
	.
	.
	.

	lda pic2.size_x
Kinda like a struct :) You can also use .DB and .DW in macros too. I was able to include an immediate string and placing a BRA right before it like this:

Code: Select all

PRINT_STR_i   .macro
      bra .y_\@
.x_\@:
      .db \1,0
.y_\@:
      lda #low(.x_\@)
      sta <R0
      lda #high(.x_\@)
      sta <R0+1
      lda #low((\2 & $3f)+((\3)<<6))
      ldx #low((\3 & $3f)>>2)
      clc
      jsr PrintString
  .endm
And then call it like so:

Code: Select all

      PRINT_STR_i "Custom MOD player ver: 1.0.0 alpha",3,1

Re: pceas patch

Posted: Wed Mar 24, 2010 9:37 am
by MooZ
I was thinking about adding some kind of structure directives to pceas. I'd have looked like this:

Code: Select all

Sprite .struct
    x      .ds 2
    y      .ds 2
    flag    .ds 1
.ends


    .zp
muscle_man  .dstruct(Sprite)
clown_list  .dstruct(Sprite) 8


    .code
    lda     <muscle_man.x
    cmp     <clown_list[3].x
    bne     safe
    ; ...
This means that we have to perform type checks. And I don't know if it's the philosophy of pceas to be strongly typed. And if we are at it, why not check if the access are out of bound. I fear that after some iterations we end up with some kind of poor man C or ghetto Pascal.

Re: pceas patch

Posted: Fri Apr 23, 2010 8:57 am
by TOUKO
hi i have make a .bat file for easy compiling your .pce projects ..

Code: Select all

cls
@echo off

SET EXTENSION=%~x1
SET NAME=%1
SET CHEMIN=%~dp0
SET PCE_INCLUDE=%CHEMIN%include\pce

If "%EXTENSION%"==".c" goto Compilc
If "%EXTENSION%"==".C" goto Compilc
:Compilasm
bin\pceas.exe %1
goto Fin

:Compilc
bin\huc.exe %1
bin\pceas.exe %NAME:~0,-2%.s  

:Fin     
With that you have not to specify your include directory.

You only must lunch your .bat in the same directory of your .c or .asm project .

ex : compil.bat toto.c or compil.bat toto.asm .
If you are using multiple projects directory, simply copy your .bat without changing anything