A problem whith my little BASIC-library project in c

By sp4

Master (214)

Аватар пользователя sp4

18-10-2010, 16:36

Hi, i have written a little source for make a BASIC-library with one module main.c

main.c:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define T32COL 0xF3BF
#define T32CGP 0xF3C1
#define T32ATR 0xF3C3
#define T32PAT 0xF3C5
#define T32NAM 0xF3BD

#define MODE0 0x00
#define MODE1 0x01
#define MODE2 0x02
#define MODE3 0x03
#define MODE4 0x04
#define MODE5 0x05
#define MODE6 0x06
#define MODE7 0x07
#define MODE8 0x08

void screen(int mode);
void color(char primo_piano, char sfondo, char periferico);
//void pset(char x, char y);
//void cls(void);
//void putchar(char chr);
void print(char *stringa);
/*char inkey(void);
void locate(char x,char y);
void tab(char x);
void input(char var);
void screen(int mode);*/


int main()
{
    screen(1);
    //color(1,6,1);
    //pset(100,100);
    print("F");
    while(1) {};
    return 0;
}

//funzione per impostare configurazione schermo
void screen(int mode){
  __asm

  ld a,4(ix)
  call 0x005F ; --- go to screen mode
  call 0x00CC ; --- erase function keys

  __endasm;
}


//funzione per impostare colori schermo
void color(char primo_piano, char sfondo, char periferico){
  _asm

  ld hl,#0xf3e9
  ld a,4(ix)
  ld (hl),a

  inc hl
  ld a,5(ix)
  ld (hl),a

  inc hl
  ld a,6(ix)
  ld (hl),a

  call 0x0062 ; --- change color

  _endasm;
}






//funzione per stampa stringhe sullo schermo
void print(char *stringa){
    char var;
    int x=0;
     while(*(stringa+x)!='\0')
    {
        var=*(stringa+x);
        putchar(var);
        x++;
    }
}

I've keep only screen(), color() and print() functions for understand better where is the problem in my source
I've compiled my main.c with this command row:

sdcc --no-std-crt0 -mz80 --code-loc 0x4020 --data -loc 0xc000 -o prova.ihx main.c crt0msx.16k.4000.rel

and the compilation resoult is:

at 1: warning 117: unknow compiler option '--data' ignored
at 1: warning 119: don't know what to do with file '0xc000' .
file extension unsupported
"sdcpp" it's not recognezed as a internal or external command or an executable program or a batch file
at 1: warning 190: ISO C forbids an empty source file

I don't understand why my compiler tell the above replies ?
Nobody can help me please ?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By larsthe18th

Master (186)

Аватар пользователя larsthe18th

18-10-2010, 18:05

As far as i can see is that you need to get rid of the space between --data and -loc in the command line.
sdcc --no-std-crt0 -mz80 --code-loc 0x4020 --data-loc 0xc000 -o prova.ihx main.c crt0msx.16k.4000.rel

By sp4

Master (214)

Аватар пользователя sp4

18-10-2010, 22:01

Well, i've made a modification as follow below:

Compilation row:

sdcc --no-std-crt0 -mz80 --code-loc 0x4020 --data-loc 0xc000 -o prova.ihx main.c cio.rel crt0msx.16k.4000.rel

main.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cio.h"

#define T32COL 0xF3BF
#define T32CGP 0xF3C1
#define T32ATR 0xF3C3
#define T32PAT 0xF3C5
#define T32NAM 0xF3BD

#define MODE0 0x00
#define MODE1 0x01
#define MODE2 0x02
#define MODE3 0x03
#define MODE4 0x04
#define MODE5 0x05
#define MODE6 0x06
#define MODE7 0x07
#define MODE8 0x08


char prova[2]="S";

int main()
{
    screen(1);
    //color(1,6,2);
    cls();
    putchar('r');
    //pset(100,100);
    //print(prova);
    //putchar('D');
    while(1) {};
	return 0;
}


core.c

//modulo contenente le funzioni di input ed output
#include "cio.h"
#include <string.h>

//funzione per la cancellazione dello schermo
void cls(void) {
  putchar(0x1b);
  putchar(0x45);
}

//funzione per inserire un carattere sullo schermo
void putchar(char chr) {
  _asm
    ld a,4(ix)   ;registro su cui viene messo il carattere da visualizzare
    call 0x00A2  ;chiamata del servizio visualizzazione carattere su schermo
  _endasm;
}


//funzione per stampa stringhe sullo schermo
void print(char *stringa){
    char var;
    int x=0;
	 while(*(stringa+x)!='\0')
    {
        var=*(stringa+x);
        putchar(var);
        x++;
    }
}


//funzione per leggere caratteri da tastiera
char inkey(void) {
  _asm
    call 0x009F   ;chiamata servizio di lettura carattere da tastiera
    ld   h,#0x00
    ld   l,a      ;registro su cui viene depositato il carattere letto
  _endasm;
}

//funzione per posizionare il corsore
void locate(char x,char y) {
  _asm
    ld l,4(ix)  ;metti la coordinata x nel reg l
    ld h,5(ix)  ;metti la coordinata y nel reg h
    call 0x00C6 ;chiamata bios per spostare corsore
  _endasm;
}

//funzione per spostare solo la posizione di riga del cursore
void tab(char x)
{
  _asm
    ld l,4(ix)  ;metti la coordinata x nel reg l
    call 0x00C6 ;chiamata bios per spostare corsore
  _endasm;
}

//funzione per inserimento di un carattere in una var con eco
void input(char var){
    var=inkey();
    putchar(var);
}


void screen(int mode){
  __asm

  ld a,4(ix)
  call 0x005F ; --- go to screen mode
  call 0x00CC ; --- erase function keys

  __endasm;
}

core.h

//file di intestazione cio.h

void cls(void);
void putchar(char chr);
void print(char *stringa);
char inkey(void);
void locate(char x,char y);
void tab(char x);
void input(char var);
void screen(int mode);

//fine di cio.h

The compilation resoult was as follow below:
?ASlink-Error-<cannot open> : "cio.rel"

it was impossible to create cio.rel, and if i compile only the cio.c source with sdcc -c cio.c the resoult is:
Error: <o> .org in REL area or directive / mnemonic error

Can you tell me why it's impossible to create a cio.rel ?
I've controlled cio.c and it'c correct, but it doesn't function in the compilation.
CrazyCrazy

By andrear1979

Expert (97)

Аватар пользователя andrear1979

18-10-2010, 23:29

please try if

sdcc --data-loc 0xc000 --code-loc 0x4020 -mz80 -c cio.c

compiles. If not, check carefully the asm parts of your
code. By the way, I think that sdcc may require to use
__asm / __endasm (with 2 underlines instead of 1),
but check sdcc docs to be sure 100%.

Hope that some of these hints may help, regards.

EDIT: but I see you wrote "core.c" not "cio.c"! Looks
like a typo or wrong file name?

By sp4

Master (214)

Аватар пользователя sp4

20-10-2010, 16:20

Thank for your help andrear the 'core.c' than i've introduced was a wrongonly in my post not in my code.
I'vr introduced
'sdcc --data-loc 0xc000 --code-loc 0x4020 -mz80 -c cio.c' and my compilation has been all right Wink