sjakke
13th February 2009, 20:44
So...in short. I have never programmed before. I want to start by learning assembly language. The language I want to code in is FASM(Flat Assembler).
My question is: Do you have an idea for a small, simple and portable program to use with video conversion?
And possibly provide links for documentation on how to create such a program. If not....I'll just google it:)
And last but not least: Is this a good idea???
Adub
13th February 2009, 21:39
No, I don't think it is a good idea. It is always better to start programming with a higher level language, such as java or c++. It is much easier to understand.
Then you can move on to stuff like C, and from there Verilog/VHDL and Assembly.
The problem with assembly is that it requires a deeper understanding of the actual hardware you are programming for.
Dark Shikari
13th February 2009, 21:48
You don't write an encoder in assembly; you write DSP functions in assembly for that encoder, which is written in C.
LoRd_MuldeR
13th February 2009, 22:16
Well, learning Assembler language is a good thing, as you will understand how the CPU actually works and how all your "high level" code will be compiled and executed. But x86 assembler is a pretty hard thing to start with, as the x86 architecture isn't very straightforward. You'd better start with something more simple, like MIPS assembler, which is a RISC (reduced instruction set) architecture. Also writing anything but extremely simple programs in plain assembler language is pain! Nobody would do that. What people do is: Write the program in some "high level" language and then find the "critical" functions that actually bottleneck the performance. These functions (and only these) are then re-written as hand-optimized assembler code, as no compiler in existence beats a well-written assembler code. Anyway, if you are new to programming, I highly recommend to start with Java. C and C++ are considered "high level" languages, but they are still pretty "low level" and can be used in a way that requires a deep understand of the underlying hardware. Especially pointers, which C makes intensive use of, are not trivial to understand for a newbie. Java abstracts from all that. In fact in Java you don't see the difference between Pointers and "normal" variables. Java simply does a lot of things for you automatically, so you don't even need to worry about them. In C/C++ you'd have to take care of all these things yourself...
(Once you have understood the basics in Java, you can move on to C/C++. And finally you can do assembler, if the need arises)
lpcstr
14th February 2009, 17:14
No, I don't think it is a good idea. It is always better to start programming with a higher level language, such as java or c++. It is much easier to understand.
Then you can move on to stuff like C, and from there Verilog/VHDL and Assembly.
The problem with assembly is that it requires a deeper understanding of the actual hardware you are programming for.
I disagree. My learning progression was from x86 Assembler, to C, to C++. I did learn Basic first technically, but that was when I was much younger.
C isn't necessarily easier to understand than Assembler, it's just that C can take mundane tasks and automate the process. All the the basic knowledge is still required.
Learning Assembler will give you a much more intimate knowledge of how a computer works, and will help you understand exactly what is going on in higher level languages like C.
Here is a basic program I wrote, my first ASM program from quite a while back.
It's a simple Win32 console assembly program written in NASM syntax. It makes a handful of Windows API calls to get some key values from the registry, then it has a small basic math algorithm to take that data and calculate your Windows product key. It then formats a string and outputs it to the console.
.686
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\user32.lib
printf MACRO S1, S2
invoke WriteConsole, DWORD PTR[StdOut], addr S1, lengthof S1 - 1, 0, 0
invoke WriteConsole, DWORD PTR[StdOut], addr S2, lengthof S2 - 1, 0, 0
invoke WriteConsole, DWORD PTR[StdOut], addr Newline, lengthof Newline - 1, 0, 0
ENDM
printl MACRO S1
invoke WriteConsole, DWORD PTR[StdOut], addr S1, lengthof S1 - 1, 0, 0
invoke WriteConsole, DWORD PTR[StdOut], addr Newline, lengthof Newline - 1, 0, 0
ENDM
.data
AppName db "WinKey", 0
string1 db "- WinKey Decoder v1.0.0 by -", 0
string2 db "- For more info visit http:// -", 0
string3 db "Windows Licence Info:", 13, 10, 0
string4 db "Product ID: ", 0
string5 db "Product Key: ", 0
string6 db "------------------------------------------------", 0
Newline db 0, 13, 10, 0
b24chr db "BCDFGHJKMPQRTVWXY2346789",0
HexChr db "0123456789ABCDEF", 0
regKey1 db "ProductId",0
regKey2 db "DigitalProductId", 0
subKey db "SOFTWARE\Microsoft\Windows NT\CurrentVersion", 0
lenPid dd 24
lenDpid dd 164
ErrMessage db "Error: 0x????", 0
.data?
hInstance HINSTANCE ?
StdOut HANDLE ?
StdIn HANDLE ?
openKeyPtr HANDLE ?
int32a dd ?
bytesRead dd ?
inputbuff db 64500 dup(?)
prodKey db 25 dup(?)
prodKeyStr db 30 dup(?)
prodID db 25 dup(?)
dProdID db 164 dup(?)
rawID db 15 dup(?)
.code
start:
call Main
call FreeConsole
invoke ExitProcess, 0
Main:
invoke GetModuleHandle, 0
mov DWORD PTR [hInstance], eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov DWORD PTR [StdOut], eax
invoke GetStdHandle, STD_INPUT_HANDLE
mov DWORD PTR [StdIn], eax
invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE, addr subKey, 0, KEY_READ, addr openKeyPtr
invoke RegQueryValueEx, DWORD PTR [openKeyPtr], addr regKey1, 0, 0, addr prodID, addr lenPid
invoke RegQueryValueEx, DWORD PTR [openKeyPtr], addr regKey2, 0, 0, addr dProdID, addr lenDpid
mov ecx, 15
lea esi, dProdID + 52
lea edi, rawID
rep movsb
mov ecx, 25
l1:
dec ecx
mov DWORD PTR [int32a], 0
mov ebx, 15
l2:
dec ebx
shl DWORD PTR [int32a], 8
movzx edx, BYTE PTR [ebx + rawID]
or DWORD PTR [int32a], edx
mov eax, DWORD PTR [int32a]
xor edx, edx
idiv DWORD PTR [lenPid]
mov DWORD PTR [int32a], edx
mov BYTE PTR [ebx + rawID], al
mov eax, edx
cmp ebx, 0
jnz l2
lea edi, [ecx + prodKey]
lea esi, [eax + b24chr]
movsb
cmp ecx, 0
jnz l1
mov eax, 5
lea edi, prodKeyStr
lea esi, prodKey
mkstr:
dec eax
mov ecx, 5
rep movsb
mov BYTE PTR [edi], 45
inc edi
cmp eax, 0
jnz mkstr
mov edx, FOREGROUND_INTENSITY
or edx, FOREGROUND_GREEN
invoke SetConsoleTextAttribute, DWORD PTR [StdOut], edx
printl string6
printl string1
printl string2
printl string6
printl string3
printf string4, prodID
printf string5, prodKeyStr
invoke ReadConsole, DWORD PTR[StdIn], addr inputbuff, 256, addr bytesRead, 0
ret
end start
I've attached the executable if you want to try it or disassemble it. As you can see, because it was written in ASM with very few lines of code, it's only 3Kb. :D
PS. This will not run correctly on Windows XP 64-bit or Vista 64-bit
LoRd_MuldeR
14th February 2009, 18:33
C isn't necessarily easier to understand than Assembler, it's just that C can take mundane tasks and automate the process. All the the basic knowledge is still required.
That's why I'd recommend to start with Java, because all the details that you don't see in C but still have to know about, are excluded in Java.
It's a simple Win32 console assembly program written in NASM syntax.
And you really think that a complete noob should start with implementing the Windows calling convention in assembler? Really?
I think it's much more important to understand the basic idea of "function calling" and techniques like "recursion" before you learn how to implement that on the lowest level.
The same applies to "loops": Once you have understood the basic idea of loops, you can easily understand how to implement a loop in assembler by using JUMP instructions.
But looking at an existing assembler code without knowing the basic concepts of programming will not only be extremely confusing, but also leads nowhere...
squid_80
14th February 2009, 21:36
Regardless I think it's awesome that someone still knows how to write a whole program from scratch in assembly :cool:
Shinigami-Sama
15th February 2009, 08:53
geez and I was happy just to make a basic calculator in Z80 a couple years ago
MfA
16th February 2009, 14:48
And last but not least: Is this a good idea???
The problem is that all the interfaces are rather complex and the necessary coding is boring enough in higher level languages as is. Writing a win32 console application is one thing ... but all the stuff necessary for say a VFW codec is really more trouble than it's worth.
You could try to create a simple command line compressor for RAW video ... not really useful to anyone else, but can still be fun.
PS. you better have a whole lot of persistence ...
dancho
16th February 2009, 19:09
Try Masm32 (http://www.masm32.com/board/index.php),
I wrote MCbatch (http://forum.doom9.org/showthread.php?t=101246&highlight=mcbatch) in masm32,and as IDE I recommend RadASM ( dl link in forum )...
sjakke
17th February 2009, 21:42
What people do is: Write the program in some "high level" language and then find the "critical" functions that actually bottleneck the performance. These functions (and only these) are then re-written as hand-optimized assembler code, as no compiler in existence beats a well-written assembler code.
I think I'll take this route. Thanks LoRd_Mulder:) A friend of mine has a book on Java and, to my surprise, I found a book on C++ in the library. I guess I'm going to flip through the pages on one of those books.
And a big :thanks: to ALL of you guys! Thanks for helping out a newbie.
And on a side-note. I got a book about the Vim editor a while ago. I never quite got the hang of maneuvering around in it. But now I found a plugin for firefox called "Vimperator". It has helped me an awful lot. Just wanted to mention that, so that "maybe" it could help someone else learn how to use Vim.
And once more... Thanks.
Shinigami-Sama
18th February 2009, 01:51
And on a side-note. I got a book about the Vim editor a while ago. I never quite got the hang of maneuvering around in it. But now I found a plugin for firefox called "Vimperator". It has helped me an awful lot. Just wanted to mention that, so that "maybe" it could help someone else learn how to use Vim.
And once more... Thanks.
I <3 vim
http://www.viemu.com/vi-vim-cheat-sheet.gif
this is all you need
print it out and never let it leave your sight
once you master it
good luck on your project
sjakke
19th February 2009, 21:11
@Shinigami-Sama
Don't know if you script any avs files, but I just saw on http://niiyan.net/?AviSynthNews an Vim syntax file for AviSynth.
Shinigami-Sama
20th February 2009, 07:50
nice...
have to try it out once I get my i7
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.