Is there any C cross compiler that generates ROM files? (Development Foros MSX)MSX Resource Center            
                       
English Nederlands Espa�ol Portugu�s Russian                  
 Noticias
   Página principal
  Almacén de noticias
  Temas de noticias

 Recursos
   Foros MSX
  Artículos
  Analisis
  Informe de ferias/RUs
  Álbum de fotos
  Ferias y encuentros
  Encuestas
  Enlaces
  Buscar

 Software
   Descargas
  Tienda Online

 MRC
   Quiénes somos
  Únete a nuestro equipo
  Donar
  Políticas
  Contacta con nosotros
  Enlázanos
  Estadísticas

 Buscar
 
  

  

 Login
 

Login

Contraseña




¿Aún no tienes una cuenta? ¡Conviértete en miembro del MSX Resource Center! ¡Únete a nosotros!.


 Estadísticas
 

Hay 39 invitados y 4 miembros en línea

Eres un usuario anónimo.
 

Foros MSX


Foros MSX

Development - Is there any C cross compiler that generates ROM files?

Ir a la página ( Página anterior 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 Siguiente página )
Autor

Is there any C cross compiler that generates ROM files?

ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 04 2006, 23:35   
try this code "tst.c"
/*
 *  Demo program for Z80 
 */


static port unsigned char v99 @ 0x99;
static port unsigned char v98 @ 0x98;


main()
{
    register unsigned char  i;   

    for(i = 0 ; i != 255 ; i++)
        {
            asm("halt");
            v99 = i;
            v99 = 0x87; 
            
        }
}


compile using:
1) cpm memory model
2) z80 i/o port
3) full optimization

and run the resulting tst.com from msxdos in msx

ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 04 2006, 23:39   
if you see the cycling colors you are on the right path :-)

ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 04 2006, 23:43   
If you did anything rigth, asking for "generate assemby listings", you should get the file "tsts.lst"


HI-TECH SOFTWARE Z80 Macro Assembler: C:\WINDOWS\TEMP\$$000539.001Tue Apr  4 23:33:55 2006

                                                                      Page   1


    1                               global  small_model
    2   0000'                       psect   text,class=CODE
    3                               global  _main
    4                               signat  _main,26
    5                               file    "C:\HT-Z80\EXAMPLES\TST.C"
    6                               line    11
    7   0000'                   _main:
    8                           ;C:\HT-Z80\EXAMPLES\TST.C: 12: register unsigned
                                 char i;
    9                           ;C:\HT-Z80\EXAMPLES\TST.C: 14: for(i = 0 ; i != 
                                255 ; i++)
   10                           ; _i allocated to c
   11                               line    14
   12   0000' 0E 00                 ld  c,0
   13                               line    15
   14   0002'                   l2:
   15                           ;C:\HT-Z80\EXAMPLES\TST.C: 15: {
   16                           ;C:\HT-Z80\EXAMPLES\TST.C: 16: asm("halt");
   17                               line    16
   16   0002' 76                halt ;#
   17                           ;C:\HT-Z80\EXAMPLES\TST.C: 17: v99 = i;
   18                               line    17
   19   0003' 79                    ld  a,c
   20   0004' D3 99                 out (099h),a
   21                           ;C:\HT-Z80\EXAMPLES\TST.C: 18: v99 = 0x87;
   22                               line    18
   23   0006' 3E 87                 ld  a,-121
   24   0008' D3 99                 out (099h),a
   25                           ;C:\HT-Z80\EXAMPLES\TST.C: 20: }
   26                               line    14
   27   000A' 0C                    inc c
   28   000B' 79                    ld  a,c
   29   000C' FE FF                 cp  -1
   30   000E' 20 F2                 jp  nz,l2
   31                           ;C:\HT-Z80\EXAMPLES\TST.C: 21: }
   32                               line    21
   33   0010' C9                    ret 
   34   0000'                       psect   bss,class=DATA
   35   0098        =           _v98    equ 152
   36   0099        =           _v99    equ 153
   37   0011'                       psect       text


HI-TECH SOFTWARE Z80 Macro Assembler: C:\HT-Z80\EXAMPLES\TST.CTue Apr  4 23:33:55 2006

                                                                      Page   2



                      ---------- Symbol Table ----------

      (ABS) 0000#         CODE 0000          DATA 0000         _main 0000'  
       _v98 0098          _v99 0099           bss 0000#           l2 0002'  
small_model 0000*         text 0011#  

1 jump optimizations


Huey
online
msx professional
Mensajes: 636
Publicado: Abril 05 2006, 00:31   
Ok, its working. But i cant get an lst file. Looks like it is deleted automaticly?

