jp (hl)

ZX evolution software and hardware

Postby justine » 23 Mar 2012, 19:11

Is there a way if i use JP (HL) in a routine to allow me to use RET in the routine that was jumped to ??

For example :

LD HL, TEST
JP (HL)
; Routine continues here


; This is the TEST routine

; Code to do stuff and then

RET ; Return to the line after the JP (HL)

Is this possible ???

Thanx
User avatar
justine
 
Posts: 101
Joined: 06 Jul 2011, 00:50
Location: Scotland
Group: Registered users

Postby нолька » 23 Mar 2012, 19:30

я проснулся среди ночи и понял, что всё...
всё идет по плану
User avatar
нолька
рОвный
 
Posts: 264
Joined: 08 Apr 2007, 21:12
Group: Registered users

Postby DimkaM » 23 Mar 2012, 19:41

JP (HL) worked as LD PC,HL
Code: Select all
   LD HL, TEST
   JP (HL)      ;PC=HL
...      |
...      |
...      ↓
TEST   go code
Last edited by DimkaM on 23 Mar 2012, 19:56, edited 2 times in total.
ZX-Evo rev C, ZXNetUsb rev С
DimkaM
 
Posts: 1290
Joined: 24 Mar 2010, 13:42
Location: джунгли Амазонки
Group: Registered users

Postby justine » 23 Mar 2012, 19:49

No what i need is a way to make a do the following with a command that doesnt exist. CALL (HL) now i know you can use that command but surely there is a way using JP (HL) so that when the called routine issues a RET it jumps back to the next command line after the JP (HL) was issued ??????
User avatar
justine
 
Posts: 101
Joined: 06 Jul 2011, 00:50
Location: Scotland
Group: Registered users

Postby DimkaM » 23 Mar 2012, 19:57

Code: Select all
   ld a,3
   call go_func
   ...
   ...   

go_func      ;a-number function
   add a,a
   ld hl,tabl_func
   add a,l
   ld l,a
   jr nc,l1
   inc h
l1   ld a,(hl)
   inc hl
   ld h,(hl)
   ld l,a
   jp (hl)

tabl_func
   dw func_1
   dw func_2
   ...
   dw func_n

func_1
   ret
func_2
   ret
...
...
func_n
   ret
ZX-Evo rev C, ZXNetUsb rev С
DimkaM
 
Posts: 1290
Joined: 24 Mar 2010, 13:42
Location: джунгли Амазонки
Group: Registered users

Postby lvd » 23 Mar 2012, 20:03

Code: Select all

ld hl,RETURN_PLACE
push hl
ld hl,JUMP_PLACE
jp (hl)
RETURN_PLACE  ;here we will return by ret



Многого нет здесь: http://lvd.nedopc.com
Image
User avatar
lvd
 
Posts: 1637
Joined: 07 Apr 2007, 22:28
Group: Registered users

Postby lvd » 26 Mar 2012, 14:22

TS-Labs wrote:
Code: Select all
call $+3
jp (hl)

You are stupid lamer. RET from a procedure will return to jp (hl).
Многого нет здесь: http://lvd.nedopc.com
Image
User avatar
lvd
 
Posts: 1637
Joined: 07 Apr 2007, 22:28
Group: Registered users


Return to Пентева - софт и железо

Who is online

Users browsing this forum: No registered users and 4 guests