What Software Use For This Coding?

Discussion in 'Programmer's Corner' started by Muhamad, Apr 15, 2015.

  1. Muhamad

    Thread Starter New Member

    Mar 31, 2015
    14
    0
    I want to ask, what software used for this coding? I found it and want to do it for my project.
    This coding use At89C51.
    This is the coding.

    Code (Text):
    1.  
    2. equ com,0fch  ;defining com and giving initial value 0fcH
    3.  
    4. equ dat,0fdh  ;defining dat and giving initial value 0fdH
    5.  
    6. equ eot,0feh  ;defining eot and giving initial value 0feH
    7.  
    8. equ frqflg,0fh  ;defining frqflg and giving initial value 0fH
    9.  
    10. org 0000h
    11.  
    12. mov sp,#30h  ;moving 30H to stack pointer
    13.  
    14. sjmp over  ;simple jump to over
    15.  
    16. org 001bh
    17.  
    18. setb psw.3  ;set bit psw.3,register bank selector 0
    19.  
    20. inc r0  ;increment r0
    21.  
    22. cjne r0,#00h  ;checktime
    23.  
    24. ;compare r0 and 00H and jump to checktime if  not equal
    25.  
    26. inc r1    ;increment r1
    27.  
    28. cjne r1,#00h  ;checktime
    29.  
    30. ;compare r0 and 00H and jump to checktime if  not equal
    31.  
    32. inc r2  ;increment r2
    33.  
    34. checktime:  ;defining checktime
    35.  
    36. cjne r2,#11h,goback  ; repeatit 11h times
    37.  
    38. cjne r1,#27h,goback  ;repet it 27h times
    39.  
    40. cjne r0,#0c0h,goback  ;repeat it c0h times
    41.  
    42. clr tr0  ;clear tr0,timer 0 run control bit (OFF)
    43.  
    44. clr tr1  ;clear tr1,timer 1 run control bit (OFF)
    45.  
    46. setb frqflg  ;setbit frqflg
    47.  
    48. goback:  ;defining goback
    49.  
    50. clr psw.3  ;clear psw.3
    51.  
    52. reti  ;return interupt
    53.  
    54. over:
    55.  
    56. mov p1,#00h
    57.  
    58. mov dptr,#msg1  ;move msg1 to data pointer
    59.  
    60. lcall message   ;long call message
    61.  
    62. mov r0,#00h  ;move 00H to r0
    63.  
    64. over1:  ;defining over1
    65.  
    66. mov r1,#00h  ;move 00H to r1
    67.  
    68. mov r2,#00h  ;move 00H to r2
    69.  
    70.   mov r3,#00h  ;move 00H to r3
    71.  
    72.   mov r4,#00h
    73.  
    74.   mov r5,#00h
    75.  
    76.   mov r6,#00h
    77.  
    78.   mov r7,#00h
    79.  
    80.   mov tcon,#00h  ;move 00H to TCON (clear TCON)
    81.  
    82.   setb psw.3
    83.  
    84.   mov r0,#00h  ;move 00H to r0
    85.  
    86.   mov r1,#00h  ;move 00H to r1
    87.  
    88.   mov r2,#00h  ;move 00H to r2
    89.  
    90.   clr psw.3  ;clear psw.3
    91.  
    92. mov tmod,#25h  ;timer 0 16 bit counter, timer 1 mode 2 auto reload timer
    93.  
    94.   mov tl1,#4eh  ;tl1=4eh,the low byte
    95.  
    96.   mov th1,#0ceh  ;th1=ceh, the high byte
    97.  
    98.   mov tl0,#00h  ;move 00H to tl1
    99.  
    100.   mov th0,#00h  ;move 00H to th1
    101.  
    102.   clr frqflg  ;clear frqflg
    103.  
    104.   mov tcon,#50h  ;tr1 and tr0 are set to start timer1
    105.  
    106.    and timer0
    107.  
    108. mov ie,#88h  ;move 88H to IE, enabling the interrupts
    109.  
    110. simulate:
    111.  
    112.   jbc frqflg,getfrq  ;stay until bit is set
    113.  
    114.   sjmp simulate  ;repeat for reloadin counters
    115.  
    116. getfrq:
    117.  
    118. mov ie,#00h  ;move 00H to IE,disabling all interrupts
    119.  
    120.   mov r1,tl0  ;move value in tl0 to r1
    121.  
    122.   mov a,r1  ;move value in r1 to accumulator,a
    123.  
    124.   mov b,#0ah  ;move 0aH to b
    125.  
    126. div ab  ;div a by 10 and store quotient in a and reminder in b
    127.  
    128.   mov r4,b  ;move the least significan bit t to r4
    129.  
    130.   mov b,#0ah  ;move 0aH to b
    131.  
    132. div ab  ;divide a by 10, store quotient in a and remainder in b
    133.  
    134.   mov r3,b  ;move value in b to r3
    135.  
    136.   mov r2,a  ;move value in a to r2
    137.  
    138.   lcall display  ;long call display
    139.  
    140. cjne r1,#80D,l1  ;compare r1 and 80D and jmp to l1 if not equal
    141.  
    142. l1:  jc l8  ;jump if carry to l8
    143.  
    144.   lcall send1  ;long call send1
    145.  
    146. l8:  sub r0,60D  ;defining l8
    147.  
    148.   jc send1
    149.  
    150. ljmp over1  ;long jump to over1
    151.  
    152. display  ;defining display
    153.  
    154. :mov dptr,#msg0  ;move msg0 to data pointer
    155.  
    156.   lcall message   ;long call message
    157.  
    158.   mov a,r2  ;move r2 to accumulator
    159.  
    160. add a,#30h  ;add 30H to a, ASCII conversion
    161.  
    162.   lcall ready  ;long call ready
    163.  
    164.   lcall sendit1  ;long call sendit1
    165.  
    166. mov a,r3   ;move content in r3 to accumator
    167.  
    168. add a,#30h  ;adding 30H to accumulator, ASCII conversion
    169.  
    170.   lcall ready  ;long call ready
    171.  
    172.   lcall sendit1  ;long call sendit1
    173.  
    174. mov a,r4  ;move content of r4 to accumulator
    175.  
    176.   add a,#30h  ;adding 30H to accumulator, ASCII conversion
    177.  
    178.   lcall ready  ;long call ready
    179.  
    180.   lcall sendit1  ;long call sendit1
    181.  
    182.   ret  ;return
    183.  
    184. message:  ;defining message
    185.  
    186. acall ready  ;absolute call to ready
    187.  
    188.   clr a  ;clear accumulator
    189.  
    190. movc a,@a+dptr  ;move code byte relative to data pointer to accumulator
    191.  
    192.   inc dptr  ;increment data pointer
    193.  
    194. cjne a,#eot,comd  ;compare a and eot and jump to comd if not equal
    195.  
    196.   ret  ;return
    197.  
    198. comd:  ;defining comd
    199.  
    200. cjne a,#com,data  ;compare Acc content and com and jump to data if not equal
    201.  
    202.   clr p0.0  ;compliment p0.0
    203.  
    204.   sjmp message  ;simple jump to message
    205.  
    206.  
    207. data:  ;defining data
    208.  
    209. cjne a,#dat,sendit  ;compare Acc contents to dat and jump to send it if not equal
    210.  
    211.   setb p0.0  ;set bit p0.0
    212.  
    213.   sjmp message  ;simple jump message
    214.  
    215. sendit:  ;define sendit
    216.  
    217. mov p2,a  ;move Acc contents to port 2
    218.  
    219.   clr p0.1    ;clear p0.1
    220.  
    221.   setb p0.2  ;set bit p0.2
    222.  
    223.   clr p0.2  ;clear p0.2
    224.  
    225.   sjmp message  ;simple jump message
    226.  
    227. ready:  ;defining ready
    228.  
    229. mov r7,p0  ;move p0 to r7
    230.  
    231.   clr p0.2  ;clear p0.2
    232.  
    233. mov p2,#0ffh  ;move 0ffH to port2 for transmission
    234.  
    235. clr p0.0  ;clear p0.0,RS=0,select command register
    236.  
    237.   setb p0.1  ;set bit p0.1, R/W=1 for read
    238.  
    239. wait:  ;defining wait
    240.  
    241.   clr p0.2  ;clear p0.2
    242.  
    243.   setb p0.2  ;set bit p0.2
    244.  
    245.   jb p2.7,wait  ;jump to wait if bit in p2.7
    246.  
    247.   clr p0.2  ;clear p0.2
    248.  
    249.   mov p0,r7  ;move content in r7 to p0
    250.  
    251.   ret  ;return
    252.  
    253. msg1:  ;defining msg1
    254.  
    255. .db com,3ch,06h,0eh,01h,81h,dat,"000",com,0c0h,dat,"heart beat",eot
    256.  
    257. ;data heart beat and 000 defined to display at specific location on lcd
    258.  
    259. msg0:  ;defining msg0
    260.  
    261. .db com,3ch,06h,0eh,01h,81h,eot
    262.  
    263.  
    264.  
    265. delay2:    ;defining delay2
    266.  
    267.   setb p1.0  ;set bit p1.0
    268.  
    269.   mov r6,#01h  ;move 01H to r6
    270.  
    271. cont2:  ;define cont2
    272.  
    273.   mov r2,#0ffh  ;move 0ffH to r2
    274.  
    275. s2:  ;define s2
    276.  
    277. mov r3,#0ffh  ;move 0ffH to r3
    278.  
    279. s1:  ;define s1
    280.  
    281. djnz r3,s1     ;decrement r3 and jump to s1 if r3 is non-zero
    282.  
    283. djnz r2,s2  ;decrement r2 and jump to s2 if r2 non zero
    284.  
    285. djnz r6,cont2  ;decrement r6 and jump to cont2 if r6 non zero
    286.  
    287.   cpl p1.0  ;compliment p1.0
    288.  
    289.   ret  ;return
    290.  
    291. sendit1:  ;defining sendit1
    292.  
    293. setb p0.0  ;set bit p0.0
    294.  
    295. mov p2,a     ;move accumulator contents to p2
    296.  
    297.   clr p0.1  ;clear p0.1
    298.  
    299.   setb p0.2  ;set bit p0.2
    300.  
    301.   clr p0.2  ;clear bit p0.2
    302.  
    303.   ret    ;return
    304.  
    305. delay:  ;dfining delay
    306.  
    307.   setb p1.0  ;set bit p1.0
    308.  
    309.   mov r6,#50h  ;move 50H to r6
    310.  
    311. c2:  ;defining c2
    312.  
    313.   mov r2,#61h  ;move 61H to r2
    314.  
    315. s20:  ;defining s20
    316.  
    317. mov r3,#0ffh  ;move offH to r3
    318.  
    319. s10:    ;defining s10
    320.  
    321. djnz r3,s10    ;decrement r3 and jump to s10 if r3 non zero
    322.  
    323. djnz r2,s20     ;decrement r2 and jump to s20 if r2 non zero
    324.  
    325. djnz r6,c2  ;decrement r6 and jump to c2if r6 non zero
    326.  
    327.   cpl p1.0  ;compliment p1.0
    328.  
    329.   ret  ;return
    330.  
    331. send1:    ;defining send1
    332.  
    333.   mov dptr,#msg2  ;move msg2 to data pointer
    334.  
    335.   lcall out  ;long call out
    336.  
    337.   mov dptr,#msg9  ;move msg9 to data pointer
    338.  
    339.   lcall out  ;long call out
    340.  
    341.   mov dptr,#msg10  ;move msg10 to data pointer
    342.  
    343.   lcall out  ;long call out
    344.  
    345.   mov a,r2  ;move content of r2 to a
    346.  
    347.   add a,#30h  ;add 30H to accumulator
    348.  
    349.   lcall out1  ;long call out1
    350.  
    351.   mov a,r3  ;move content of r3 to Acc
    352.  
    353.   add a,#30h    ;add 30H to aontent of Acc
    354.  
    355.   lcall out1    ;long call out1
    356.  
    357.   mov a,r4    ;move r4 contents to Acc
    358.  
    359.   add a,#30h  ;add 30H to Acc contents
    360.  
    361.   lcall out    ;long call out1
    362.  
    363.   mov dptr,#msg13  ;move msg13 to data pointer
    364.  
    365.   lcall out    ;long call out
    366.  
    367.   mov dptr,#msg14  ;move msg14 to data pointerr
    368.  
    369.   lcall out    ;long call out
    370.  
    371.   ret      ;return
    372.  
    373. out:    ;defining out
    374.  
    375. lcall delay1  ;long call delay1
    376.  
    377. trans:  ;defining trans
    378.  
    379.   mov pcon,#00h    ;move 00H to PCON
    380.  
    381.   mov tmod,#20h    ;move 20H to TMOD
    382.  
    383.   mov th1,#0fDh  ;move 0fdH to th1
    384.  
    385.   setb tr1        ;set bit tr1,T1 run control bit
    386.  
    387.   mov scon,#40h  ;move 40H to SCON
    388.  
    389.   clr a    ;clear accmulator
    390.  
    391. movc a,@a+dptr   ;move code byte relative to data pointer to accumulator
    392.  
    393. inc dptr    ;increment data pointer
    394.  
    395. cjne a,#eot,comd1   ;compare accumulator and eot and jump to comd1 if not equal
    396.  
    397.   ret  ;return
    398.  
    399. comd1:    ;defining comd1
    400.  
    401. mov sbuf,a  ;move accumulator contents to SBUF
    402.  
    403. wait1:    ;defining mait1
    404.  
    405. jbc ti,fin  ;jump bit carry ti to fin
    406.  
    407.   ljmp wait1    ;long jmp to wait1
    408.  
    409. fin:    ;defining fin
    410.  
    411. ljmp trans    ;long jump to trans
    412.  
    413. out1:    ;defining out1
    414.  
    415.   lcall delay1  ;jong call delay1
    416.  
    417. trans1:  ;defining trans1
    418.  
    419. mov pcon,#00h  ;move 00H to PCON
    420.  
    421.   mov tmod,#20h  ;move 20H to TMOD
    422.  
    423.   mov th1,#0fDh  ;move 0fdH to th1
    424.  
    425.   setb tr1  set bit tr1,T1 run control bit
    426.  
    427.   mov scon,#40h  ;move 40H to SCON
    428.  
    429. mov sbuf,a  ;move accumulator contents to SBUF
    430.  
    431. wait2:    ;define wait2
    432.  
    433.   jbc ti,fin1  ;jump bit carry ti to fin1
    434.  
    435.   sjmp wait2  ;simple jump wait2
    436.  
    437.  
    438. fin1:  ;defining fin1
    439.  
    440. ret  ;return
    441.  
    442. delay1:   ;defining delay1
    443.  
    444. setb psw.3  ;set bit psw.3
    445.  
    446.   mov r7,#08h  ;move 08H to r7
    447.  
    448. d3:  ;defining d3
    449.  
    450. mov r6,#0ffh  ;move 0ffH to r6
    451.  
    452. d2:  ;defining d2
    453.  
    454. mov r5,#0ffh  ;move 0ffH to r5
    455.  
    456. d1:  ;defining d1
    457.  
    458. djnz r5,d1  ;decrement r5 and jump to d1 if r5 non zero
    459.  
    460. djnz r6,d2  ;decrement r6 and jump to d2 if r6 non zero
    461.  
    462. djnz r7,d  ;decrement r7 and jump to d3 if r7 non zero
    463.  
    464.   clr psw.3  ;clear psw.3
    465.  
    466.   ret  ;returnJ
    467.  
    468. msg2:  .db "AT+CMGF=1",0dh,eot
    469.  
    470. msg9:  .db "AT+CMGS=",22h,"9633444713",22h,0dh,22h,”ATA9447700861”,22h,0dh,eot
    471.  
    472. msg10: .db "heart beat is "
    473.  
    474. msg13: .db 0dh,eot
    475.  
    476. msg14: .db 1Ah,eot
    477.  
    Moderators note : please use code tags for pieces of code
     
    Last edited by a moderator: Apr 16, 2015
  2. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Not an answer to your question but, have you found it like that? Has it any format?

    If so, for future postings of code, please use the "code" option from the toolbar.

    Just an example of how it could look:

    Code (Text):
    1. ;DIG_BCD_4:0 are trashed out upon completion.
    2.  
    3.     MOVF  DIG_BCD_1,W       ;(DIG_BCD_1 + DIG_BCD_3) *2
    4.     ADDWF DIG_BCD_3,W
    5.     MOVWF NROBIN_L
    6.     RLCF NROBIN_L,F
    7.  
    8.     SWAPF DIG_BCD_2,W       ;+DIG_BCD_2*16 + DIG_BCD_2
    9.     ADDWF DIG_BCD_2,W
    10.     ADDWF NROBIN_L,F
    11.  
    12.     RLCF DIG_BCD_4,W        ;+(DIG_BCD_4 *2 + DIG_BCD_3) *256
    13.     ADDWF DIG_BCD_3,W
    14.     MOVWF NROBIN_H
    15.  
    16.     RLCF NROBIN_L,F         ;*2
    17.     RLCF NROBIN_H,F
    18.  
    19.     SWAPF DIG_BCD_3,W       ;-DIG_BCD_3 *16
    20.     SUBWF NROBIN_L,F
    21.     BTFSS STATUS,C
    Easier for everybody, including you.
     
    Last edited: Apr 15, 2015
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    It's assembly language. Have you checked the microChip site?
     
  4. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,698
    905
    It is indeed Assembly language, but it is for the AVR/Atmel chips. The instructions are a bit different, so I would suggest looking for a tutorial for that type of MCU.

    John
     
  5. DickCappels

    Moderator

    Aug 21, 2008
    2,656
    632
    There are some instructions in the listing that are not in the AVR Instruction set document but do occur in 8051 assembly language. Examples: djnz and jbc.

    8051 instruction set: https://www.win.tue.nl/~aeb/comp/8051/set8051.html

    What you need to assemble this is , Muhamad, is an 8051 assembler.
    I tried ASEM51 on a an Atmel 8051 controller and it seemed to work.
    http://plit.de/asem-51/
     
  6. JWHassler

    Member

    Sep 25, 2013
    201
    33
    Those are 8051 mnemonics. In fact, the OP stated that.
    It looks like the output of a disassembler: all the comments are pointless re-iterations of the menmonics
     
  7. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Now I understand. Found them way too obvious :eek: thus, useless.
     
Loading...