Any idea how to make the tst.c into a rom now?
ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 08:52   
for the rom this is the path, (but i have never tried till now)

assume your rom at 8000-8FFFF and your ram at C000
this means that your code starts at 8010
and that the first 0x10 bytes are "custom MSX rom"

Do you see the problem? you need to reserve 16 bytes in the rom.

Solution:
Set the rom parameter as 8010-8FFFF and the ram as C000-C200 (I assume you need only 0x200 ram byte)
then compile as tst.bin

the next thing to do is to get a suitable 16 byte header, let say head.bin (use any hex editor or a C program :-)
and do the append of the two files:

head.bin + tst.bin -> tst1.rom

last thing to do is padding the result in order to get a total size of 8K or 16K,lest say pad.bin.
Use any hex editor and get a file of 8K, then append

tst1.rom+pad.bin > tst.rom

and you get a MSX ROM!

About the header, head.bin the fisrt two bytes are 'A' and 'B', the start address in or example should be 8010h
but I need to see better about the msx rom format (does anyone have any tech docs about msx roms??)


A different solution could be define multimple rom during compilation,
where you have a data rom at 8000-800F (for the msx rom header) and a code rom at 8010-8FFF
but I need to test what is easyer


ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 08:53   
to get the .lst use the tick "generate assemby listing" in the compile menu
AuroraMSX

msx master
Mensajes: 1262
Publicado: Abril 05 2006, 09:28   
Quote:

I see no mention of sdcc, is it universally hated?


It is I tried it once but decided against using it, because sdcc didn't use the normal standard Z80-style mnemonics, but a 6502-like style... Have to admit that that was about 2, 3 years ago; sdcc may have evolved during those years ...
ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 10:18   
AFAIK sdcc produces less efficient ASM code than hitech C
1) does not use alternate registers AF', BC',ecc. (hitech does)
2) does not split the IX IY registers (hitech C does, at least the IY, IX is for function calls)
3) does not allow rom and ram page automatic management (hitech C does, for msx you need custom functions)
4) supports only the small memoy model (see point above)

Huey
online
msx professional
Mensajes: 636
Publicado: Abril 05 2006, 12:24   
ARTRAG -> Your the MAN! Thanks for helping a total noob. ;P

I got it working. Strangely it only works under C-bios (msx1) and not using a phillips 8250 configuration in openMSX.
Ah well. Next thing is to experiment a little and read some tech sheets I downloaded.......
ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 12:59   
Let me know how you succeeded

Huey
online
msx professional
Mensajes: 636
Publicado: Abril 05 2006, 13:41   
I Will. If this little project works out I want to make a short article on 'Making MSX games for Dummies'
This weekend i'll have some freetime to Experiment. Is it wise to make use of asm as much as possible for graphical interactions (e.g. setting screenmode, sprites and so on )?
ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 19:59   
IMHO yes!!
Use asm the most as you can for simple I/O macros.
and than call the macros in C.
Never the less, as you have seen in the .lst file, setting
the use of 8bit ports the hitech C compiler gives good asm
code.

PS
In asm, using the asm(" XXX" ) function, you can use "_"
in order to point to the memory address of the C variables!

e.g.
int a=0;
asm ("ld hl,(_a)");
asm ("inc hl");
asm ("ld (_a),hl");
printf("%d",a); // now a =1
...




Huey
online
msx professional
Mensajes: 636
Publicado: Abril 05 2006, 21:52   
Ok thanks. Great tip. I use the C for keeping is readable and modular. I will try to keep the most of the arithmatic parts for C as I think that would be the parts i will get lost easy. But the rest of the code I will try to build in ASM.

I hope i will get thru the HI-TECH manual and the MSX1 VPD techbook soon by fastreading them. Can't wait to do some actual SCREEN2 coding.......

As I sold all my MSX stuff about 2 years ago, it's inpossible for me to test it on a real MSX. Are there any catches when coding for/ testing with an emulator? Or is it an advantage?
manuel
msx guru
Mensajes: 3545
Publicado: Abril 05 2006, 22:08   
It has several advantages, but there's a big disadvantage: emulators are not perfect. Especially critical timing things should definately be checked on a real MSX.
ARTRAG
msx master
Mensajes: 1747
Publicado: Abril 05 2006, 22:13   
But crossdevelopemet rocks!!!

You can use your PC editor, compile in a msdos window and copy the result in a "DIRASDISK" dirve of openmsx (or for roms, you do not neither need this, simply use the resulting file in thee emulator)

 
Ir a la página ( Página anterior 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 Siguiente página )
 







(c) 1994 - 2008 Fundación MSX Resource Center. MSX es una marca registrada de MSX Licensing Corporation