I agree that you must really have a good reason to write assembly language, but part of code that need speed or size smashed can be usefully code in asm.
If you try to do most things in assembler you end up with unfinished projects.
Assembly is fast that any compiler of any language could ever produce, and lot closer to machine level, all commands are mapped 1-1 to machine instructions.
Assembly code is smaller that any compiler of any language could ever produce.
Yap most programs are done in C++, but small parts of it can be done in asm, like the matrix calculations, encrypting…
I have done a small program in asm and DBPro to test speed:
The program just makes 3Billion of cycles with basic arithmetic
In asm it take in my computer ( P4 2400 ) 8 seconds, in DBPro it takes 50 seconds, that is about 6 times slow…
I show here the program in asm, with some other extra stuff, just to show some of you how the asm look like:
.MODEL TINY ; both code and data fit in the same 64K segment
.STACK 200h ; space for stack
.DATA ; allows you to create a data segment
day DB 20 ; day=20, variable as byte ( 1 byte )
money DW 2000 ; money=2000, variable as word ( 2 byte )
count1 DW 50000 ; count1=50000, variable as word
count2 DW 60000 ; count2=60000, variable as word
score DD 5000 ; score=5000, variable as double ( 4 bytes )
my_arr DW 50,23,11,3 ; my_arr as word
.CODE ; allows you to create a code segment
START:
MOV AX, [money] ; AX=2000
ADD AX, 5 ; AX=AX+5
SUB AX, 2 ; AX=AX-2
MOV BX, [my_arr+2] ; BX=11
myloop1:
MOV CX, [count2] ; CX = 60000
myloop2:
ADD DX, [money] ; DX=DX+money
ADD DX, 1000 ; DX=DX+1000
ADD DX, 100 ; DX=DX+100
SUB DX, 1050 ; DX=DX-1050
LOOP myloop2 ; CX=CX-1 , if CX<>0 then jump myloop2
SUB [count1], 1 ; count1=count1-1
CMP [count1], 0 ; compare count1 with 0
JNE myloop1 ; jump if not equal
MOV AX, 4C00h ;AX=4C00h (hexa format)
INT 21h ;interrupt 21h, with AH=4C00h, exit program, back to DOS
END START
A program that do the same thing in DBPro, I fist try with goto, and other cycles but it get to slow, so I have done with for/next.
sync on; sync rate 0
For x=1 to 50000
For y=1 to 60000
INC DX,money+1000+100-1050
Next y
Next x
print "END"
do
sync
loop