flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Examples and Tutorials > BASELIB: General purpose libs for beginners

Goto page Previous  1, 2, 3, 4, 5, 6  Next
Author
Thread Post new topic Reply to topic
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
I realized that some users might try to turn these routines into objects so that they can be accessed as static library (.obj, .o). So I transferred all local data declared via data directives (db, dq, dw etc) back to stack. Safer this way but probably less convenient for beginners since I don't put enough documentation for the stack partitioning.

This latest update is compiled with FASM 1.71.40 without any problem (October 21st, 2015).

My next plan is to complete the internal documentations and line comments to make it even more readable and useful. But it's not going to be completed any time soon (probably will never be completed anyway). Time is against me when year end is approaching. But up to this point, I am throwing everything in.

Enjoy it.
Post 20 Oct 2015, 23:59
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
I added "memview" and "encoder" as two core routines.

1) memview - display memory content from a defined label
2) encoder - display encoding for instructions between two labels

These latest additions should help beginners to understand more about memory (usage, addresses) and how their instructions are encoded (instruction size, placement and encoding).

I intend to turn these library to DLL and SO form instead so that it can run cross assemblers / compilers and can promote better information hiding. But I am having second thoughts about it because it will no longer be open source.

On the other hand, exposing codes that should be hidden may not be appropriate in formal education environment. I don't know. Only time will tell. But for sure I am not releasing both the source and binary format.

See you all again next year. Year-end auditing work is stacking up mountain high. LOL
Post 28 Oct 2015, 16:25
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
Debuggers are not counter productive. The word even describes what they do. They help you identify bugs. If you debug your code thoroughly you won't have to go back and forth trying to figure out why nothing is working.
Post 07 Nov 2015, 17:35
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396

typedef wrote:
Debuggers are not counter productive. The word even describes what they do. They help you identify bugs. If you debug your code thoroughly you won't have to go back and forth trying to figure out why nothing is working.



That's what's this library is all about. Beginners can code & debug at the same time so that they don't waste their time going back and forth the debugger. That is to say they can prevent bug from occurring in the first place.

I don't know about you but I'm not relying on C/C++ programmers to write a debugger so that I can check what's wrong with my low-level assembly code. See the irony here? Assembly programmer will have to rely on C programmers / programs to see what's going down with their own assembly code???? LOL
Post 08 Nov 2015, 07:28
View user's profile Send private message Visit poster's website Reply with quote
randall



Joined: 03 Dec 2011
Posts: 149
Location: Poland

fasmnewbie wrote:

I don't know about you but I'm not relying on C/C++ programmers to write a debugger so that I can check what's wrong with my low-level assembly code. See the irony here? Assembly programmer will have to rely on C programmers / programs to see what's going down with their own assembly code???? LOL



But you are relying on a Linux kernel which is written by C programmers Smile

_________________
https://github.com/michal-z
Post 10 Nov 2015, 11:34
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
randall I am referring to people's obsession with debugger, not with kernel. Even FASM rely in some way on windows library/headers to make it work on Windows. You are missing the point. Besides, syscall is the lowest I can go for this little 'app' without breaking anything on the user's side or on my side. Btw, I do have the 16-bit version of this library using the BIOS interrupt services. No C.

I have nothing against debuggers or C programs. My only issue is that assembly programmers are pushing the idea of 'must-have debugger or you die'. That really is burdensome to assembly beginners when in reality the use of debugger can be completely avoided by using library like this, by assembly programmers, for assembly beginners. More time can be saved because beginners can code and debug at the same time.

But I have to admit that debugger is inevitable when it comes to advance things like windows programming. But this library involves no such headers. Just simple command-line assembly library.

A debugger may be easy for an individual PCs/users, but for large multi-platform learning institutions with hundreds of non-standard PCs, a debugger will be too luxurious to implement. So the safest, easiest and cheapest alternative is a library like this one Very Happy
Post 10 Nov 2015, 13:14
View user's profile Send private message Visit poster's website Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 781
Location: Jakarta, Indonesia

fasmnewbie wrote:

But I have to admit that debugger is inevitable when it comes to advance things like windows programming. But this library involves no such headers. Just simple command-line assembly library.



In reality, sometimes programmers are just lazy to fire up the debugger, and use the good old 'printf' instead Smile
Post 10 Nov 2015, 16:23
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14790
Location: Lost in translation
People will do what they find the most comfortable at the time. Sometimes I use a debugger, sometimes I just print out debugging information. I do whatever is easiest and most prudent to fixing the problem.

I don't agree that printf is always better than debugger, or that a debugger is always better than printf. Each has its place. And learning to recognise when to use each one is a very important skill.
Post 10 Nov 2015, 17:11
View user's profile Send private message Visit poster's website Reply with quote
codestar



Joined: 25 Dec 2014
Posts: 254
fasmnewbie: Good work!

I use both s/printf and debuggers - homemade disassemblers, FASM "display" and PE Browse Pro for .EXEs - whatever is the fastest, easiest and/or most convenient.

