Page 1 of 1

Learning ASM

Posted: Wed Apr 17, 2024 5:35 pm
by CrazyTeeka
I'm on a mission to learn ASM. It's going to be difficult at the beginning but in a few years I guess I can master it.

Re: Learning ASM

Posted: Wed Apr 17, 2024 5:48 pm
by lcoughey
I haven't written Assembly code since the mid 90's. Can't say that I miss it, though it was the one course that landed me an A+ in computer science.

Re: Learning ASM

Posted: Wed Apr 17, 2024 6:38 pm
by fzabkar
I think that a knowledge of ASM would be useful in data recovery.

In my case, I learned Motorola 6800 assembler at university. For my second data recovery case in the 1980s, I wrote a tiny routine in Data General machine code to scan a Control Data HDD for directory sectors. These days some of my FreeBasic programs incorporate ASM routines to improve computation speed.

That said, I'm an ASM novice.

BTW, are you wanting to reverse engineer SpinRite? ;-)

Re: Learning ASM

Posted: Wed Apr 17, 2024 6:55 pm
by CrazyTeeka
I want to write something better. :D
Starting from beginner level might take a while.

Can I learn ASM faster than Steve can finish SR v7?
Hopefully.

Re: Learning ASM

Posted: Wed Apr 17, 2024 8:33 pm
by CrazyTeeka
Simple "Hello World!" program that works under FreeDOS...

Code: Select all

org 0x100	; Code starts at offset 100h
use16		; Use 16-bit code

mov ax,0900h	; DOS function: AX = 0900h (Show Message)
mov dx,hello	; DX = "Hello World!$"
int 21h		; Call a DOS function: AX = 0900h (Show Message)

mov ax,4c00h	; DOS function: AX = 4c00h (Exit)
int 21h		; Call a DOS function: AX = 4c00h (Exit)

hello db "Hello World!$"
Compiling Code...

Code: Select all

nasm hello.asm -o hello.com

Re: Learning ASM

Posted: Sat Apr 20, 2024 11:57 am
by Joep
CrazyTeeka wrote: Wed Apr 17, 2024 6:55 pm I want to write something better. :D
Starting from beginner level might take a while.

Can I learn ASM faster than Steve can finish SR v7?
Hopefully.
I'd say you don't have to learn any assembly for that. In essence all he does is read data and then write it back. All the rest is mumbo.

"But Steve writes in assembly!" ..

Ask yourself how much sense there is in wring assembly code if 95% of the code inside even a low level data recovery tool has nothing to do with low level hardware access but mundane stuff like writing files, sorting stuff, comparing stuff, showing stuff on screen etc.., so things that can be done 10 times easier using a different language. If there's anything the last few year 6.1 update cycle has shown it is that writing in assembly is a mess.

Like Franc it has been ages for me that I wrote assembly, for me it was code I used with PowerBasic and it was purely for interacting with drives. It was probably no more than 2% of the total code. Why would I bother with writing a logfile using assembly if PowerBasic gives me a simple means to create files, write to them, etc..

Re: Learning ASM

Posted: Sat Apr 20, 2024 6:48 pm
by fzabkar
I'm hardly the person to be giving programming advice, but here is a simple FreeBASIC program that incorporates an ASM subroutine that does all the computational work.

https://web.archive.org/web/20230522152 ... rdrev3.bas

Re: Learning ASM

Posted: Tue Apr 23, 2024 11:19 am
by CrazyTeeka
So far I'm finding it easy to write code in ASM for Linux, but a bit messy writing coding in ASM for DOS. :roll:

Re: Learning ASM

Posted: Mon May 06, 2024 12:46 pm
by CrazyTeeka
MASM32 seems to provide some nice code samples to play with...

Code: Select all

.486
.model flat,stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\macros\macros.asm

include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.code

start:
	print chr$("SpinRust v1.0",13,10)
	print chr$("SpinRust v2.0",13,10)
	print chr$("SpinRust v3.0",13,10)
	print chr$("SpinRust v4.0",13,10)
	print chr$("SpinRust v5.0",13,10)
	print chr$("SpinRust v6.0",13,10)
	print chr$("SpinRust v6.1",13,10)
	print chr$("SpinRust v7.0",13,10)
	exit
end start