News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

conversion of C code into assembly language

Started by sonal, December 01, 2008, 09:47:41 AM

Previous topic - Next topic

sonal

hello everyone out there!!!!!!!!!
I am a new member n also new in this field. Could u plzz helpme or suggest any tool or software that converts a C code into Assembly
language.
the code is as follows ::
' Connect the timer0 input P3.4 to a frequency generator
' freq meter
' 24 mhz xtal ok upto 300khz
' define crystal speed and include file
$regfile = "89C2051.dat"
$crystal = 24000000
' define variables used
Dim A As Byte
Dim C As Long , D As Long
Dim Count As Word
Dim Onceasec As Bit
Dim T0ic As Long
Dim Green As Byte
Dim Delayword As Word
' Initialize variables
Onceasec = 0
Count = 0
T0ic = 0
D = 0
Green = 0
' initialize ports
P1 = 0
P3 = 1023
' configure lcd display
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6
= P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2
Cls
'clear the LCD display
Lcd "Frequency Meter"
' define timer0
Config Timer0 = Counter , Gate = Internal , Mode =
1
'Timer0 = counter : timer0 operates as a counter
'Gate = Internal : no external gate control
' exte/internal makes no difference
'Mode = 1 : 16-bit counter
' set t0 internal interrupt
On Timer0 Timer_0_overflow_int
' interrupt will be generated on every 65536 count
Priority Set Timer0
Enable Interrupts
Enable Timer0
Counter0 = 0
'clear counter
Start Counter0
'enable the counter to count
Do
'set up a 1 sec accurate DO NOTHING loop
Enable Interrupts
'wait 1 as per BASCOM-51 is not accurate
For Delayword = 1 To 4544
Next Delayword
Disable Interrupts
C = Counter0
'get counter value
D = T0ic * 65536
Lowerline
C = C + D
T0ic = 0
Lcd " "
Lowerline
' show the frequency
Lcd "f=" ; C ; " Hz"
Waitms 255
Waitms 255
C = 0
Counter0 = 0
Start Counter0
're-start it because it was stopped by accessing the
COUNTER Loop
' timer0 int subroutine
Timer_0_overflow_int:
Rem timer0 overflow ( 65535 ) interrupt comes here
' increment the variable
Incr T0ic
Return
End
' end of program




plzz do reply sooon

rags

Why don't you just compile it with your C compiler, and then have look at the results in OlyDbg?
God made Man, but the monkey applied the glue -DEVO

jorgon

The point being that OlyDbg, like GoBug and also the Microsoft debugger Windbg (and lots of other tools) give a disassembly of the exe file.  The disassembly is in assembler.  This can sometimes help you to learn assembler, although the disassembled code tends to be very complex and contain a lot of unnecessary instructions.  You need to check though, whether the source code you have posted is in fact in "C" or in some other programming language.

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

Shantanu Gadgil

Quote from: sonal on December 01, 2008, 09:47:41 AM
Dim A As Byte
Dim C As Long , D As Long......


Which variant of C uses Dim ?
Looks more like BASIC to me.

-
Shantanu
To ret is human, to jmp divine!

rags

your right Shantanu, it does look like a form of BASIC. I was half asleep yet when I wrote the previous post.

God made Man, but the monkey applied the glue -DEVO

Jimg