Are You a Programmer? Think Twice Before You Say "It Is Just a Trivial 'Hello World'" example!
It is Monday in Germany, and it is Easter Monday 2016.
I had finally chance to take my "pimped" Commodore Amiga 500 out of the shelf (yes "she" is pimped, with 2 MB RAM, with a Workbench-switch between versions 2.0 and 3.1, with a Gotek floppy emulator, and so on). And I had played with it. Hm, you know me, no games, just coding, just assembler, just pure system.
The ASM-One assembler together with a "very" old book "Amiga Assembler Buch" by Peter Wollschlaeger did their job perfectly. I wrote a "Hello World" for the Motorola 68000 and Amiga DOS. I was able to assemble it, to link it and to run it. And here is the result:
Wow, what a result! It is tremendous!
I can see the "Hello World" printed on the command line of Amiga's Workbench! Ok, just kidding...
But wait a minute and just look at the code, the pure Motorola 68000 assembler code:
To print a "Hello World" on the Amiga 500 using assembler, you have to first find the address of the DOS library, open it, set parameters for the method, call it and and finally close it carefully at the end... It is not a just one or three lines of code you suppose to write...
So think twice before you say "it is just a trivial 'Hello World' example". Our modern machines do pretty much similar stuff as wirten above.
And think again about it when you decide to use a plenty of high sophisticated libraries to access a database, create services or integrate security. Think about what is going on under the hood. Think about this "Hello World" example. Think about complexity you introduce. Just think about it because this is reality.
---
I had finally chance to take my "pimped" Commodore Amiga 500 out of the shelf (yes "she" is pimped, with 2 MB RAM, with a Workbench-switch between versions 2.0 and 3.1, with a Gotek floppy emulator, and so on). And I had played with it. Hm, you know me, no games, just coding, just assembler, just pure system.
The ASM-One assembler together with a "very" old book "Amiga Assembler Buch" by Peter Wollschlaeger did their job perfectly. I wrote a "Hello World" for the Motorola 68000 and Amiga DOS. I was able to assemble it, to link it and to run it. And here is the result:
![]() |
Bildunterschrift hinzufügen |
Wow, what a result! It is tremendous!
I can see the "Hello World" printed on the command line of Amiga's Workbench! Ok, just kidding...
But wait a minute and just look at the code, the pure Motorola 68000 assembler code:
* Hello World using 68000 assembler
* based on example from Peter Wollschlaeger book 1987
SysBase: equ 4 ;base of exec
LVOOpenLib: equ -552 ;open lib
LVOCloseLib: equ -414 ;close lib
LVOOutput: equ -60 ;dos.lib get output-handle
LVOWrite: e qu -48 ;dos.lib write
* open dos.lib
main: move.l #dosname,a1 ;name of dos.lib
moveq #0,d0 ;version is not relevant
move.l SysBase,a6 ;set base address of exec
jsr LVOOpenLib(a6) ;call open lib
tst.l d0 ;any errors?
beq finish ;on error goto finish
move.l d0,DOSBase ;save pointer to lib
* find output handler
move.l DOSBase,a6 ;set base address of dos.lib
jsr LVOOutput(a6) ;call function
move.l d0,d4 ;save output handler
* print text
move.l d4,d1 ;set output handler
move.l #string,d2 ;set address of text
moveq #12,d3 ;set length of text
move.l DOSBase,a6 ;set base address of dos.lib
jsr LVOWrite(a6) ;call function
* close libs
move.l DOSBase,a1 ;set lib to close
move.l SysBase,a6 ;set base address of exec
jsr LVOCloseLib(a6) ;close the lib
finish: rts
* data
DOSBase: dc.l 0
cnop 0,2
dosname: dc.b 'dos.library',0
cnop 0,2
string: dc.b 'Hello world',10,0
cnop 0,2
To print a "Hello World" on the Amiga 500 using assembler, you have to first find the address of the DOS library, open it, set parameters for the method, call it and and finally close it carefully at the end... It is not a just one or three lines of code you suppose to write...
So think twice before you say "it is just a trivial 'Hello World' example". Our modern machines do pretty much similar stuff as wirten above.
And think again about it when you decide to use a plenty of high sophisticated libraries to access a database, create services or integrate security. Think about what is going on under the hood. Think about this "Hello World" example. Think about complexity you introduce. Just think about it because this is reality.
---
Comments
Post a Comment