RE: A82: ASM code problem


[Prev][Next][Index][Thread]

RE: A82: ASM code problem



On Monday, July 07, 1997 9:42 PM, Thomas J. Hruska[SMTP:thruska@tir.com] wrote:
> At 07:54 PM 7/7/97 -0400, you wrote:
> No, I meant call (FINAL_ADDR).  The call opcode does exist (see the Z80
> Instruction Set Summary).

Yes, I know the CALL instruction exists, it's just that in Z80 assembly, if something has parenthesis around it, it means indirection -- the CPU will look at the value *at the address of the address in parenthesis.*  So regular CALL xxxx exists, but CALL (xxxx) doesn't (or it may compile fine that way, but it's bad programming practice to write it that way).

Now on to your code...

	<snip>


Here's your first problem:  the following line should be ROM_CALL(CLEARLCD), becuase ROM_CALL is not just an ordinary call to an address, it has an 'INDEX' value after it which the shell uses, so you can't simply call it.

>   call CLEARLCD            ; Clears the LCD

>   ld bc,0                  ; 0 -> c, 0 -> b
>   ld (CURSOR_ROW),bc       ; Set cursor at position (0,0)
>   ld hl,Text               ; Address of Text -> hl
>   ld de,(PROGRAM_ADDR)     ; (PROGRAM_ADDR) -> de
>   add hl,de                ; hl = hl + de

Up to here, everything else seems to be fine... you reset the CURSOR_ROW and CURSOR_COL values fine, and you find the absolute address of 'Text,' but here is where I start to get confused...
	It seems that you're trying to use the CALL (xxxx) opcode to call an indirect address...  The only way to indirectly call something is with the CALL (HL), CALL (IX) and CALL (IY) opcodes.  All other CALL instructions use direct addressing (where the immediate data points directly to the place to be called).

If this compiles at all (I didn't test it), TASM will think it's just a regular call to $8C2B, the value of FINAL_ADDR.  Once again, you need to use ROM_CALL when calling a ROM function, because the OS has to be able to adjust addresses accordingly for each ROM version.

>   
>   ld bc,D_ZT_STR
>   ld (FINAL_ADDR),bc
>   call (FINAL_ADDR)


In your second piece of code, you still don't use ROM_CALL with D_ZT_STR, but you probably should... or at least the Oshell-82 docs say so.

>   call D_ZT_STR

> Both programs should be compiled under OShell-82.  This is a very confusing
> problem and I really would like any hint to an answer.

I hope I was a help (email me if you've still got questions)
	Sam
-- 
Sam Davies <sdavies@mail.trilogy.net>


Follow-Ups: