[SOLVED !] Assembler


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Assembler3769 days old

  1. #1
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default Assembler

    Hi there...

    Is there anyone that can help me to translate a ASM program to BASIC??

    My ASM language knowledge is very limited.

    The program I want to translate is:
    Code:
    Source code file for Ericsson GA628 lcd interface:
    
    ;=====i2c lcd test for Ericsson GA628 / Version 2.0======21/06/03==
    ;	iic lcd driver: PCF2103
    ;	ra0,ra1     sdata,sclock
    ;	rb0 to rb7	led outputs
    ;	internal clock
    ;	standard crystal 4.000 MHz XT - 1us pe instructiune
    ;	Program realizat de Ing. Bergthaller Iulian-Alexandru 
    ;------------------------------------------------------------
    	list	p=16f84A;f=inhx8m
    _CP_OFF	equ	H'3FFF'	      ;code protect off
    _PWRTE_ON	equ	H'3FFF' 		;Power on timer on
    _WDT_OFF	equ	H'3FFB'		;watch dog timer off
    _XT_OSC		equ	H'3FFD'	;crystal oscillator
    	__CONFIG       _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
    ;------------------------------------------------------------
    ;      cpu init
    status	equ	03
    porta	equ	05
    portb	equ	06
    count1	equ	0C
    count2	equ	0D
    count3	equ	0E
    transo	equ	0F
    trisa	equ	85
    trisb	equ	86	
    #DEFINE sclk	porta,1
    #DEFINE sdta	porta,0
    ;------------------------------------------------------------
    ;      bit init
    rp0	equ	5
    w	equ	0
    f	equ	1
    ;------------------------------------------------------------
    	org	0
    ;
    ;------------------------------------------------------------
    init	bsf	status,rp0  ;switch to bank 1
    	movlw	0	; porta and portb set to outputs
    	movwf	trisa
    	movwf	trisb
    	bcf	status,rp0  ;switch back to bank 0
    	movlw	0
    	movwf	porta
    	movwf	portb	
    ;***************************************************
    start	movlw	0xFF	; led test
    	movwf	portb 
    	call	pause
    ;***************************************************
    ;* Lcd init commands                               *
    ;***************************************************
    scrie	call	iict	; i2c start
    	movlw	0x74	; device write address (75h for read)
    	call	act	; i2c send subroutine
    	movlw	0x00	; Co,RS=0, set instruction register for multiple next command bytes  
    	call	act
    	movlw	0x31	; extended instruction set
    	call	act
    	movlw	0x02	; set screen configuration left to right 
    	call	act
    	movlw	0x05	; set display configuration 
    	call	act
    	movlw	0x08	; set icon mode, full mode, icon blink disable
    	call	act
    	movlw	0x30	; normal instruction set
    	call	act
    	movlw	0x0C	; set display on
    	call	act
    	movlw	0x06	; set cursor move direction
    	call	act
    	movlw	0x02	; set DDRAM address 0 in address counter
    	call	act
    	call	iicp	; i2c stop 
    ;***************************************************
    ;* Lcd icon sets off                               *
    ;***************************************************
    	call	iict
    	movlw	0x74
    	call	act
    	movlw	0x80	; Co=1, RS=0 just one next command byte
    	call	act
    	movlw	0x4C	; set CGRAM for icons
    	call	act
    	movlw	0x40	; Co=0, RS=1, set instruction register for multiple next data bytes  
    	call	act
    	movlw	0x00	; erase icons sequence
    	call	act
    	movlw	0x18
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x0F
    	call	act
    	movlw	0x10
    	call	act
    	call	iicp	; i2c stop 
    ;***************************************************
    ;* Lcd cursor subroutine                           *
    ;***************************************************		
    	call	iict
    	movlw	0x74
    	call	act
    	movlw	0x00
    	call	act
    	movlw	0x30
    	call	act
    	movlw	0x01	; clears entire display and sets DDRAM address to 0 in address counter
    	call	act
    	movlw	0x0F	; display on, cursor on, cursor blink on
    	call	act
    	call	iicp
    ;***************************************************
    ;* Lcd data subroutine                             *
    ;***************************************************	
    	call	iict
    	movlw	0x74
    	call	act
    	movlw	0x80	; Co=1, RS=0 just one next command byte
    	call	act
    	movlw	0x8C	; set CGRAM for characters
    	call	act
    	movlw	0x40	; Co=0, RS=1, set instruction register for multiple next data bytes  
    	call	act
    	movlw	0xC8	; H
    	call	act
    	movlw	0xE5	; e
    	call	act
    	movlw	0xEC	; l
    	call	act
    	movlw	0xEC	; l
    	call	act
    	movlw	0xEF	; o
    	call	act
    	movlw	0x20	;  
    	call	act
    	movlw	0xD7	; W
    	call	act
    	movlw	0xEF	; o
    	call	act
    	movlw	0xF2	; r
    	call	act
    	movlw	0xEC	; l
    	call	act
    	movlw	0xE4	; d
    	call	act
    	call	iicp
    homa	goto	homa
    ;***************************************************
    act	movwf	transo	; iic data transmission 
    	call	oled	
    	movlw	0x08
    	movwf	count3
    vbit	bcf	sclk
    	call	pause
    	btfsc	transo,7	
    	bsf	sdta
    	btfss	transo,7
    	bcf	sdta
    	call	pause
    	bsf	sclk
    	call	pause
    	bcf	sclk
    	call	pause
    	rlf	transo,f
    	decfsz	count3,f
    	goto	vbit
    	call	ackp
    	retlw	00
    ;***************************************************
    iicp	bcf	sdta	; stop condition module
    	call	pause
    	bsf	sclk
    	call	pause
    	bsf	sdta	; stop command
    	call	pause
    	bcf	sclk
    	call	pause
    	retlw	00
    ;***************************************************	
    iict	bsf	sdta	; start condition module 
    	bsf	sclk
    	call	pause
    	bcf	sdta	; start command
    	call	pause
    	bcf	sclk
    	call	pause
    	retlw	00
    ;***************************************************
    ackp	bsf	sclk	; one clock step for acknowledge (not read)
    	call	pause
    	bcf	sclk
    	call	pause
    	retlw	00
    ;***************************************************
    oled	call	halta	; iic data before transmission displayed on portb
    	movlw	0x00
    	movwf	portb 
    	movf	transo,w
    	movwf	portb
    	call	halta
    	movlw	0x00
    	movwf	portb
    	retlw	00
    ;***************************************************
    pause	movlw	0x08	; cca. 6ms delay
    	movwf	count1
    d1	movlw	0xFF	  
    	movwf	count2
    d2	decfsz	count2,f	
    	goto 	d2		
    	decfsz	count1,f	
    	goto 	d1		
     	retlw	00
    ;***************************************************
    halta	movlw	0x03	; cca. 585ms delay
    	movwf	count3
    r3	movlw	0xFF
    	movwf	count1
    r1	movlw	0xFF	  
    	movwf	count2
    r2	decfsz	count2,f	
    	goto 	r2		
    	decfsz	count1,f	
    	goto 	r1		
    	decfsz	count3,f    
    	goto 	r3          
    	retlw	00
    ;------------------------------------------------------------
    	end
    ;============================================================
    This is to use ans old ericsson GA628 LCD in a project.

    Any help will be appreciated.

    Thanks

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default

    Ok, maybe this was too much to ask...

    Is there anyone that can help me to understand that code? Any tutorial or something?

    Thanks in advance.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default

    This can get you started...

    In the top section of code names are assigned to sections of memory, (can be used like variables) eg.
    XYZ equ 0x45
    becomes...
    Dim XYZ as Byte
    You don't need to bother with the 45, PDS allocates things for you. Also you don't need to define the locations of SFRs cuch as PORTB, etc. but count2, etc. is a variable.

    Combinations of movlw...movwf writes a literal value into a register, ie.
    movlw 0x12
    movwf PORTA
    sets PORTA to $12

    bsf, bcf clear bits of a file register like
    bsf PORTA,7
    is like
    PORTA.7 = 1

    call is like gosub.

    In assembler labels do not have colons ":" on the end, but they are recognised by being in the first column of code and are not instructions.

    Note that format prefixes are different in PDS...

    Hex in ASM = 0x123, in PDS = $123
    Dec in ASM = 123, in PDS = 123
    Bin in ASM = 0b'101', in PDS = %101

    There are also conditional statements....
    btfss (skip next instruction if bit is set)
    btfsc (skip next instruction if bit is clear)
    decfsz (decrement register and skip next instruction if result is 0)
    incfsz (increment register and skip next instruction if result is 0)
    eg.
    Code:
    decfsz    count3,f
        goto    vbit
        call    ackp
    becomes...
    Code:
    dec count3
    if count3 <> 0 then goto vbit
    call ackp
    This should get you started...

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,363
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default

    Hi,
    Whenever I get something like this I do not try to do a conversion but look at what it is trying to do and then see if I can create it in PDS totally with BASIC. Generally I find if you just try to convert the ASM code it does not make very good reading.
    From first glance it looks like it is just I2C to LCD, I think this has been done somewhere, possibly by Wastrix?

    Regards,
    Bob

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Citius
    Guest Citius's Avatar

    0 Not allowed!

    Default

    If you are serious/curious about Assembly...there is a fantastic book, that is both quick to read, and easy to digest. You'll be hooked right away, and what you lear will stick with you (mostly )

    I bought a copy back in 2003 and read it in the course of a month. It serves as a reference to me to this day.

    PIC In Practice by David Smith Published by Newnes

    I even wrote the author a question via e-mail and he responded within half a day.

    It covers everything from LCDs to Interrupts to A/d to Radio Rx & Tx Modules, EEPROM, Keypads, etc...all with excellent examples.

    Carl

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default

    Maybe I should have actually read what the code did

    If you are simply driving a PCF2103 via I2C, that is very easy. You can see the controller datasheet here: http://www.datasheetcatalog.org/data...2103_FAM_1.pdf

    You can use PDS commands like HBusOut or I2COut or BusOut to send I2C commands, then write a custom print command to use this LCD

    @Bob: That was actually for a 2-wire HD44780 LCD using a 4015 shift register, it didn't use I2C, but the framework could be adapted.

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Fanatical Contributor fanie's Avatar
    Join Date
    Oct 2005
    Posts
    7,989
    Thumbs Up
    Received: 31
    Given: 15
    Total Downloaded
    434.52 MB

    0 Not allowed!

    Default

    Have a look at the pre-processor
    Fanie

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default

    Hi there...

    I tried to "translate" the asm, to basic, using wastrix suggestion, I had read the PDF for PCF2103, that is the driver for the GA628 LCD, and has the control address of 0x74 for write and 0x75 for read, I used BUSOUT command, but I cannot get the LCD to show anything...

    I "used" the asm code as a reference for the program, and I got this:

    File CONTROL.BAS:
    Code:
    Device 16F84A
    Xtal 10
    Config CP_OFF, PWRTE_OFF, WDT_OFF, HS_OSC
    
    TRISA = %00000000           ' Configure I/O on port A
    TRISB = %00000000           ' Configure I/O on port B
    Include "ga628.inc"
    
    Call LCD_Test
    
    
    End
    File GA628.INC:
    Code:
    Declare SDA_Pin PORTB.5
    Declare SCL_Pin PORTB.4
    Declare Slow_Bus 1          ' 1 if Xtal higher than 4MHz
    Symbol Control = %01110100  ' device write address (01110101 for read)
    
    GoTo JumpOver
    
    LCD_Test:
        HBStart
        HBusOut Control, 0,[49,2,5,8,48,12,6,2]
        BStop
        DelayMS 10
        
        BStart
        BusOut Control, 128,[76,64,0,24,0,0,0,0,0,0,0,0,0,0,15,16]
        BStop
        DelayMS 10
        
        BStart
        BusOut Control,0,[48,1,15]
        BStop
        DelayMS 10
        
        BStart
        BusOut Control,128,[140,64,"Hello World"]
        BStop
        DelayMS 10
        Return
    
    JumpOver:
    Can anyone tell me what am I forgetting?

    Thanks

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default

    In the File ga628.inc, where it shows:
    Code:
    LCD_Test:
        HBStart
        HBusOut Control, 0,[49,2,5,8,48,12,6,2]
        BStop
    It should be:
    Code:
    LCD_Test:
        BStart
        BusOut Control, 0,[49,2,5,8,48,12,6,2]
        BStop
    This Pic doesn't have a MSSP module.

    Despite that, I cannot get the LCD to show anything...

    Anyone can help?

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    flosi
    Guest flosi's Avatar

    0 Not allowed!

    Default

    Try to increase contrast.

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by flosi View Post
    Try to increase contrast.
    It cannot be a contrast problem, because I'm using the same circuit, for try with that first code, the ASM, and with the BASIC code, and in the BASIC version, I cannot see anything...

    Any more clues?

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    flosi
    Guest flosi's Avatar

    0 Not allowed!

    Default

    You mean that you assembled the the asm code andt hat worked?

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #13
    nullsoft
    Guest nullsoft's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by flosi View Post
    You mean that you assembled the the asm code andt hat worked?
    Yes, the ASM code worked, and I saw the "Hello World" on the LCD, but that code I cannot use in my project to display what I want, and use as I need.

    As I said, I tried the BusOut, but cannot get it to work...

    If someone could help me, I'll be thankful...

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #14
    pverburg
    Guest pverburg's Avatar

    0 Not allowed!

    Default

    well time to get the scope out and see what your basic is sending and compare with the output of the asm.

    Paul V.

  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  29. #15
    wastrix
    Guest wastrix's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by pverburg View Post
    well time to get the scope out and see what your basic is sending and compare with the output of the asm.

    Paul V.
    Yes. I have had problems in the past with the software I2C commands, I'm not really sure why as the waveforms seem OK.

    Is it possible to try the code on a device with an MSSP module?

  30. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Assembler to Proton
    By teo in forum Proton Plus Compiler v3
    Replies: 9
    Last Post: 23rd August 2018, 13:47
  2. Assembler listing
    By towlerg in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 22nd February 2017, 16:57
  3. Microchip assembler
    By towlerg in forum The Lounge
    Replies: 2
    Last Post: 19th October 2016, 19:27
  4. [SOLVED !] Need a little help in assembler, please...
    By pdgnr in forum Proton Plus Compiler v3
    Replies: 8
    Last Post: 1st June 2006, 08:42
  5. Help in assembler
    By pdgnr in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 28th March 2006, 10:02

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts