20 November 2018, 19:03 | #1 |
Posts: n/a
|
Issues with ORG directive (vasm + FS-UAE)
Hi!
I am trying to learn the basics of Amiga programming by following along with ScoopexUs' video tutorial on Yotutube. https://www.youtube.com/playlist?lis...hTKJnjdTHz0_bW I am using vasm and running the program in FS-UAE, which has been working great until part 7 where the ORG/LOAD/JUMPPTR directives are included. This causes warnings when assembling with vasm and does not work at all in FS-UAE (only a blank screen is displayed when running the program). This is the source code in question (i had to make the Copper: label lowercase since vasm appears to be case sensitive) http://coppershade.org/asmskool/Tut7.S Assembling: Code:
$ vasmm68k_mot -Fhunkexe -kick1hunks -o hd0/tutorial Tut7.S vasm 1.8d (c) in 2002-2018 Volker Barthelmann vasm M68k/CPU32/ColdFire cpu backend 2.3c (c) 2002-2018 Frank Wille vasm motorola syntax module 3.11d (c) 2002-2018 Frank Wille vasm hunk format output module 2.9b (c) 2002-2017 Frank Wille warning 1012 in line 2 of "Tut7.S": directive has no effect > LOAD $20000 warning 1012 in line 3 of "Tut7.S": directive has no effect > JUMPPTR init seg20000(acrwx2): 266 bytes Code:
/usr/bin/fs-uae --amiga_model=A500 --hard_drive_0=hd0 --joystick_port_1=none --chip_memory=512 --slow_memory=512 Could anybody help me understand why this is not working? Apologies if this is in the wrong forum since i'm not sure exactly where the problem is. |
20 November 2018, 20:05 | #2 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
Quote:
Quote:
Quote:
It would also be sufficient to write this SECTION directive one line above the Copper: label. The code also works in Fast RAM. Quote:
Last edited by phx; 20 November 2018 at 20:10. Reason: -Fbin, -nocase |
|||||
20 November 2018, 21:34 | #3 | |
Posts: n/a
|
Thank you for your reply.
Quote:
http://coppershade.org/asmskool/Tut9.S Assembling this causes the the above mentioned errors, removing ORG/LOAD/JUMPPTR instead causes the following errors: Code:
$ vasmm68k_mot -Fhunkexe -kick1hunks -nocase -o hd0/tutorial Tut9.S vasm 1.8d (c) in 2002-2018 Volker Barthelmann vasm M68k/CPU32/ColdFire cpu backend 2.3c (c) 2002-2018 Frank Wille vasm motorola syntax module 3.11d (c) 2002-2018 Frank Wille vasm hunk format output module 2.9b (c) 2002-2017 Frank Wille error 39 in line 149 of "Tut9.S": illegal relocation > dc.w $120,(Spr>>16)&$ffff error 39 in line 150 of "Tut9.S": illegal relocation > dc.w $122,(Spr)&$ffff error 39 in line 152 of "Tut9.S": illegal relocation > dc.w $124,(NullSpr>>16)&$ffff error 39 in line 153 of "Tut9.S": illegal relocation > dc.w $126,(NullSpr)&$ffff error 39 in line 154 of "Tut9.S": illegal relocation > dc.w $128,(NullSpr>>16)&$ffff ***maximum number of errors reached!*** |
|
21 November 2018, 16:05 | #4 | |
Posts: n/a
|
Quote:
I must say that I don't use vasm, but I use ASM-ONE (editing my code on my Mac in Atom, which I think is a nice workflow). |
|
21 November 2018, 17:50 | #5 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
"Spr" is such a reference, which would have to be relocated by the OS loader (dos.library LoadSeg()) when running the executable. Legal relocations are usually something like Label+Addend, but here we have (Label>>16)&$ffff! This can only work in absolute code, while loaded and executed at a fixed address. Quote:
There are several workarounds. Either rewrite the code, so that you insert these addresses like Spr into the copper list during runtime. Or prepend a startup routine to the code, which copies everything to $20000, when the program is started (you probably also want to AllocAbs() this region, while being at it). Example: Code:
section code,code lea start(pc),a0 lea $20000,a1 move.w #(end-start)/2-1,d0 .copy: move.w (a0)+,(a1)+ dbf d0,.copy jmp $20000 start: ORG $20000 ; LOAD $20000 ; JUMPPTR init w =320 h =256 bplsize =w*h/8 screen =$60000 init: move.l 4.w,a6 ;execbase ... section code,code end: |
||
21 November 2018, 19:15 | #6 |
Posts: n/a
|
creativecoder: i tried chipmap a while back, but it didn't return any output when i ran it directly in AmigaDos (A500/KS 1.3). I didn't investigate it any further.
Do you save the source file from Atom and assemble it on the Amiga using ASM-ONE? I use vscode with the "Amiga Assembly" extension which has quite a few nice features like assembling on save and being able to launch FS-UAE directly from the editor. phx: thank you for the explanation and examples! I will play around with it and see if i can make it work. |
21 November 2018, 19:48 | #7 | |
Posts: n/a
|
Quote:
Sounds nice! Working on a Mac or PC? |
|
30 August 2023, 14:43 | #8 | |
Registered User
Join Date: Aug 2023
Location: Neu-Isenburg/Germany
Posts: 5
|
Quote:
|
|
30 August 2023, 16:25 | #9 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
AllocAbs()first. IMHO absolute RAM addresses should only be used if you take over the system completely, and the only way to return to the OS is by reboot. |
|
02 September 2023, 11:37 | #10 |
Registered User
Join Date: Aug 2023
Location: Neu-Isenburg/Germany
Posts: 5
|
What workflow would be your recommendation if you'd want to completely take over (demoscene style) and then reboot, while having fixed addresses?
|
02 September 2023, 23:21 | #11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
You can find many example sources on the net, for cleanly taking over the system.
At first I would use the OS to gather all useful information, like PAL/NTSC, CPU type, available memory and memory locations. Then take over the system by loading a default View ( LoadView(NULL), 2x WaitTOF()), get the Blitter ( OwnBlitter(), WaitBlit()), disable all DMA channels and interrupts, reset the chipset into default state ( FMODE=0, set BPLCONx, etc). You may also have to disable the MMU (or set to transparent translation for 040/060). After that you can completely use all system resources. Copy your code to absolute memory addresses, set exception vectors, use the custom chipset directly, etc. But this is the point of no return (to the OS). The steps required will vary a little bit, when you need to load data. A single file with all data included could also be launched from Workbench, but otherwise I would recommend to write a trackloader for the boot block and do you own disk routines. The boot block approach also has the advantage that the system is in a more defined state, without any unknown hardware causing interrupts (like network cards, hard disk controllers, etc.). |
03 September 2023, 13:28 | #12 | |
Registered User
Join Date: Aug 2023
Location: Neu-Isenburg/Germany
Posts: 5
|
Quote:
It's more the "copy your code to absolute memory addresses" that's still a problem with a cross compiler like vasm. With a trackloader that is under complete control, but for just quick testing of single parts of your code, the missing LOAD directive is still a problem. The OS loads your executable to an unknown position in memory. Copying it from there to a fixed address still has the problem of potentially dangerous overlap. When I stopped working with Amiga games, we had 2-Amiga development systems, where one Amiga had a very small listener program that could receive code and data via cable and then execute it. So other than the small listener, we had complete memory available. |
|
03 September 2023, 16:23 | #13 | ||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
Quote:
Quote:
Quote:
As an example, have a look at the full source of our last game project: https://server.owl.de/~frank/BlkStberries.lha |
||||
03 September 2023, 23:44 | #14 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
|
The tutorials start with absolute addressing, to dispel some of the magic and empower coders: Your code, as well as your resources end up at specific addresses in memory.
Like Phx says, LOAD doesn't make much sense when cross-assembling, unless it's connected to an emulator which does have "Amiga memory". For learning, this offers the benefits of showing what you did, examining variables, interpreting hex numbers to check values, etc. This is only possible with a native Assembler which has a monitor, or running a Monitor program separately. You can also do it if the emulator has a debugger and monitor, but that would be very confusing, I think. The Amiga is a real computer and this is how your program is converted to real words in memory. Native tools are more direct, and this directness offers further benefits, such as not having to reassemble all of your program, find the part of your program that crashed to the Assembler prompt with a message + crash address, and so on. Since anyone who has a 1MB Amiga (preferably with an extra floppy drive) can code Assembler for the same spec, I wanted to show this. In this environment, using ORG, LOAD, and EXTERN will still let you reassemble in seconds on a 7MHz 68000. The tutorials are coded live on such a config. So, LOAD doesn't make sense for a cross-assembler, but ORG can. The simplest example where fixed addresses are very helpful is for track-loaded programs and resources. In this environment, normally the OS is shut down completely and overwritten to use maximum memory. In the tutorials leading up to the introduction of SECTION statements, you can replace ORG and LOAD at the top with a SECTION MyCode,C |
05 September 2023, 00:41 | #15 | |
Registered User
Join Date: Aug 2023
Location: Neu-Isenburg/Germany
Posts: 5
|
Quote:
|
|
05 September 2023, 11:56 | #16 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
It's always hard to dig through somebody else's code, even if I tried to comment most of it. Feel free to ask, if you have any questions (preferably by email, if the question is not of common interest).
Quote:
I'm currently adapting this engine to 8-way scrolling again. I had it already running ten years ago (with the game "Solid Gold"), but with an inferior technique. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FS-UAE graphics issues | soundtrackgeek | support.FS-UAE | 12 | 25 April 2020 12:16 |
REPT directive in vasm | phx | Coders. Asm / Hardware | 8 | 01 October 2014 21:48 |
FS-UAE MacOs issues | fnap | support.FS-UAE | 2 | 02 October 2012 20:27 |
AsmOne even directive...? | pmc | Coders. General | 30 | 04 December 2009 09:33 |
Invalid Directive | Kimmo | support.WinUAE | 1 | 23 July 2004 11:23 |
|
|