Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help to convert follwing assembly code to hex file

Status
Not open for further replies.

andyyeap

Newbie level 5
Joined
Jul 27, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,364
hi guys i really need some help to convert following assembly codes to hex file... im having problems while converting those code can any of u guys help me with this problem can help me convert these assembly language to hex file? thanks alot






Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
;   This file is a basic code template for object module code         *
;   generation on the PIC10F222. This file contains the               *
;   basic code building blocks to build upon.                         *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler and linker.                             *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      xxx.asm                                           *
;    Date:                                                            *
;    File Version:                                                    *
;                                                                     *
;    Author:                                                          *
;    Company:                                                         *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: P10F222.INC                                      *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;    GPIO0=TRANSISTOR DRIVE                                                                 *
;    GPIO1=PICIN                                                                 *
;    GPIO3=JUMPER                                                                 *
;    GPIO2=UNUSED                                                                 *
;**********************************************************************
 
        list      p=10F222            ; list directive to define processor
        #include <p10F222.inc>        ; processor specific variable definitions
 
        __CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
 
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
 
 
 
 
;***** VARIABLE DEFINITIONS
TEMP_VAR    UDATA
TEMP1        RES     1             ;DELAY REGISTER1
TEMP2            RES     1                         ;DELAY REGISTER2     
TEMP3            RES     1                         ;DELAY REGISTER3     
TEMP4            RES     1                         ;DELAY REGISTER4 
TEMP5            RES     1                         ;TIMING REGISTER
TEMP6            RES     1                         ;TINING REGISTER
 
 
 
;**********************************************************************
RESET_VECTOR    CODE   0xFF       ; processor reset vector
 
; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.
 
MAIN    CODE    0x000
        movwf   OSCCAL            ; update register with factory cal value
 
 
INITIALIZE
MOVLW B'0010'           ; GPIO1=COMPARATOR IN - GPIO0-RELAY ACTIVATE
TRIS GPIO                       ; INITIALIZE
CLRF ADCON0                     ; ADC DISABLE
CLRF GPIO
MOVLW B'00001000'
OPTION                          ; ENABLE GPIO2 AS A DIGITAL PORT
CLRF GPIO
 
 
 
START:
 
SCAN1:
BTFSS GPIO,1
GOTO SCAN1
ENSURE:
BTFSC GPIO,1
GOTO ENSURE
CALL LOOP1
COUNTDOWN:
MOVLW 0XFF
MOVWF TEMP5
MOVLW 0XFF
MOVWF TEMP6
COUNTDOWN2:
BTFSC GPIO,1
GOTO RELAYACTIVATE
DECFSZ TEMP5
GOTO COUNTDOWN2
MOVLW 0XFF
MOVWF TEMP5
DECFSZ TEMP6
GOTO COUNTDOWN2
GOTO SCAN1
 
RELAYACTIVATE:
BSF GPIO,0
CALL LOOP1
CALL LOOP1
CALL LOOP1
SCAN2:
BTFSS GPIO,1
GOTO SCAN2
ENSURE2:
BTFSC GPIO,1
GOTO ENSURE2
CALL LOOP1
COUNTDOWN3:
MOVLW 0XFF
MOVWF TEMP5
MOVLW 0XFF
MOVWF TEMP6
COUNTDOWN4:
BTFSC GPIO,1
GOTO RELAYDEACTIVATE
DECFSZ TEMP5
GOTO COUNTDOWN4
MOVLW 0XFF
MOVWF TEMP5
DECFSZ TEMP6
GOTO COUNTDOWN4
GOTO SCAN2
 
RELAYDEACTIVATE:
BCF GPIO,0
RESET
 
LOOP1:
MOVLW 0X00 
MOVWF TEMP1
MOVLW 0XF0
MOVWF TEMP2
 
LOOP2:
DECFSZ TEMP1
GOTO LOOP2
DECFSZ TEMP2
GOTO LOOP2
RETURN
 
 
 
; remaining code goes here
 
 
 
 
 
        END                       ; directive 'end of program'

 
Last edited:

Have you downloaded and installed the Microchip MPLAB and MPASM?

Both are available free from Microchip's website. There is also a "Getting Started" tutorial available in PDF format.


BigDog
 

im asking for my fren and yes he have dwonloaded mplab software.. but he is facing problems while convert those assembly language to hex file
 

You haven't explained what doesn't work so I'm guessing the problem is the arrangement of columns in the file. It looks like the first part is copied from Microchip's template but the rest has no indentation.
The fix is simple, make sure labels start at the begiining of the line (1st column) and the code starts anywhere except the beginning of the line. My preference is to use tabs so the columns line up nicely but that's a personal decision. It should then assemble and produce hex code. If it still doesn't work, post the error message so we can see what went wrong.

Brian.
 

Hi,

Here is the corrected source code and .hex file.

One thing to note is that when the Relay is Deactivated the program Resets itself back to the beginning.


RELAYDEACTIVATE:
BCF GPIO,0
RESET

- - - Updated - - -

hey there, im still a newbie in this programming field, i wanted to ask the hex file u sent me is the completed hex file? or just part of it? im sorry if causes any inconvenient to u, but i really need help in this problem lol


Hi,

Yes , its a complete .hex file ready to program into that chip.

Its always much smaller than the .asm file which contains lots of user infromation not needed by the chip.
 

Attachments

  • relay.rar
    1.6 KB · Views: 83
really thanks alot man.. u just saved my life!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top