Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2020-06-14 15:38:59

tommaso
New member
Registered: 2020-06-14
Posts: 2

GBDK C inline assembly

Hi, i'm new to GB development, so my question is probably pretty stupid and apologize for that, i'm trying to send debug messages for bgb in c, i found on this forum an user that suggested a macro like this:

Code:

#define BGB_MESSAGE(lbl, message_text) \
__asm \
  ld d, d \
  jr lbl \
  .dw 0x6464 \
  .dw 0x0000 \
  .ascii message_text \
lbl: \
__endasm

but when i try to use it i just get :

Code:

parse error before ld

i never used lcc before so maybe i'm missing some options.
does anyone know how to fix this? i noticed i don't seem to be able to do any inline assembly at all.
Thanks in advance,
Tommaso.

Last edited by tommaso (2020-06-14 15:51:33)

Offline

 

#2 2020-06-14 16:59:30

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK C inline assembly

the problem seem not to be in the macro itself, but in the way, how you use that macro.

Offline

 

#3 2020-06-14 18:45:17

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: GBDK C inline assembly

you must use that macro this way:
1. inside a function, with ';'
2. lbl must be the numeric value ended by the $ symbol. that numeric label must not intersect with other local labels, generated by sdcc, choose some big numbers.
3. the message must be a constant string

example:

void main(void)
{   
    BGB_MESSAGE(100500$, "HELLO, WORLD");
}

ps: just use the latest GBDK-2020 https://github.com/Zal0/gbdk-2020/releases , there are better BGB macros in gb/bgb_emu.h.

Last edited by toxa (2020-06-14 18:45:51)

Offline

 

#4 2020-06-14 18:54:30

tommaso
New member
Registered: 2020-06-14
Posts: 2

Re: GBDK C inline assembly

toxa wrote:

you must use that macro this way:
1. inside a function, with ';'
2. lbl must be the numeric value ended by the $ symbol. that numeric label must not intersect with other local labels, generated by sdcc, choose some big numbers.
3. the message must be a constant string

example:

void main(void)
{   
    BGB_MESSAGE(100500$, "HELLO, WORLD");
}

ps: just use the latest GBDK-2020 https://github.com/Zal0/gbdk-2020/releases , there are better BGB macros in gb/bgb_emu.h.

thank you very much! updating gbdk solved my problem, i was using the 2000 version, i didn't know someone updated it!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson