[A89] Re: a68k vs as (linking problems)


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

[A89] Re: a68k vs as (linking problems)




I noticed you often replace jbsr on as with bsr. This is not always
possible. I changed bsr's to rom calls to jsr, and included OS.h and the
program compiled and ran. Here is my changes...

	include "OS.h"

	xdef    _ti89
	xdef    _nostub

AMS_jumptable  equ $C8
;memcpy         equ $26a
;ScreenClear    equ $19e
;DrawStr        equ $1a9
;ngetchx        equ $51
;sprintf        equ $53

   movem.l    d3-d7/a2-a6,-(sp)
   move.l     AMS_jumptable,a5

   lea        -3840(sp),sp  ; buffer
   pea        3840    ; 2 bytes
   pea        $4C00    ; 4 bytes (address)
   pea        8(sp)    ; 4 bytes (address)
   move.l     4*memcpy(a5),a4 ;
   jsr        (a4)    ; memcpy(buffer,$4C00,3840) ; jsr instead of bsr
   jsr        _main					  ; this could
be bsr
   pea        3840    ; 2 bytes
   pea        16(sp)    ; 4 bytes
   pea        $4C00    ; 4 bytes
   move.l     4*memcpy(a5),a4 ;
   jsr        (a4)    ; memcpy($4C00,buffer,3840) (jsr instead of bsr)
   lea        3864(sp),sp
   movem.l    (sp)+,d3-d7/a2-a6
   rts

_main:
   link.w     a6,#0

   move.l     4*ScreenClear(a5),a4 ;
   jsr        (a4)    ; ClrScr()		; jsr instead of bsr

   jsr        rand				; jsr instead of bsr
   lea        -30(sp),sp
   move.w     d0,-(sp)  ; 2 bytes (word)
   pea        string    ; 4 bytes (address)
   pea        6(sp)    ; 4 bytes (address)
   move.l     4*sprintf(a5),a4
   jsr        (a4)				; jsr instead of bsr

   move.w     #1,-(sp)  ; 2 bytes (word)
   pea        12(sp)
   move.w     #0,-(sp)  ; 2 bytes (word)
   move.w     #0,-(sp)  ; 2 bytes (word)
   move.l     4*DrawStr(a5),a4
   jsr        (a4)				; jsr instead of bsr

   move.l     4*ngetchx(a5),a4
   jsr        (a4)				; jsr instead of bsr

   unlk       a6
   rts

string:
   dc.b       "random: %i",0


Although, I would just learn GNU as syntax. It's not that different, and
it's much more advanced in optimizing your code than a68k is. Just a
suggestion though...

Hope this helps,

John David Ratliff
jdratlif@cs.indiana.edu


-----Original Message-----
From: assembly-89-bounce@lists.ticalc.org
[mailto:assembly-89-bounce@lists.ticalc.org] On Behalf Of R.A.
Sent: Tuesday, August 20, 2002 10:16 PM
To: assembly-89@lists.ticalc.org
Subject: [A89] a68k vs as (linking problems)


sorry, didn't know that the list didn't support attachments,
here are the files (as text)

---- BEGIN rtest.asm ----
   xdef    _ti89
   xdef    _nostub

AMS_jumptable  equ $C8
memcpy         equ $26a
ScreenClear    equ $19e
DrawStr        equ $1a9
ngetchx        equ $51
sprintf        equ $53

   movem.l    d3-d7/a2-a6,-(sp)
   move.l     AMS_jumptable,a5

   lea        -3840(sp),sp  ; buffer
   pea        3840    ; 2 bytes
   pea        $4C00    ; 4 bytes (address)
   pea        8(sp)    ; 4 bytes (address)
   move.l     4*memcpy(a5),a4 ;
   bsr        (a4)    ; memcpy(buffer,$4C00,3840)
   jsr        _main
   pea        3840    ; 2 bytes
   pea        16(sp)    ; 4 bytes
   pea        $4C00    ; 4 bytes
   move.l     4*memcpy(a5),a4 ;
   bsr        (a4)    ; memcpy($4C00,buffer,3840)
   lea        3864(sp),sp
   movem.l    (sp)+,d3-d7/a2-a6
   rts

_main:
   link.w     a6,#0

   move.l     4*ScreenClear(a5),a4 ;
   bsr        (a4)    ; ClrScr()

   bsr        rand
   lea        -30(sp),sp
   move.w     d0,-(sp)  ; 2 bytes (word)
   pea        string    ; 4 bytes (address)
   pea        6(sp)    ; 4 bytes (address)
   move.l     4*sprintf(a5),a4
   bsr        (a4)

   move.w     #1,-(sp)  ; 2 bytes (word)
   pea        12(sp)
   move.w     #0,-(sp)  ; 2 bytes (word)
   move.w     #0,-(sp)  ; 2 bytes (word)
   move.l     4*DrawStr(a5),a4
   bsr        (a4)

   move.l     4*ngetchx(a5),a4
   bsr        (a4)

   unlk       a6
   rts

string:
   dc.b       "random: %i",0
---- END FILE ----

---- BEGIN rtest.s ----
   .xdef    _ti89

   .equ    AMS_jumptable,0xC8
   .equ    memcpy,0x26a
   .equ    ScreenClear,0x19e
   .equ    DrawStr,0x1a9
   .equ    ngetchx,0x51
   .equ    sprintf,0x53

ASM_loader:
   movem.l    %d3-%d7/%a2-%a6,-(%sp)

   move.l     AMS_jumptable,%a5

   lea        (%sp,-3840),%sp
   pea        3840
   pea        0x4C00
   pea        (%sp,8)
   move.l     4*memcpy(%a5),%a4
   jbsr       (%a4)

   jsr        _main

   pea        3840
   pea        (%sp,16)
   pea        0x4C00
   move.l     4*memcpy(%a5),%a4
   jbsr       (%a4)
   lea        (%sp,3864),%sp

   movem.l    (%sp)+,%d3-%d7/%a2-%a6
   rts

_main:
   link.w     %a6,#0

   move.l     4*ScreenClear(%a5),%a4
   jbsr       (%a4)

   bsr        rand
   lea        (%sp,-30),%sp
   move.w     %d0,-(%sp)
   pea        RandString
   pea        (%sp,6)
   move.l     4*sprintf(%a5),%a4
   jbsr       (%a4)

   move.w     #1,-(%sp)
   pea        (12,%sp)
   move.w     #0,-(%sp)
   move.w     #0,-(%sp)
   move.l     4*DrawStr(%a5),%a4
   jbsr       (%a4)

   move.l     4*ngetchx(%a5),%a4
   jbsr       (%a4)

   unlk       %a6
   rts

RandString:
   .string    "random: %i"

.comm _nostub,2
---- END FILE ----

regards,
ra.-






Follow-Ups: References: