Skip to main content
26 events
when toggle format what by license comment
Feb 14, 2020 at 2:54 comment added Jean-François Fabre okay, maybe someone wants to edit the answer so the z80 code is correct?
Feb 12, 2020 at 20:23 comment added CJ Dennis Unfortunately ld af,(sp) makes no sense for a Z80. 1. AF is the (8-bit) Accumulator A and (8-bit) Flag F registers, never treated as a 16-bit value except when PUSHing, POPping, or EXchanging. You would want to use one of BC, DE, or HL. 2. You can't get (SP) except by POPping which also adds 2 to SP. So you'd want to POP BC, POP DE, or POP HL.
Feb 12, 2020 at 19:36 comment added Misha Lavrov If something like call next followed by next: pop hl works, then so does next: ld hl, next. In either case, this is only valid if the address of the code is known at compile time.
Feb 11, 2020 at 21:45 comment added S.S. Anne I wouldn't load it into AF. AF is the flags register and that could be dangerous.
Feb 11, 2020 at 15:58 comment added Criticizing Israel not allowed @ilkkachu I can comfirm the PIC12F508 (page 27) has an inaccessible stack. But we're talking about a machine with 25 bytes of RAM here. The hidden stack adds another 3 whole bytes! (2 x 12 bits)
Feb 11, 2020 at 13:21 comment added Raffzahn @ilkkachu Hihi. Yes, that would add another level of fun :)
Feb 11, 2020 at 13:20 comment added Raffzahn @another-dave Sure, that needs to be defined before anything else. But when done, it's simply a subtraction of the offset from the instructions address. Ofc, this can only be valid when done in the same module (phase) as the defined start is :) So yes, there are many additional hurdles that could apply. For a definite answer more information is needed than given by the OP.
Feb 11, 2020 at 13:03 history edited Jean-François Fabre CC BY-SA 4.0
added 4 characters in body
Feb 11, 2020 at 10:55 comment added ilkkachu ...for all processors with a software-accessible call stack ;) There might be ones with a hidden call stack, accessible only by the call and return instructions. I think some tiny RAM-less AVR might have had something like this.
Feb 11, 2020 at 8:48 history edited Alex Hajnal CC BY-SA 4.0
FIxed typos
Feb 11, 2020 at 7:37 history edited Jean-François Fabre CC BY-SA 4.0
added 168 characters in body
Feb 11, 2020 at 7:35 comment added Jean-François Fabre yeah simple pc relative lea does the job.
Feb 11, 2020 at 7:26 comment added lvd for 68k it is as simple as lea (pc),a0
Feb 11, 2020 at 2:54 comment added dave To be picky: this answer and others tell how to get the address of a particular instruction, The "address of the program" is a little trickier, starting with defining what that really means.
Feb 11, 2020 at 2:49 comment added dave If there's no call stack then it's probably even easier, The return address will get stored somewhere -- register, first word of subroutine, … :-)
Feb 11, 2020 at 0:27 comment added RETRAC Only works for processors with a subroutine call stack :)
Feb 10, 2020 at 22:27 comment added Jean-François Fabre I only know z80 through disassembling arcade games. Never coded anything with that processor myself...
Feb 10, 2020 at 22:26 history edited Jean-François Fabre CC BY-SA 4.0
deleted 129 characters in body
Feb 10, 2020 at 22:26 comment added user722 Don't really know Z80 well myself, I had to Google about the JR instruction.
Feb 10, 2020 at 22:25 history edited Jean-François Fabre CC BY-SA 4.0
deleted 129 characters in body
Feb 10, 2020 at 22:22 comment added Jean-François Fabre I see, no need to return from the subroutine, I get it.. please feel free to edit the z80 code of the answer above. I can use a good z80 lesson
Feb 10, 2020 at 22:21 comment added user722 AF is the flags register and JR doesn't push a return value. You could simplify this with something like call next next: pop ix. Though CALL isn't relative.
Feb 10, 2020 at 22:20 history edited Jean-François Fabre CC BY-SA 4.0
added 497 characters in body
Feb 10, 2020 at 22:09 history edited Jean-François Fabre CC BY-SA 4.0
added 194 characters in body
Feb 10, 2020 at 22:08 vote accept twisted
Feb 11, 2020 at 18:41
Feb 10, 2020 at 22:02 history answered Jean-François Fabre CC BY-SA 4.0