When I see posts about web-based/script-based/managed code..
Page 1 of 1
Frant
King's Bounty



Posts: 24656
Location: Your Mom
PostPosted: Wed, 1st Apr 2015 13:56    Post subject: When I see posts about web-based/script-based/managed code..
.. I feel nostalgic about old days of spaghetti code in Assembler. Sure, I can't decipher some of my own sources from 1990 but I remember it was really fun to try to figure out how to solve a problem purely by using your brain....


Code:
>extern "df0:font16",font
>extern "df1:petpic.bmp",pet
>extern "df1:mod.petsematary",mt_data
org $20000
load $20000
execbase             =        4
Forbid               = -30 -102
Permit               = -30 -108
OldOpenLibrary       = -30 -378
CloseLibrary         = -30 -384
start:   bset #1,$bfe001
   bsr.L   mt_init
   move.l execbase,a6
   lea    gfxname,a1
   jsr    OldOpenLibrary(a6)
   move.l d0,gfxbase
   beq.l  no_gfxbase
   move.l execbase,a6
   jsr    Forbid(a6)
   move.l gfxbase,a0
   move.w #$4000,$dff09a
   move.w #$0080,$dff096
   move.l $6c,oldirq
   move.l #interrupt,$6c
   move.l 50(a0),oldcopper
   move.l #copper,50(a0)
   move.w #$86c0,$dff096
   move.w #$c000,$dff09a
   move.l #text,counta
   move.l   #empty,d0
   move.w   d0,sprite+6
   swap   d0
   move.w   d0,sprite+2
   move.l   #pet,d0
   move.l   #pet+20480,d1
   move.l   #pet+40960,d2
   move.w   d0,p1hi+6
   move.w   d1,p2hi+6
   move.w   d2,p3hi+6
   swap   d0
   swap   d1
   swap   d2
   move.w   d0,p1hi+2
   move.w   d1,p2hi+2
   move.w   d2,p3hi+2
   move.l   #swind3,d0
   move.w   d0,p4hi+6
   swap   d0
   move.w   d0,p4hi+2
   move.l   #st1,countb
mus:   btst   #6,$bfe001
   bne.L   mus
quit:   move.l gfxbase,a0
   move.w #$4000,$dff09a
   move.w #$0080,$dff096
   move.l oldirq,$6c
   move.l oldcopper,50(a0)
   bsr.L   mt_end
   move.w #$8080,$dff096
   move.w #$c000,$dff09a
   move.l execbase,a6
   jsr    Permit(a6)
no_gfxbase:
   clr.l   d0
   rts
interrupt:
   move   SR,-(a7)
   movem.l a0-a6/d0-d7,-(a7)
   bsr.L   mt_music
   bsr.L   lett
   bsr.L   blitter
   bsr.L   blitter2
   bsr.L   sinus
   movem.l (a7)+,a0-a6/d0-d7
   move   (a7)+,SR
   dc.w   $4ef9
oldirq:   dc.l   0
gfxname:   dc.b "graphics.library",0
even

gfxbase:   dc.l 0
oldcopper:   dc.l 0

lett:   clr.l   d0
   clr.l   d1
   clr.l   d2
   clr.l   d3
   clr.l   d4
   suba.l   a0,a0
   suba.l   a1,a1
   suba.l   a2,a2
   suba.l   a3,a3
   cmpi.b   #8,bit
   bne.L   hit
   move.l   counta,a3
   move.b   (a3),d4
   move.b   d4,bitt
   cmpi.b   #$00,d4
   beq.L   reset
   addi.l   #1,counta
   clr.l   d0
   clr.l   d1
   move.l   #font,a0
   move.l   d4,d0
   subi.l   #$20,d0
   divu   #40,d0
   move.w   d0,d1
   swap   d0
   mulu   #40*8,d1
   mulu   #1,d0
   adda.l   d0,a0
   adda.l   d1,a0
   move.l   #7,d0
   move.l   #swind+88,a1
lopp:   move.b   (a0),(a1)
   addi.l   #40,a0
   addi.l   #90,a1
   dbf   d0,lopp
   move.b   #0,bit
   rts
reset:   move.l   #text,counta
   bra.L   lett
hit:   rts

counta:   dc.l 0
bitt:   dc.b 0
bit:   dc.b 0




blitter:lea   swind+2,a0
   move.l   a0,$dff050
   subq   #2,a0
   move.l   a0,$dff054
   move.l   #$e9f00000,$dff040
   move.l   #$ffffffff,$dff044
   move.l   #$00000000,$dff064
   move.w   #%0000001000101101,$dff058
   addi.b   #2,bit
   rts

