CPCWiki forum

General Category => Programming => Topic started by: funkheld on 14:37, 16 December 20

Title: ld hl,#_addr ?
Post by: funkheld on 14:37, 16 December 20

Hi good afternoon.


I would the 0xc000 from addr to hl.
what is wrong there please?


the value x is passed.


thanks.
greeting




#include <cpctelera.h>


u8 x;
u16 addr;


void datascr() {
__asm
   ld a,#_x
   ld hl,#_addr
   ld(hl),a
__endasm;
}


int main() {
    cpct_disableFirmware();
    cpct_setVideoMode(2);
   
     x=255;
     addr=0xc000;
     datascr();
   
    while(1);
}
Title: Re: cpctelera : ld hl,#_addr ?
Post by: ervin on 14:49, 16 December 20
You are loading the address of x into the A register.
Title: Re: cpctelera : ld hl,#_addr ?
Post by: funkheld on 15:17, 16 December 20

how do i get this 0xc000 from addr in hl?


thanks.
Title: Re: cpctelera : ld hl,#_addr ?
Post by: ronaldo on 15:31, 16 December 20
Please, stop tagging as "cpctelera" questions that have nothing to do with CPCtelera.

This is an assembly question, and should go into the assembly programming forum, more precisely into a newbie corner.

@Gryzor (https://www.cpcwiki.eu/forum/index.php?action=profile;u=1).
Title: Re: ld hl,#_addr ?
Post by: SRS on 19:10, 16 December 20
How about "native C" ?
#include <cpctelera.h>

int main() {

u8 x;
u16* addr;

    cpct_disableFirmware();
    cpct_setVideoMode(2);
   
     x=255;
     addr=0xc000;
   
    *addr=x;
   
    while(1);
}
Title: Re: ld hl,#_addr ?
Post by: reidrac on 19:32, 16 December 20
That addr should be a pointer to byte, not to word; isn't it?


u8 *addr;

addr = (u8 *)0xc000;
*addr = 255;


EDIT: OK, mode 2. May be you did it on purpose!
Title: Re: ld hl,#_addr ?
Post by: Gryzor on 08:48, 17 December 20
Quote from: ronaldo on 15:31, 16 December 20
Please, stop tagging as "cpctelera" questions that have nothing to do with CPCtelera.

This is an assembly question, and should go into the assembly programming forum, more precisely into a newbie corner.

@Gryzor (https://www.cpcwiki.eu/forum/index.php?action=profile;u=1).

Do we have an assembly subforum? :D
Title: Re: ld hl,#_addr ?
Post by: AMSDOS on 09:59, 17 December 20
Quote from: Gryzor on 08:48, 17 December 20
Do we have an assembly subforum? :D


Does 'Listings' in the 'Deutsches CPC-Forum' qualify?  :-X
Title: Re: ld hl,#_addr ?
Post by: ronaldo on 13:39, 17 December 20
Quote from: Gryzor on 08:48, 17 December 20
Do we have an assembly subforum? :D

I think I got carried away and imagined forums and subforums in my own parallel reality ::) .

Anyway, a newbie assembly corner could be useful.
Title: Re: ld hl,#_addr ?
Post by: Gryzor on 13:42, 17 December 20
Quote from: ronaldo on 13:39, 17 December 20I think I got carried away and imagined forums and subforums in my own parallel reality

We all do from time to time, nothing to worry about.

Quote from: ronaldo on 13:39, 17 December 20Anyway, a newbie assembly corner could be useful.
As always, if more people find it a good idea I'll be more than happy to add whatever!
Title: Re: ld hl,#_addr ?
Post by: GUNHED on 19:12, 17 December 20
Quote from: AMSDOS on 09:59, 17 December 20

Does 'Listings' in the 'Deutsches CPC-Forum' qualify?  :-X
No, "Listings" is for type-in stuff.
Title: Re: ld hl,#_addr ?
Post by: SRS on 20:56, 17 December 20
How about "https://www.cpcwiki.eu/forum/programming/asm-source-code/" ?
Title: Re: ld hl,#_addr ?
Post by: funkheld on 22:12, 17 December 20
hello, thanks for the help.


greeting.
Title: Re: ld hl,#_addr ?
Post by: Gryzor on 08:41, 18 December 20
Quote from: SRS on 20:56, 17 December 20
How about "https://www.cpcwiki.eu/forum/programming/asm-source-code/" ?

That's a thread though, not a forum?
Title: Re: ld hl,#_addr ?
Post by: freemac on 09:48, 18 December 20
You can add some C code into your asm function (param+=1) and see the .asm file resulting. Like a hacker  8)
void toto(unsigned char c) {
__asm
TADA
__endasm;
c=c+1
}
Title: Re: ld hl,#_addr ?
Post by: SRS on 20:56, 18 December 20
Quote from: Gryzor on 08:41, 18 December 20
That's a thread though, not a forum?
We need a forum about "What's a forum, a subforum and a thread for newbies ...." ! 8)
Title: Re: ld hl,#_addr ?
Post by: Gryzor on 21:23, 18 December 20
Quote from: SRS on 20:56, 18 December 20
We need a forum about "What's a forum, a subforum and a thread for newbies ...." ! 8)
Surely you mean a topic? 😂
Powered by SMFPacks Menu Editor Mod