ld hl,#_addr ?

Started by funkheld, 15:37, 16 December 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

funkheld


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);
}

ervin

You are loading the address of x into the A register.

funkheld


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


thanks.

ronaldo

#3
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.

SRS

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);
}

reidrac

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!
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Gryzor

Quote from: ronaldo on 16: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.

Do we have an assembly subforum? :D

AMSDOS

Quote from: Gryzor on 09:48, 17 December 20
Do we have an assembly subforum? :D


Does 'Listings' in the 'Deutsches CPC-Forum' qualify?  :-X

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

ronaldo

Quote from: Gryzor on 09: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.

Gryzor

Quote from: ronaldo on 14: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 14: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!

GUNHED

Quote from: AMSDOS on 10:59, 17 December 20

Does 'Listings' in the 'Deutsches CPC-Forum' qualify?  :-X
No, "Listings" is for type-in stuff.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2022.03.09)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

SRS


funkheld

hello, thanks for the help.


greeting.

Gryzor


freemac

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
}

SRS

Quote from: Gryzor on 09: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)

Gryzor

Quote from: SRS on 21: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