blitter2:
   move.l   #swind+4,$dff050
   move.l   #swind2+2,$dff054
   move.w   #0,$dff064
   move.w   #0,$dff066
   move.w   #%0000001000101000,$dff058
   rts

sinus:   move.l   #empty,$dff050
   move.l   #swind3,$dff054
   move.w   #%00010100101000,$dff058
   move.l   countb,a0
   move.l   #39,d4
   move.w   #$09f0,d5
   move.l   #swind2,d2
   move.l   #swind3,d3
loop:   move.l   (a0)+,d0
   cmpi.l   #$ffffffff,d0
   beq.L   reset2
   move.l   d2,$dff050
   move.l   d3,d1
   mulu   #80,d0
   addi.l   d0,d1
   move.l   d1,$dff054
   move.w   d5,$dff040
   move.l   #$ffffffff,$dff044
   move.w   #88,$dff064
   move.w   #78,$dff066
   move.w   #%00001000000001,$dff058
   addi.l   #2,d2
   addi.l   #2,d3
   dbf   d4,loop
   addi.l   #4,countb
   rts
reset2:   move.l   #st1,countb
   rts

st1:


dc.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dc.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dc.l 2,4,6,8,10,8,6,4,2,1,1,1,1,1,2,2,3,4,6,8,10,12,13,13,12,10,8
dc.l 6,4,3,2,2,1,1,1,1,1
dc.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dc.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
dc.l $ffffffff
countb:   dc.l   0

copper:   dc.l $01000200
   dc.l $01800000,$01820f00,$01840222,$01860444
   dc.l $01880666,$018a0888,$018c0aaa,$018e0ccc
sprite:   dc.l $01200000,$01220000
   dc.l $2407fffe,$01020000
p1hi:   dc.l $00e00000,$00e20000
p2hi:   dc.l $00e40000,$00e60000
p3hi:   dc.l $00e80000,$00ea0000
p4hi:   dc.l $00ec0000,$00ee0000
   dc.l $2c07fffe,$0100b200
   dc.l $008e2c41,$009039c1
   dc.l $00920038,$009400d0
   dc.l $01080000,$010a0000
   dc.l $5807fffe,$0100c200
   dc.l $7807fffe,$0100b200
   dc.l $ffdffffe,$01020000
   dc.l $1c07fffe,$01000200
   dc.l -2


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"The sky was the color of a TV tuned to a dead station" - Neuromancer
Back to top
garus
VIP Member



Posts: 34197

PostPosted: Wed, 1st Apr 2015 14:16    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:41; edited 1 time in total
Back to top
Frant
King's Bounty



Posts: 24656
Location: Your Mom
PostPosted: Wed, 1st Apr 2015 14:22    Post subject:
For me assembler is different from any other higher level language. We're talking right down to the nuts and bolts, direct access to the hardware, no API, nothing like that at all, just mnemonics and a lot of addresses, numbers, logical operands of various complexity.

I've programmed in Basic, Pascal, C, C#, some Java, Python, HTML/CSS... and it's not comparable to classic assembler which gives you absolute and direct control of every aspect of the hardware (and thus have to save the source file after every compile and test-run in case it crashes). Wink

With modern managed languages you have several layers of abstraction from the computer and hardware. Programmers today doesn't have to know anything about the hardware itself (which is obviously great for programmers that have a task to do and use existing API's to do things for you instead of doing it yourself, a time-consuming process).

It's about "fun".

Assembler = you're driving a rally car, taking turns that may throw you rolling into trees. <- fast code, decoding ideas to abstract assembler code, having fun when you get something in particular to work, a thrill (which can end in "fuuuuuuu..." or "whoaaaa").

Modern high level languages = you sit on a train and write a paper. <- effective but somewhat "boring". you know what your goal is and you have a pretty good idea how to get there with the IDE telling you which lines are wrong and what is wrong.


I'm obviously talking about hobby programming, not commercial or work.


Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"The sky was the color of a TV tuned to a dead station" - Neuromancer
Back to top
garus
VIP Member



Posts: 34197

PostPosted: Wed, 1st Apr 2015 14:39    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:41; edited 1 time in total
Back to top
shole




Posts: 3363

PostPosted: Wed, 1st Apr 2015 14:57    Post subject:
it's mostly just crosschecking with function and registry tables
dem damn registries

asm is basically this:

load up values to registries
push button
receive bacon

i like asm as an intellectual exercise since it's so pure and cold
closest to hardware short of doing solder work
but there's no way in hell i would ever actually code anything with it
Back to top
Werelds
Special Little Man



