Punit
Punit

Reputation: 35

Assembly language coding help required

Can someone improve on this code (MC9S08JM60):

ldhx  #0xDFC4;  // Vector location
ldhx  ,x        // Fetch vector contents
jsr   ,x        // Execute interrupt function

What I want to do is to jump at the location 0xABCD, where, 0xAB lies in 0xDFC4 and 0xCD lies in 0xDFC5.

So, the above code doesn't seem to jump to ABCD location.

Upvotes: 0

Views: 1185

Answers (1)

Rooke
Rooke

Reputation: 2033

The HCS08 Reference Manual is handy in a situation like this:

The immediate mode of the instruction LDHX loads in the byte at address 0xDFC4 into the "H" register, and the byte at address 0xDFC5 into the "X" register.

I think your second instruction is ok.

But your third instruction, JumptoSubRoutine (JSR) does an offset jump, I think. Try JMP ,x

Note also, JSR does a push of the current (return) address to the stack, effectively incrementing the stack pointer by two.

Upvotes: 1

Related Questions