0

I have the following instruction in Z80 assembly language:

JP .

It is not clear to me where it jumps.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Ago
  • 51
  • 4
  • Which assembler are you using? – harold Jun 22 '17 at 12:33
  • 2
    that's nothing from zilog, but a "feature" of your assembler. most probably its a " current address " . disassemble the output, if you get something like `03f1 JP 0x03f1` it is – Tommylee2k Jun 22 '17 at 12:50
  • 1
    The assembler your using would be useful as harold asked. I've seen `$` and `*` (depending on assembler) be the current program counter. Likely `.` (period) is the program counter. – Michael Petch Jun 22 '17 at 16:27

2 Answers2

1

The JP . instruction means that the PC remains there!!!

Ago
  • 51
  • 4
0

Many assemblers provide special variables, or other symbols, that can be used to represent useful information available during the assembly process.

For example, one early assembler (this is deep in my past so I'm not sure which one it was), used $ to represent the current location being assembled into, which allowed you to do things like:

msg:    ds  "This is my message"
msg_sz: equ $ - msg

Given that $ was the next byte to assemble into, the symbol msg_sz would be set to that minus the start of the message, which is effectively the size of said message. You could then load msg into one register, msg_sz into another, then call a function that used both those values to process the message.

It's almost certain that . in your assembler is performing the same function since that would effectively make the jump an infinite loop, something we often used in our early assembler assignments to signal the end of a program - most of the stuff we did was on bare metal so there was no operating system to return to :-)

And, in fact, the GNU assembler as still uses a period as that special symbol:

The special symbol '.' refers to the current address that as is assembling into. Thus, the expression 'melvin: .long .' defines Melvin to contain its own address. Assigning a value to . is treated the same as a .org directive. Thus, the expression '.=.+4' is the same as saying '.space 4'.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953