2 Replies - 268 Views - Last Post: 16 January 2019 - 07:38 PM Rate Topic: -----

#1 hu1234   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-January 19

Grasping the consent of assembly language

Posted 16 January 2019 - 06:30 PM

Hi, so i'm very new to assembly and haven't even started writing any code but i just can get my head around it fully and need help. Hopefully this post will help new comers into the topic. P.S I'm very new so some statements may be wrong.

- So I know there are different forms to the assembly language but not too sure how it works. Does every processor have a different form of assembly that it can understand ?

-I'm currently reading a book and it says this code is targeted at 8088 processors, so if i tried to write this code on my PC (I7-6700) would it not work?

-I struggling to find a assembler to use for my current windows I7 computer. Ive seen some people use the notepad application and console command, and some people use things like visual masm, whats the difference?

- whats the best way to actually start using the language and making functional programs?

Is This A Good Question/Topic? 0
  • +

Replies To: Grasping the consent of assembly language

#2 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2745
  • View blog
  • Posts: 4,405
  • Joined: 21-June 11

Re: Grasping the consent of assembly language

Posted 16 January 2019 - 07:13 PM

View Posthu1234, on 17 January 2019 - 02:30 AM, said:

- So I know there are different forms to the assembly language but not too sure how it works. Does every processor have a different form of assembly that it can understand ?


There are different architectures like x86 (in 16-bit, 32-bit and 64-bit versions) or ARM. All consumer-market CPUs created by Intel or AMD are x86 (the 64-bit variant these days). These are what you generally find in desktop or laptop computers (even Macs since Apple switched to Intel CPUs in the mid 00s). Phones, tablets and other smart devices often run ARM. Processors in the same family speak the same machine code (for the most part - some times newer processors add some additional instructions that older ones didn't have). But different architectures do indeed have their own machine code.

In addition to that there are also different assembly dialects for the same machine code. That is, even if you're writing assembly for the same CPU, the textual assembly code can still look different depending on which assembler you're using. Some of those differences are cosmetic (in some dialects you write the target register of an instruction before the source and in some after it) and some are related to features that don't directly exist in the machine code (e.g. macros).

Quote

I'm currently reading a book and it says this code is targeted at 8088 processors, so if i tried to write this code on my PC (I7-6700) would it not work?


The 8086 and 8088 processors were the first processors of the (16-bit) x86 architecture (in fact the former is why it's called x86). The I7 uses the 64-bit variant of the x86 architecture. So in a sense, your CPU would be able to run assembly programs written for the 8088 - but probably not in any sense that's useful to you.

Specifically the problem is that machine code isn't just CPU-dependent, but also OS dependent: different operating systems have different interrupt handlers, memory-mapped locations and library functions. So while the actual instructions that you have are the same, you still need to write different code on different OSs (or when not running an OS at all). Now if your book is targeting the 8088, you will most likely write code for DOS or bare metal code that's meant to be booted directly (i.e. without going through an OS at all).

In the former case, your problem would be that 64-bit versions of Windows no longer offer the ability to run 16-bit code, so you wouldn't be able to run the applications under Windows. You could install FreeDOS on your system and that would very likely actually work (perhaps even MS DOS would work if you can find a copy), but it'd be much less trouble to just use an emulator instead.

In the case of bare metal code, it will probably work fine if you put it on some bootable medium and then restart the computer, but again it would be easier to use an emulator, so you don't need to restart.

Quote

-I struggling to find a assembler to use for my current windows I7 computer. Ive seen some people use the notepad application and console command, and some people use things like visual masm, whats the difference?


As I mentioned above, different assemblers speak different assembly dialects, so you should use whichever assembler your book uses. Otherwise the assembler won't understand the book's code. In general masm is a perfectly fine assembler for x86 assembly.

There really isn't much difference between writing the code in notepad (or some better editor) and then using masm (or whichever assembler you choose) on the command line versus using something like visual masm. The latter simply allows you to run masm via a button click instead of the command line. It's just a matter of preference.

This post has been edited by sepp2k: 16 January 2019 - 07:14 PM

Was This Post Helpful? 0
  • +
  • -

#3 hu1234   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-January 19

Re: Grasping the consent of assembly language

Posted 16 January 2019 - 07:38 PM

Wow thank you so much for the fast reply and in depth answers, really helped me understand things better.

Again Thank You!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1