English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 26 June 2015, 11:52   #1
Tracker
 
Posts: n/a
Asm programmer's guide -> errors [SOLVED]

Hello!

I'm new on this forum, and let me first say that it looks excellent!

I'm slowly getting back to asm coding and, using the Amiga System Programmer's Guide (1988), I tried to type in the Copperlist example found on p.93.
[environment is asm-one on e-uae.]

I get an error with the command ALIGN, placed before the copperlist. I switched it to EVEN, which seems ok.
However, I also get a Relative Mode Error due to the line:

moveq #CLsize,d0

I understand (or so I think!) that this is because CLsize is defined in another section of the program (near the end)

CLsize = CLend - CLstart

What I do not know is how to get around this.
If anyone's interested, hints appreciated!

Cheers.

Tracker

Last edited by Tracker; 27 June 2015 at 10:18. Reason: Problem solved!
 
Old 26 June 2015, 12:54   #2
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
What is CLsize size ? Is bigger than 255 ? Anyway try move.l #CLsize,D0 instead moveq.

Last edited by obiwanken; 26 June 2015 at 13:04.
obiwanken is offline  
Old 26 June 2015, 13:02   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
CLsize is an equate, so the only reason it would give a relative mode error would be because CLend and CLstart are not in the same section.

If the value of CLsize is outside of the range -128 to 127 then, for
moveq #CLsize
, you would get an error saying "value out of 8-bit range" or similar.
Leffmann is offline  
Old 26 June 2015, 13:26   #4
Tracker
 
Posts: n/a
Thanks for the answers!

Well, CLsize should be small (not sure how to get its size quickly from the command h.l CLsize though).
In any case, I tried the change moveq for move.l and, after doing so in a couple of places, it compiled fine.

I agree it's weird the Relative error's gone away in this way...

Anyway, not sure it's the end as the execution does nothing (while there should be some coloured lines on the screen and a wait for a left click...). Will try to look at it a bit later. Kind of weird that a listing in a book has such problems (probably it was written for another compiler, but still). Maybe it's my fault...
 
Old 26 June 2015, 14:14   #5
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
To get size just type ? and equate in command line (after compiling).
In your case:
? clsize
Even can be used as calculator
? 5*5
I think your program works well. It's a copper list tutorial.
obiwanken is offline  
Old 26 June 2015, 14:54   #6
Tracker
 
Posts: n/a
Quote:
Originally Posted by obiwanken View Post
To get size just type ? and equate in command line (after compiling).
In your case:
? clsize
Even can be used as calculator
? 5*5
I think your program works well. It's a copper list tutorial.

Thanks, I knew for the calculator, but not for the variables/labels. I'm taking note of everything, so I won't ask twice the same question and keep progressing

So clsize is about $226472.

As for the second point, I'm not sure: I think the prog should close the system, put on a black screen with 3 coloured lines and wait for a left click. It does nothing of this at present...
 
Old 26 June 2015, 15:04   #7
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
CLsize is toooooooo big, no idea why. Try to post your program here.
obiwanken is offline  
Old 26 June 2015, 16:33   #8
Tracker
 
Posts: n/a
Quote:
Originally Posted by obiwanken View Post
CLsize is toooooooo big, no idea why. Try to post your program here.
I think I've located the problem: it is in the allocation memory (the program directly branch to Ende, which ends with an error). I tested taht by adding some left-click wait in the Ende section, and indeed the program now waits for a left click to quit. The code follows. Let me note that this is probably not how I would have written things (and I do not yet understand everything), but I'm now rigorously following the book, copying exactly the source therein...

##

;CustomChip-Register

INTENA = $9A ; Interrupt-enable register
DMACON = $96 ; DMA-control
COLOR00 = $180 ; Color palette

;Copper Register

COP1LC = $80
COP2LC = $84
COPJMP1 = $88
COPJMP2 = $8a

;CIA-A Port register A (left mouse button)

CIAAPRA = $bfe001

;Exec Library Offsets

OpenLibrary = -30-522
Forbid = -30-102
Permit = -30-108
AllocMem = -30-168
FreeMem = -30-180

;graphics base

StartList = 38

;other Labels

Execbase = 4
Chip = 2

;*** INIT ***

;Request memory for the CopperList

Start:
move.l Execbase,a6
move.l #Clsize,d0
moveq #chip,d1
jsr AllocMem(a6)
move.l d0,CLadr
beq.s Ende

;Copy the CopperList in CLadr

lea CLstart,a0
move.l CLadr,a1
move.l #CLsize-1,d0
CLcopy:
move.b (a0)+,(a1)+
dbf d0,CLcopy

