View Single Post
Old 07 December 2018, 22:36   #93
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by litwr View Post
I like such tricks! Can it work with 68020?
Yes.

Quote:
BTW I have a routine to print the next text, for example,
Code:
         bsr printstr
         dc.b "Hello World!",0
         even

printstr:
         movea.l (sp)+,a2
         lea stringbuf(a3),a4   ;A3 is a base for data section
         moveq #0,d0
.l1:     addq.w #1,d0
         move.b (a2)+,d1
         move.b d1,(a4)+
         bne .l1
         
         move.l a2,d1
         addq.l #1,d1    ;is it necessary?
         andi.b #$fe,d1
         move.l d1,-(sp)

         ;movea.l GRAPHICS_BASE(a3),a6
         ;movea.l RASTER_PORT(a3),a1
         lea stringbuf(a3),a0
         subq.w #1,d0
         jmp Text(a6)
I'm sorry but your code style is so wrong for so much reasons (at least for the 68k architecture). Why mixing code/data and mess with stack and alignment?
Even understanding what you want to do in such a simple routine is complicated by how you write it!

You can use a simple straightforward call:
Code:
        move.w  #(endstr-string-1),d0
        lea     string(pc),a0
;       movea.l RASTER_PORT(a3),a1
;       movea.l GRAPHICS_BASE(a3),a6
        jsr     _LVOText(a6)
;       code continue..

string  dc.b 'Hello World!',0
endstr   
        even
If you insist in complicating your life then this can be a "wrong way" better version:
Code:
        bsr     printstr
        dc.b 'Hello World!',0
        even
;       code continue..

printstr:
        moveq   #-1,d0 
        movea.l (sp),a0
.l      addq.l  #1,d0
        tst.b   (a0,d0.l)
        bne.b   .l
        move.l  d0,d1
        addq.l  #2,d1
        lsr.l   #1,d1
        add.l   d1,d1
        add.l   d1,(sp)

;       movea.l GRAPHICS_BASE(a3),a6
;       movea.l RASTER_PORT(a3),a1
        jmp Text(a6)
ross is offline  
 
Page generated in 0.04535 seconds with 11 queries