Author Topic: Trying to learn Assembly  (Read 305 times)

mamoon.xilix

  • Regular Member
  • *
  • Posts: 5
Trying to learn Assembly
« on: August 05, 2017, 01:38:14 PM »
Hello guys, hope u are all having a good day.
My goal is to learn Assembly language programming for 32 bit processor.
 I m making a compiler. I have already created a parser for it. Now i want to convert source language (which is being parsed) into 32 bit assembly language.
Where i am having a problem ?
I dont wanna learn like invoke calls to system libraries, I wanna learn basic Assembly language with movs and ints.
Masm32 has different syntax and other assemblers also have different syntax. I am too confused. Assembler provided by microsoft (ml.exe) always crashes at int 21h.
Please guide me. I know this is a bad written question and i also hope u got the point.
Thank you

felipe

  • Member
  • ***
  • Posts: 282
  • I love assembly language programming.
Re: Trying to learn Assembly
« Reply #1 on: August 05, 2017, 01:59:09 PM »
Welcome to the forum!   :icon14:
int 21h is an old dos "call" to the most typical functions provided by dos, so is not for windows.
Your project seems to be a big thing, but seems like you are trying to learn assembly from scratch, just from now.
So, if you want to do it i guess is good for you.  :bgrin: But you have to be patient, it can't be done like a magic act. Take your time with it. Maybe you want to keep runing other projects at the same time, that's ok, i guess. But be constant and patient and you will get it. As hutch said sometime: "Don't take shortcuts". (or something like that)  :icon_mrgreen:.

I highly recommend you this forum and the masm32 sdk package. And don't be afraid of the high level facilities it provides. They are part of the understanding you will need to learn assembly, oh yeah!  :lol:
Felipe.

mamoon.xilix

  • Regular Member
  • *
  • Posts: 5
Re: Trying to learn Assembly
« Reply #2 on: August 05, 2017, 03:24:16 PM »
Thank you man, for a very nice reply. I was too afraid i might get a roasting as my question too noob.
I am ready to give my time to learning, even if it takes a year. I dont mind.
Can you please guide to a good tutorial site that will guide me through. I checked Icezilon's (Sorry if the name is wrong) tutorials and Lena's reverse engineering. But they are not telling to learn from the start. If u please guide me.
Thank you so much.

jj2007

  • Member
  • *****
  • Posts: 7551
  • Assembler is fun ;-)
    • MasmBasic
Re: Trying to learn Assembly
« Reply #3 on: August 05, 2017, 07:30:07 PM »
I have already created a parser for it.

That sounds very interesting! Can you zip the source and post it here?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Trying to learn Assembly
« Reply #4 on: August 05, 2017, 08:12:09 PM »
mamoon,

Spend the time getting the swing of protected mode Windows programming. Instead of DOS-BIOS interrupts, you have API calls and they are far more powerful that the old DOS real mode architecture. The memory addressing scheme in 16 bit real mode DOS cannot be used as Windows 32 and 64 bit use what is called a flat memory model, DOS use a "segment : offset" memory model that is not compatible with the later architecture.

> I was too afraid i might get a roasting as my question too noob

Don't worry about this, no-one gets roasted in here and if anyone tries it, we boot them out.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

mamoon.xilix

  • Regular Member
  • *
  • Posts: 5
Re: Trying to learn Assembly
« Reply #5 on: August 05, 2017, 11:50:06 PM »
> That sounds very interesting! Can you zip the source and post it here?
Bro, i dont wanna sound mean or something but u dont really wanna see the source code, u will laugh like never before. Too much memory leaks plus some ideas that i wanna keep to myself (for a certain time). Please dont mind.

mamoon.xilix

  • Regular Member
  • *
  • Posts: 5
Re: Trying to learn Assembly
« Reply #6 on: August 05, 2017, 11:56:40 PM »
Thanks @admin for a really nice and great gesture.
One more quick question if you dont mind.
Where can i find a binary for system calls, like for example, print a message on screen require
invoke StdOut,addr message ; supposing message is the variable where the String is stored

Where can i find the binary or code behind StdOut function ?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Trying to learn Assembly
« Reply #7 on: August 06, 2017, 12:07:43 AM »
You will find the entire MASM32 library with full source in the subdirectory "m32lib".
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

mamoon.xilix

  • Regular Member
  • *
  • Posts: 5
Re: Trying to learn Assembly
« Reply #8 on: August 06, 2017, 12:18:07 AM »
Thank you guys, you all are great.

Vortex

  • Member
  • *****
  • Posts: 1704
Re: Trying to learn Assembly
« Reply #9 on: August 06, 2017, 07:01:04 PM »
Hi,

You can also use the C run-time function printf :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\msvcrt.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\msvcrt.lib

.data

string      db 'Hello world!',0

.code

start:

    invoke  crt_printf,ADDR string

    invoke  ExitProcess,0

END start

Mikl__

  • Member
  • ****
  • Posts: 537
Re: Trying to learn Assembly
« Reply #10 on: August 07, 2017, 12:24:15 AM »
Hi, mamoon.xilix!
Assembly language programming for 8/16/32-bits processor remained in the last century. It is necessary to learn the assembler for 64 or 128 bits systems. DOS and programming for int 21h died in the 90s of last century. hutch-- is right 
Quote
you have API calls and they are far more powerful that the old DOS real mode architecture