;*** MAIN ***

jsr forbid(a6)
lea $dff000,a5
move.w #$03a0,dmacon(a5)
move.l CLadr,cop1lc(a5)

clr.w copjmp1(a5)

;Switching DMA
move.w #$8280,dmacon(a5)

;Waiting for the left mouse button
Wait:
btst #6,ciaapra
bne.s Wait

;End of the program

move.l #GRname,a1
clr.l d0
jsr OpenLibrary(a6)
move.l d0,a4
move.l StartList(a4),cop1lc(a5)
clr.w copjmp1(a5)
move.w #$83e0,dmacon(a5)
jsr permit(a6)

;Freeing memory taken by Copperlist

move.l CLadr,a1
move.l #CLsize,d0
jsr Freemem(a6)

Ende:
clr.l d0
btst #6,ciaapra
bne.s Ende
rts

;Variables
CLadr:
dc.l 0

;Constants
GRName:
dc.b "graphics.library",0
even

;CopperList

CLstart:
dc.w color00,$0000
dc.w $640f,$fffe
dc.w color00,$0f00
dc.w $be0f,$fffe
dc.w color00,$0fb0
dc.w $ffff,$fffe

CLend:
CLsize = CLend - CLstart
end
 
Old 26 June 2015, 17:49   #9
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
Just tested your program and works well, German flag shown. Before you wrote that CLsize value is very big number, my value is $18. And this is your problem, you want alloc Chipmem which is not available and program ends. Check clsize=clend-clstart location. Must be $18.

Btw. I'm using Asm Pro.
obiwanken is offline  
Old 26 June 2015, 18:15   #10
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
I suppose that your CLsize position is in left edge (column 0) and assembler takes it as label. And your big value is memory position not a copper size. Just press TAB key before you define equates.
obiwanken is offline  
Old 26 June 2015, 19:49   #11
Tracker
 
Posts: n/a
Hum... So if right after compiling I do a
=s
I get

CLEND.........01.000000CC
CLSTART......01.000000B4
CLSIZE........01.000000CC

Isn't that weird that CLSIZE is not $CC-$B4=$18?
 
Old 26 June 2015, 20:35   #12
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
CLsize Must be $18 and is calculated as CLend-CLstart. If CLend=CLsize then CLsize is Label for assembler. I think it must be assembler problem, try Asm Pro.

Try to trace your prog with AD directive and you will see what happen.
Or change CLsize=CLend-CLstart to CLsize=$18

I'm curious
obiwanken is offline  
Old 26 June 2015, 21:06   #13
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Tracker View Post
CLsize = CLend - CLstart
Change to:

CLsize = CLend-CLstart
StingRay is offline  
Old 26 June 2015, 21:13   #14
obiwanken
Registered User
 
Join Date: Jan 2013
Location: Slovakia
Posts: 27
You right.
Asm One is accepting this mess.
But Asm Pro generate "NO operand space alowed" error.
obiwanken is offline  
Old 26 June 2015, 21:13   #15
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
There are a lot of typos in the System Programmers Guide. Esp in the example code.

CLSize <> CLsize (If I remember this is one of the errors!)
BippyM is offline  
Old 26 June 2015, 21:22   #16
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by obiwanken View Post
But Asm Pro generate "NO operand space alowed" error.
Check ASM-One/Pro prefs and make sure the "; Comment" checkbox is enabled.
StingRay is offline  
Old 26 June 2015, 22:52   #17
Tracker
 
Posts: n/a
Right! If I hard set CLsize to $18 instead of CLend-CLstart, then I see the German flag. Had a look at the original version with the debugger, and it seems that CLsize get some non-sense value, for some reason...
 
Old 26 June 2015, 23:00   #18
Tracker
 
Posts: n/a
Quote:
Originally Posted by StingRay View Post
Change to:

CLsize = CLend-CLstart

Exactly! [Sorry, backreading messages, as the newest did not show up before my last answer to Obiwanken]

Removing the spaces get things right.

Bippym: in asm-one there's no difference between M and m (at least in my configuration).

Many thanks to all!

I'm sure I'll have many other questions, as I'm eager to learn...
 
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide: WinUAE PPC OS 4.0 Classic Install Guide (Beta 12+) BinoX support.WinUAE 170 22 April 2021 11:37
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 13 30 December 2020 11:57
asm code file errors and external file locations Brick Nash support.WinUAE 0 06 April 2015 17:14
Help with programmer majsta support.Hardware 1 20 January 2011 03:30
My first guide - Drakkhen leveling guide Fragger Nostalgia & memories 2 08 April 2010 21:35

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:18.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09576 seconds with 13 queries