After you finish a LL library in ASM, you may decide later to create a separate higher level DLL in C or FASM macros that encapsulates all of this with Windows UI and controls. Iczelion's Windows ASM Tutorials (MASM is easy to translate).
Post 10 Nov 2015, 20:12
View user's profile Send private message Reply with quote
rbprsp



Joined: 14 Nov 2014
Posts: 6
fasmnewbie: Really good work & my favorite thread on this board atm. Thanks for your effort!

revolution: I doing the same things for debugging + sometimes using disassembler "IDA Pro" - fastest way & fresh look to my code.
Post 11 Nov 2015, 06:42
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
I changed the source to a new name CORE64, reflecting my intention to turn these library into SO and DLL soon.

I altered "memview" so that the Address column is placed on the right. The content is now read from left-to-right. Left=MSB and Right=LSB. For example, an attempt to probe the memory dump backward to read the ELF64 header;


Code:
mov rax,$   ;start reading from current location
mov rbx,-78h    ;read backward up to base address
call memview



producing this output, which in some way reflecting the same idea as Linux readelf


Code:
MSB                  LSB          Address                
00 00 00 00 00 00 10 00 |0000000000400070
00 00 00 00 00 00 32 C5 |0000000000400068
00 00 00 00 00 00 32 C5 |0000000000400060
00 00 00 00 00 40 00 78 |0000000000400058
00 00 00 00 00 40 00 78 |0000000000400050
00 00 00 00 00 00 00 78 |0000000000400048
00 00 00 07 00 00 00 01 |0000000000400040
00 00 00 00 00 40 00 01 |0000000000400038
00 38 00 40 00 00 00 00 |0000000000400030
00 00 00 00 00 00 00 00 |0000000000400028
00 00 00 00 00 00 00 40 |0000000000400020
00 00 00 00 00 40 00 78 |0000000000400018
00 00 00 01 00 3E 00 02 |0000000000400010
00 00 00 00 00 00 00 00 |0000000000400008
03 01 01 02 46 4C 45 7F |0000000000400000  ;ELF64 ... executable 3



I am not sure if this new arrangement will be the best, but I am more comfortable reading the content from left-to-right, from MSB to LSB. The address represents the offset of the byte nearest to it. For example address 0x400058 contains 78h, 0x400059 contains 0, 0x40005a contains 40h and so on.
Post 13 Nov 2015, 01:53
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
As for "encoder" routine, I am not very sure how to properly implement it as I don't have good knowledge on encoding, plus there's no way we can be fully sure of what those opcodes really represent. For example 48h is either DEC or it could be a REX prefix. DON'T ASK ME. I DON'T KNOW. I just print them out for you xD
Post 13 Nov 2015, 02:07
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396

TmX wrote:
In reality, sometimes programmers are just lazy to fire up the debugger, and use the good old 'printf' instead Smile



they are both C. yucks! xD
Post 13 Nov 2015, 02:10
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14790
Location: Lost in translation

fasmnewbie wrote:
... there's no way we can be fully sure of what those opcodes really represent. For example 48h is either DEC or it could be a REX prefix. DON'T ASK ME. I DON'T KNOW.

In 64-bit mode it is always a REX prefix. In 32-bit (and 16-bit, but who uses that?) mode it is always DEC.
Post 13 Nov 2015, 02:12
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396

codestar wrote:
fasmnewbie: Good work!

I use both s/printf and debuggers - homemade disassemblers, FASM "display" and PE Browse Pro for .EXEs - whatever is the fastest, easiest and/or most convenient.

After you finish a LL library in ASM, you may decide later to create a separate higher level DLL in C or FASM macros that encapsulates all of this with Windows UI and controls. Iczelion's Windows ASM Tutorials (MASM is easy to translate).



I don't know how many years to go so I can finally catch up with you. By looking or should I say 'staring' at your codes, I probably never will. You are way too advance my friend.
Post 13 Nov 2015, 02:14
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396

revolution wrote:
In 64-bit mode it is always a REX prefix. In 32-bit (and 16-bit, but who uses that?) mode it is always DEC.

So a REX is basically a DEC too?
Post 13 Nov 2015, 02:17
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396

rbprsp wrote:
fasmnewbie: Really good work & my favorite thread on this board atm. Thanks for your effort!



Well, if you are a fan, then you must be a beginner too! Advanced players don't use this my friend xD
Post 13 Nov 2015, 02:28
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14790
Location: Lost in translation
No, REX by itself does nothing other than to modify the following instruction for 64-bitness. In 64-bit mode only the two-byte DEC instruction is available.
Post 13 Nov 2015, 02:31
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
@revo

ok.
Post 13 Nov 2015, 02:31
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 396
Added a very basic 16-bit version. Missing many routines but should be enough for learning purposes in 16-bit environment. All-BIOS interrupts. Flat COM format (org).

Under emulators like DosBox, some floating point routines may not work properly.

Happy holiday and good luck.
Post 07 Dec 2015, 09:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6  Next

< Last Thread | Next Thread >

Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.