Posts: 15098
Location: 0100111001001100
PostPosted: Wed, 1st Apr 2015 15:08    Post subject:
Frant wrote:
Assembler = you're driving a rally car, taking turns that may throw you rolling into trees. <- fast code, decoding ideas to abstract assembler code, having fun when you get something in particular to work, a thrill (which can end in "fuuuuuuu..." or "whoaaaa").

Modern high level languages = you sit on a train and write a paper. <- effective but somewhat "boring". you know what your goal is and you have a pretty good idea how to get there with the IDE telling you which lines are wrong and what is wrong.

If you're gonna draw a car analogy at least do it properly Wink

ASM is like having all the wires sticking out right in front of you, with only very basic labelling on them and little to no guidance on which wires you can or can't cross. To steer left you'll need to cross specific cables in a specific order, all whilst doing the same to have some forward movement. Want to get some sound out of the speakers? Sure, generate a sinus signal yourself over the wires related to that subsystem*.

A high level language gives you the pedals, wheel, shifter and properly labelled buttons and knobs for all the other wires. They'll generate that sinus signal for the heater properly too.


I think every programmer should have some experience in both ASM and C as it teaches them how shit actually works, but more fun? Meh.


* actually had to do that at uni Wink
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 1st Apr 2015 16:40    Post subject:
I was pretty good at asm in uni but I prefer hacking my stuff together in a high level language (such as the very sophisticated javascript Cool Face no honestly, I love that fugly language ) to see the result, which I find more interesting than to try and debug some obfuscated shit that is holding me back from achieving my set goal


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
BearishSun




Posts: 4484

PostPosted: Wed, 1st Apr 2015 17:45    Post subject:
I wouldn't program in ASM because it's not practical anymore, but I love my C++, especially optimizing code and squeezing out the last bit of performance. It offers a nice compromise between being an actually practical language for larger programs while still being pretty damn close to the hardware.

On the other hand when I just need something to work and don't care much about how fast it works, C# (or other very high level languages) are a dream to work with.
Back to top
tainted4ever
VIP Member



Posts: 11336

PostPosted: Wed, 1st Apr 2015 19:26    Post subject:
^What he said.

At work we still regularly have to deal with assembler (we sell security software). Last month spent a week debugging compiler bugs in ARM64 compiler (clang for iOS). It can be quite challenging, but rewarding when you find the bug Very Happy

-t


Sense Amid Madness, Wit Amidst Folly
Back to top
Frant
King's Bounty



Posts: 24656
Location: Your Mom
PostPosted: Wed, 1st Apr 2015 22:14    Post subject:
I guess no one understood the point due to me not explaining:

I started coding assembler on the C64 and managed to get so far that I could create raster bars, sprite scrolls in the border and other effect. It was a blast. Then I bought my Amiga 500 in September 1987 and I started coding assembler in January/February 1988 after I got in contact with an early intro/demo coder who was very helpful and sent me an assembler (SEKA) and a few example sources. From that I started making my own intros and demos, joining groups etc. and was in the middle of the "scene" at that time. I had contacts all over Europe and some in US (the groups BBSes usually sat in the US).

Nobody coded demos in C, you had to write fast assembler to save and utilize the raster time. Doing something in C took 3+ times as much raster, CPU, blitter etc. time and things wouldn't be smooth (everything including music choppy and utterly incompetent).

In other words I'm writing about specific purpose programming on the Motorola 68K-architecture. I'd never bother with ASM on x86, there's no point. I guess the top demo groups today do some specialty routines in ASM and the rest in C/C++ and know how to make the code extremely efficient but that's an entirely different world.

ps. there are still Amiga demos (and even C64 demos) being made every year, many competing on big demo hacks/gatherings.

This one was made to run @ 50fps on a stock Amiga 500 (512KB, a 7.14MHz MC68000.. There was never any kind of texturing, filtering, hardware chunky pixel conversion etc. so everything was made withing very narrow limits and groups pushed the limits constantly just like they had with the C64.


..and just for kicks, a C64 demo from 2014 by Fairlight, Prosonix and Offence!!!



...and to end we go with a modern advanced demo that requires a CPU accelerator (68060, the last of the 68K-series made) to run properly. Choose 720p50. Still no texturing or filtering hardware, just an updated GFX-chip with more colors but unfortunately limited to 4x signal speed (Commodore was saving on everything) so it's an amazing product with great music that runs on hardware from 1992 with a faster CPU. Very clever programmers and most of it impossible to do in high level languages.



Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!

"The sky was the color of a TV tuned to a dead station" - Neuromancer
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group