Search code examples
variablesassemblyz80gameboy

How Do I Create a Variable In Z80 Assembly?


I'm trying to create a simple variable containing the hex value 0xffff. I've been able to do it as a macro with SET, but I haven't been able to get it working with something like ld _time,$ffff. How do I load a value into _time?


Solution

  • My problem was I wasn't initializing _time. The following worked:

    _time SET $ff
    ld hl, $ffff
    ld (_time),hl