For development I always like to have a couple of different options for editing, so let’s continue our installation. Like the C compiler if you do not have the AmigaShell used previously open it and use “cd t:” to enter the Amiga temp file area. We’ll extract/install both in one list of commands. You will notice below the “lha” commands reference our “transfer drive” by volume name rather than the “dh1:” drive name we’ve used before. If you remember from the “info” command in an earlier article these are effectively equivalent in this situation and given here by way of an example.
Lha x xfer:vim60bin Copy vim/vim60/Vim c: Delete #? all Lha x xfer:redit Copy Redit2.0/Redit c: Delete #? all
We have installed two additional text editors (the Amiga system includes a couple of very basic editors itself, but I would not recommend them for extended use). Vim is most known in Unix and Linux circles, perhaps less in recent years than before, but will be familiar to users of those system. Redit is a fairly simple text editor that is easier to use for most people.
We need a reasonable text editor because we need to make some additions to that “User-Startup” file we looked at while installing the C compiler. By having a transfer disk we can potentially use the “host” software to edit code, or we could be “authentic” and use native text editor for code too.
Method 1 – Vim, which needs a little setup to use
assign vim: t: vim s:user-startup
Method 2 – Redit, graphical editor
Redit s:user-startup
With user-startup open, add the following three lines exactly at the end.
assign >NIL: vim: t: assign >NIL: mkinclude: t: setenv PhxAss/PHXASSINC Work:NDK39/Include/include_i
Save and exit your chosen editor.
The first line is similar to the command given slightly earlier and prevents Vim popping up lots of “requestors” when trying to use it. This is enough setup for basic usage of the Vim editor without too many fancy features. The last line is used to tell the PhxAss assembler where the required NDK files are located. You will have noticed a line in the User-Startup file for the C include files. The line in the middle we’ll come back to shortly.
The last thing we will want to install is a “make” tool. There are a lot of different versions on Aminet but the previously mentioned “make_bin.lha” from “dev/c” suits our needs. After performing the “Lha” command check the numbers (file size) for “make-3.76.1/make” to make sure you have a well tested version. The size we’re looking for is “106648”.
Cd t: Lha x xfer:make_bin Copy make-3.76.1/make C: Copy make-3.76.1/make.guide hd0:toolsdocs Delete #? all
The make tool tries to access “mkinclude:” in the same way that Vim tries to access “vim:” hence the second assign added to the User-Startup file above.
This completes the setup, but we should test. We could tell the (emulated) Amiga to “execute” the user-startup file, but it is quick and easy to just reset. On a PC keyboard do this with Ctrl-Windows-PageDn. It should only take five seconds or so.
The simplest test is of the most complex tool, the C compiler. Create a file ctest.c (we can work in the T: temp area) containing the following. You might end up playing “hunt the symbol” a bit without me mentioning that on the Amiga the double quote is two keys left of the ‘L’ key and shifted, at least on the “American” Amiga layout…
#include <stdio.h>
int main (int argc, char *argv[])
{
puts ("Hello Amiga!");
return 0;
}
Save then compile and execute with the following commands.
vc ctest.c -o ctest ctest
We should test the assembler though too, right? Well if you insist, make a file asmtest.s as follows.
; required for exec_lib.i to generate LVOs
FUNCDEF MACRO
_LVO\1 EQU FUNC_CNT
FUNC_CNT SET FUNC_CNT-6
ENDM
FUNC_CNT SET 5*-6
; some CALL macros
CALLEXEC MACRO
move.l 4.w,a6
jsr _LVO\1(a6)
ENDM
CALLDOS MACRO
move.l _DOSBase,a6
jsr _LVO\1(a6)
ENDM
; includes, just exec and dos
include "exec/exec.i"
include "exec/exec_lib.i"
include "dos/dos.i"
include "dos/dos_lib.i"
; our code
section TestCode,code
; open any version of dos.library
lea DosName,a1
moveq.l #0,d0
CALLEXEC OpenLibrary
move.l d0,_DOSBase
beq NoDOS
; get output handle
CALLDOS Output
move.l d0,_stdout
; test message
lea TestMsg,a0
; find end
move.l a0,a1
msgloop tst.b (a1)+
bne.s msgloop
; calculate length
sub.l #1,a1
sub.l a0,a1
; write the message
move.l _stdout,d1
move.l a0,d2
move.l a1,d3
CALLDOS Write
; close dos.library
CloseDOS move.l _DOSBase,a1
CALLEXEC CloseLibrary
NoDOS rts
; data
section TestData,data
DosName DOSNAME
TestMsg dc.b "Hello Amiga!",10,0
; variables
section TestMem,bss
_DOSBase ds.l 1
_stdout ds.l 1
end
You can assemble and test this with the following commands. PhxAss is the simpler tool here.
phxass asmtest.s asmtest
If you got the “Hello Amiga” message back and no errors when building then you’re “good to go”.
As and when we start building assembly code we would likely use vasm from the vbcc package. The test assembly file can be built using the following.
vasmm68k_mot -devpac -Fhunkexe -IWork:NDK39/Include/include_i asmtest.s -o asmtest
This is easier in a “makefile” than manually entered. Now you know why we tested with PhxAss.