flat assembler
Message board for the users of flat assembler.

Index > Windows > Hi,I'm New To The FASM Assembler.Need Some Help.

Author
Thread Post new topic Reply to topic
tinman47



Joined: 02 May 2007
Posts: 1
tinman47
Hi,I'm new to the forum and the FASM Assembler and I have been a long time programmer.I started learning about the FASM Assembler a few weaks ago,and I am very confused. EmbarassedI read the manual like 7 times. I really want to learn about Assembly because it allows me to tell my computer to do whatever I want it to do,and I am designing my own Interpreter,so I need answers to the following questions:

1.What are registers and what are they supposed to do?I keep seeing ax,bx,eax.I'm scared that these are Registry Files.

2.I understand how the commands and bytes work,but how do I put it all together?

3.When I write the code,it works...But it doesn't show,how do I display results graphically?Like I type the code like mov ax,bx,which I means to move the bx register to the ax,so can I put like a window that displays the results?
Post 02 May 2007, 02:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
You might like to try using a debugger (like ollydbg, google it) to help you see what happens as each instruction is executed. Start with some of the examples given in the Win32 package and follow through them one instruction at a time with the debugger.
Post 02 May 2007, 06:38
View user's profile Send private message Visit poster's website Reply with quote
thanatosor



Joined: 07 Jun 2007
Posts: 1
thanatosor
you should read the tutorial at www.flatassembler.net for the basic info and instruction set.
about the "mov ax,bx",i can explain a little(because i 've just start 1 day):
ax,bx,cx,dx .... are called registers(not registry) they have their work....
ax=main register,
bx=base register,
cx=code register,
dx=data register,
and that all are 16 bit register,each have 2 register:h & l, ex:

ax have ah,al ,bx, have bh,bl...etc...
if you want to see result, u should use :
------------------------
org 100h
mov ax,9
mov dx,bx
int 21h
mov ax,4C00h
int 20h
------------------------
that code will print to screen the value of bx register.......for more info, go tutorial at that link...
Post 07 Jun 2007, 16:00
View user's profile Send private message Yahoo Messenger Reply with quote
resoftw



Joined: 26 Dec 2005
Posts: 12
Location: .id
resoftw
thanatosor wrote:

ax=main register,
bx=base register,
cx=code register,
dx=data register,


AX = Accumulator Register
BX = Base Register
CX = Counter Register
DX = Data Register
ESI = Source Index
EDI = Destination Index
EBP = Base Pointer
ESP = Stack Pointer

Smile

_________________
Image Loading my signature, please wait...
^_^
Post 09 Aug 2007, 13:22
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 9130
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
basically, the processor provided u with limited count of variable, they are named as ax,bx,cx and bla bla bla

each of them at good at particular purpose, eg. cx = for counter loop increase. eax, ebx, ecx, edx = 32 bits version of those processor variables.

if u do some javascript or php before or even visual basic, u would know eg. function, sub or etc (sort of grouped code that to be executed from time to time).

in assembly, they are in the form of INT (interrupt) (they are just the same thing, just in different format).
if in visual basic

Function Int21 ( param1 as double, param2 as double)
End Function

in assembly,
it would be like
mov ax, param1
mov bx, param2
int 21h

see ... Smile, they are just the same except only they are wrapped using different packages.

good luck on ur adventure into assembly world !! Smile and welcome to this awesome fasm board Smile
Post 09 Aug 2007, 14:27
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
1. Registers have nothing to do whatsoever with the registry, the former being tiny storage space in your CPU used for fast data processing, the latter being a database containing general software and system settings.

2. look at '\your_fasm_directory\EXAMPLES\' for different program structures.

3.
Code:
include '%fasminc%\win32ax.inc'

.data
; %u means unsigned integer
szStr          db '%u',0

; reserve 100 bytes for output string
szOutputBuffer db 100 dup (?)

.code
start:
; ebx<-2007
       mov ebx,2007

; eax<-ebx
       mov eax,ebx

; format character string with 'wsprintf'
       invoke wsprintf,szOutputBuffer,szStr,eax

; show message box
       invoke MessageBox,0,szOutputBuffer,'Caption',MB_OK

; terminate program
       invoke ExitProcess,0
.end start
    


Hope this helps.
Post 09 Aug 2007, 15:13
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Quote:

Code:
org 100h
mov ax,9
mov dx,bx
int 21h
mov ax,4C00h
int 20h
    

that code will print to screen the value of bx register


NO Crying or Very sad

1. This is DOS code
2. It will print garbage at best, not "value" of BX or DX

Code:
format binary as "COM"
use16
org $100

        mov al,$7D    ; Our value
        mov ah,al
   and ah,$0F    ; & Low 4 bits // reversed : LITTLE ENDIAN
    shr al,4      ; & High 4 bits
   add  ax,$3030 ; Convert 0 -> ASCII "0"
 cmp al,$3A
  jb @f          ; "b":below // OK, a number
    add   al, 7
@@:  cmp   ah, $3A
       jb @f          ; "b":below // OK, a number
    add   ah, 7
@@:     mov [bufjunk+2],ax
        mov ah,9
        mov dx,bufjunk
        int $21
        mov ax,$4C00
        int $21             ; Exit to DOS
;--------------
bufjunk: db $0D,$0A,0,0,$0D,$0A,$24
    


This will Idea print value of AL in HEX Shocked

P.S. : move to MAIN please

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 09 Aug 2007, 16:11
View user's profile Send private message Reply with quote
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla
To give you an idea of some of the registers (yes they are confusing):

The 8-bit registers are simply derivatives of the 16-bit registers. This allows you to access the two bytes of word registers separator. The low-byte ends in "L", and the high byte ends in "H". For example:
Code:
AL - Low Byte of the AX register
AH - High byte of the AX register    


The 16-bit registers (8086+) are:
Code:
AX - Accumulator Register (Often used for mathematical operations, and is used in instructions like MUL (multiplication).
BX - Base Register (Often used to store address location pointers)
CX - Count Register (Often used as a counter)
DX - Data Register (Self explanatory, and is used to store anything)    


The 32-bit registers (80386+) are:
Code:
EAX - Extended AX
EBX - Extended BX
ECX - Extended CX
EDX - Extended DX    


The 64-bit registers (x86-64) are:
Code:
RAX
RBX
RCX
RDX
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15    

Don't quite remember what the "R" at the beginning stands for though.

And that's not all of the registers! In fact, there are many more you may not encounter, such as the 128-bit multimedia use registers, and the like!
Post 19 Aug 2007, 06:17
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Hi tinman47, welcome aboard!,
It's very tough to find a decent modern assembly tutorial, or book for that matter, most are old 16-bit DOS assembly. I assume you want to do windows programming? I would start by learning the 32-bit registers (EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP) and what there purpose are, "ESP" and "EBP" I wouldn't use or worry about for now. Then learn how to define your ".data", ".code", and dll imports section's. Your best material right now IS the fasmw manual, the fasmw examples folder, and the intel reference manuals. Learn how to define the "%fasminc%" variable to compile the examples. I'd use the intel manuals for a reference to the instruction set to find out what they do. If I find anything else usefull on the internet, I'll pass it along. Maybe I should post the intel manual links so you can download them and use them while your learning. Do you have them already?
Post 19 Aug 2007, 10:16
View user's profile Send private message Reply with quote
Adam Kachwalla



Joined: 01 Apr 2006
Posts: 150
Adam Kachwalla
And as an addition of what madmatt said, many tutorials are written in MASM or TASM or something else other than FASM, making it even harder to follow.
Post 19 Aug 2007, 21:04
View user's profile Send private message Reply with quote
MichaelH



Joined: 03 May 2005
Posts: 402
MichaelH
tinman47, I think the funniest was "What are registers and what are they supposed to do?I keep seeing ax,bx,eax.I'm scared that these are Registry Files." Smile

Quite a funny thread IMHO Smile
Post 20 Aug 2007, 21:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.