Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Learning Assembly Step by Step.

Status
Not open for further replies.

Ayne

New Member
I am the user of MikroBasic and not use Assembly too much, but i am familair with Assembly and have made a little program Blinking LED in it.

There will be many members who want's to learn Assembly, May this thread help those.

In this thread i want to ask Senoir membors that share the Best way of doing Such a thing

Code:
program Learn_Assembly

Dim i as Byte
Dim j as Byte
Dim z as Byte


main:

'******* If Statement(bolean functions with Constants) *********
 If i = 100 Then
    z =  40
 End if
'---------------

 If i > 100 Then
    z =  40
 End if
'-----------------

 If i < 100 Then
    z =  40
 End if
'-----------------



'******* If Statement (bolean functions with Variables) *********
 If i = j Then
    z =  40
 End if
'---------------

 If i > j Then
    z =  40
 End if
'-----------------

 If i < j Then
    z =  40
 End if
'-----------------




'******* Select case Statement *********
  select case i
    case 1
    z = 40
  
    case 2
    z = 50
  
    case else
    z = 100
  end select
  




'******* For Statement *********
  for i = 0 to 99
    z = i + 1
  next i




  

'******* While Statement (bolean functions with Constants) *********
  while i < 99
  z = i + 2
  i = i + 1
  wend


'******* While Statement (bolean functions with Variables) *********
  while i < j
  z = i + 2
  i = i + 1
  wend
  

  
  
  
'******* Do Statement (bolean functions with Constant) *********
  do
  z = i + 2
  i = i + 1
  loop until i = 99
  
  
  
'******* Do Statement (bolean functions with Variables) *********
  do
  z = i + 2
  i = i + 1
  loop until i = j
  
  
  
End.

I request to Senoir Membors that guide us, How we do such a task in Assembly.
Convert the above code in assembly and explain it.
And i think it should be include in Nigels Tutorial Website.

Muhammad Ahmed Attari
Thanks.
 
Last edited:
hi ayne,
For users of the Oshonsoft PIC Simulator, paste the basic text into the basic compiler and compile it.

Oshonsoft is designed to produce a commented listing of the Assembly coding as well as the usual *.lst, *.hex.

I would recommend anyone who has been weaned on Basic and wants to study Assembler, to download the demo version of Oshonsoft and give a try.

I am sure many other Basic compilers also produce an assembly listing.

EDIT: as an example, conversion of ayne's code, edited part of the basic code. Uploaded as text files.
 
Last edited:
Wow, I never knew you could get an assembly listing from a compiler. I'll have to look and see if the us the case with my AVR software. I went right to Assembler, which I was more familiar with, rather than learn 'C' or what they call BASIC these days.

A good way to teach yourself Assembly is to look at programs written by others. You need a map of the registers and bit names, and a list of the instruction set. Go through the program line by line, and make a note of what and why each instruction is used. It really helps you to see how the information in the device data sheet is actual put to use.
 
hi harvey,
I dont normally use AVR devices, but just out of interest, downloaded the Oshonsoft AVR Simulator,
compiled the demo.bas and got a demo.asm with comments.

The demo IIRC is a 30day trial lite version.
 
Mikrobasic makes a .lst file as well. I used to use it to debug in MPLABS.

For the AVR, try RVKBASIC at bastoc.com it will generate the ASM as well.
 
3v0 said:
Any good cross compiler will provide an assembly listing.
It's the only bloddy way a compiler writer can tell if his implementation is correct. Writing a compiler and not doing this would be like tying one hand behind your back when it comes to debugging. I'd bet large sums that every commercial product has this feature somewhere within it's bowels.
 
3v0 said:
This is true but I doubt a cross language product make it in the marketplace if they did not pass that ability on to the user. It is expected and required.
Aye..Captain...
 
AVR Oshonsoft simulator

Hi ....
I hav got the .hex file from the AVR simulatr...
I hav loaded that .hex to oshonsoft simulatr...
Now Question z that ....I m unbale to get the LCD output display......
I want to kno ...wat z the need of setting the port in it .......
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top