CPCWiki forum

General Category => Programming => Topic started by: cpcuser on 09:41, 16 November 16

Title: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: cpcuser on 09:41, 16 November 16
Hi good afternoon.
I want to pass the address of symbols to the asmprogramm.
Where there is at the cpc6128 free ram in the zeropage to put the address there and from the program to then pick up?

Or is there another possibility to pass the address to the asmprogramm?


this is for ccz80++.


thank you.
greeting



include Indirections6128.ccz80++
include Text.ccz80++


class Test
{
  static void main()
  { 
     static short symbole[] = { 0,0,126,195,129,129,195,126, 0,0,0,0,0,36,24,0
      6,8,0,0,0,0,0,0 ,126,66,126,66,126,66,126,066};
     
     symbol();
      Text.Cls();
    Text.PrintString("\n\rtuvw");   
  }
   
   public static void symbol()
   asm
   {
      ld a,115
      call #bbae
      ld de,115
      call #bbab
      ld hl, ??  adresse from symbole[] 
      ld a,116           
      ld b,4   
               
   __sch:
      push af
      push bc
      push hl
      call #bba8     
      pop hl
      ld bc,8                 
      add hl,bc
      pop bc
      pop af
      inc a
      djnz __sch
      ld h,3
      ld l,5
      call #bb75
      ld a,116
      call #bb5a
   ret
   }
}
Title: Re: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: arnoldemu on 10:40, 16 November 16
C uses the stack for parameters.

e.g.


void symbol(void *symboldata)


Maybe ccz80 does that too?

then in asm do this:


ld hl,#2
add hl,sp
ld e,(hl)
inc hl
ld d,(hl)
Title: Re: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: cpcuser on 13:16, 16 November 16
hello, thanks.


greeting
Title: Re: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: arnoldemu on 15:01, 16 November 16
Quote from: cpcuser on 13:16, 16 November 16
hello, thanks.


greeting

ccz80++ in Graphics.ccz80++ (a C++ function with inline asm).


  public static void Origin(int argument1, int argument2)
    asm (Indirections.Values())
    {
      ld   hl,2                  ;;; <<<< return address from ret
      add  hl,sp             ;; <<< parameters on stack
      ld   e,(hl)               ;; << argument2 in de (parameters in reverse)
      inc  hl
      ld   d,(hl)                           
      inc  hl
      ld   a,(hl)               ;; << argument1 in hl
      inc  hl
      ld   h,(hl)
      ld   l,a                                ; HL = 1st parameter
      ex   de,hl                              ; DE = x, HL = y
      jp   __gra_set_origin
    }


Yes if you make asm code and use winape, then use the stack.

extern static void myFunction(int param1, int param2);


in asm:


__myFunction:   ;;; <<< check map/list for function name
   ld   hl,2                  ;;; <<<< return address from ret
      add  hl,sp             ;; <<< parameters on stack
      ld   e,(hl)               ;; << argument2 in de (parameters in reverse)
      inc  hl
      ld   d,(hl)                           
      inc  hl
      ld   a,(hl)               ;; << argument1 in hl
      inc  hl
      ld   h,(hl)
      ld   l,a                                ; HL = 1st parameter
...
Title: Re: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: arnoldemu on 15:05, 16 November 16
ccz80++ manual. English. Page 21 "Using assembler" describes parameters.

It doesn't say about map or listing. I hope asm file has label in it.


Title: Re: Where there is at the cpc6128 free ram in the zeropage ? Or .....
Post by: cpcuser on 16:08, 16 November 16

Yes, thank you.
A good explanation.


greeting
Powered by SMFPacks Menu Editor Mod