User Tag List

Показано с 1 по 10 из 21

Тема: z88dk v1.99A Release Candidate

Древовидный режим

Предыдущее сообщение Предыдущее сообщение   Следующее сообщение Следующее сообщение
  1. #12

    Регистрация
    21.05.2006
    Адрес
    Canada
    Сообщений
    78
    Спасибо Благодарностей отдано 
    3
    Спасибо Благодарностей получено 
    2
    Поблагодарили
    2 сообщений
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    По умолчанию

    Hi Anykey,

    Are you trying to create a binary destined for ROM?

    The compile line you are using " zcc +zx zloader.c -subtype=rom -lndos -create-app -ozloader.bin -lm" is not using the new part of z88dk -- it is using the classic part of z88dk. The rom subtype is for making IF1 cartridges and will have ORG 0. It also may not work with some functionality because the classic library is not able to generate ROMs using certain parts of the library.


    Especially if you are making a ROM, it is best to use the new c library in z88dk. It has been designed with generation of ROMs as one of its primary goals. I'd also suggest you get the latest nightly build instead of the version at sourceforge. z88dk is a very active project and there are quite a few changes since the last release. Of particular interest, if you are running on windows or mac osx, the nightly build comes with sdcc binaries that will allow you to compile using sdcc as well. z88dk's version of sdcc produces better code than sdcc does.

    Details for installing z88dk can be found here:
    http://www.z88dk.org/wiki/doku.php?i...t#installation

    There is a great deal of information on that page if you are comfortable with English. If I have understood you correctly and you want to create a ROM then of particular importance is this section that describes how code destined for ROM can be generated:
    http://www.z88dk.org/wiki/doku.php?i..._configuration


    First I will show you how to compile a program destined for RAM using the new c library and sdcc. This is how most zx programs would be compiled:

    zcc +zx -vn -SO3 -clib=sdcc_ix --reserve-regs-iy --max-allocs-per-node200000 test.c -o test

    The output will be "test_CODE.bin" which is a binary that should be loaded at address 32768 and started with "RAND USR 32768". You will see below how the ORG can be changed. If you need to make a tap out of that, you can use appmake ("appmake +zx -b test_CODE.bin -o test.tap --org 32768 --blockname test").



    Now I will show you how to make a ROM. You should use one of the CRTs designed for IF2 cartridges only because if you choose an ORG of 0, it will put the z80 restarts, im1 and nmi service routines in the correct places. If you choose an ORG that is not zero, those things will not be added.


    Код:
    #include <arch/zx.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #pragma output CRT_ORG_CODE = 0
    #pragma output CRT_ORG_DATA = 32768
    #pragma output CRT_ORG_BSS = -1
    #pragma output REGISTER_SP = 0
    
    
    void main(void)
    {
    printf ("Hello world!\n");
    printf ("\nTHIS TEST ROM\n");
    printf ("\n\n\nProgram end\n");
    while (1){ };
    }

    zcc +zx -vn -startup=32 -SO3 -clib=sdcc_ix --reserve-regs-iy --max-allocs-per-node200000 test.c -o test --list -m

    "--list" will create asm files for each translated c file. "-m" will produce symbols. You can add "--opt-code-size" to make the output a little bit smaller; the code size will be significantly smaller if your program uses 64-bit integers. If you are not running the rom interrupt routine, use "clib=sdcc_iy" instead of "-clib=sdcc_ix --reserve-regs-iy" to reduce the program size further. To use sccz80 as compiler instead of sdcc, use "clib=new" instead of "-clib=sdcc_ix --reserve-regs-iy".

    There will be three binary outputs: "test_CODE.bin", "test_DATA.bin" and "test_BSS.bin". The pragmas I put in the source code above choose some crt options. "CRT_ORG_CODE = 0" means code origin will be 0 (and the z80 restarts, im1, nmi will be included). "CRT_ORG_DATA = 32768" is where the initialized variables will be placed in RAM. "CRT_ORG_BSS = -1" means the zeroed variables will follow DATA in ram. To create the binary image, you must first compress the DATA section: "zx7 test_DATA.bin" and then append that to the code to generate the final binary: "copy /B test_CODE.bin+test_DATA.bin.zx7 test_OUT.bin" (windows). The final output "test_OUT.bin" is what should be loaded at address 0 and run from address 0. The crt will initialize the DATA section by decompressing its copy to address 32768 and it will then zero the BSS section before calling main.

    "REGISTER_SP = 0" will cause the crt to set SP=0 so that the stack will grow downward from the top of memory. These values are the defaults for zx if2 cartridges.

    One other thing: The heap will be initialized to occupy the space between the end of the BSS section and the bottom of the stack, giving the stack 512 bytes of space to grow. This behaviour and stack size can be changed with pragmas. In particular you can control the size of the heap with "#pragma output CLIB_MALLOC_HEAP_SIZE = 0". This zero value means don't create a heap but if you use a positive value > 14, a heap of that size will be created in the BSS section.

    The zx if2 crts will restart the program on exit unless CRT_ENABLE_RESTART is set to 0.



    I used "-startup=32" above. This chooses the 32-column driver for stdio. There are other choices "-startup=33" is the 32 column terminal with control codes. "-startup=36" is the 64 column terminal. "-startup=37" is the 64-column terminal with control codes. "-startup=40" is the fzx terminal with proportional fonts. "-startup=41" is the fzx terminal with control codes. "-startup=63" is no terminals.

    You can also write your own crt to make windows on screen or change the behaviour on program exit.


    z88dk's environment is quite sophisticated so there is a lot to know If you have questions, just ask. If you're wondering if you can do something the answer is yes you can
    Последний раз редактировалось Alcoholics Anonymous; 23.05.2016 в 04:11.

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Похожие темы

  1. Testers for new z88dk C library
    от Alcoholics Anonymous в разделе RST#38
    Ответов: 0
    Последнее: 27.12.2014, 04:32
  2. Сборка z88dk под OS X
    от foxweb в разделе Программирование
    Ответов: 0
    Последнее: 21.02.2014, 00:21
  3. Forever release
    от Sinus в разделе Демо
    Ответов: 9
    Последнее: 13.05.2008, 04:49
  4. BASin Release 13a
    от SGO в разделе Эмуляторы
    Ответов: 4
    Последнее: 26.12.2006, 15:58
  5. SP1 for Z88DK
    от Alcoholics Anonymous в разделе RST#38
    Ответов: 7
    Последнее: 30.06.2006, 17:23

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •