Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How do I use DATA and DB on 8051 assembler ?

Can anyone check out and maybe correct this code?
It`s supposed to print " hallo" to the PC terminal,but actually puts out weired characters to the screen.

Code:
;*********************************************
;controller 80531
org 100h
;--------------------------------------------
endl equ 00h; end of string
;--------------------------------------------
mov SCON,#52h
orl PCON ,#80h
orl TMOD, #20h; orl Tmod, #00100000; = 32
mov TH1, #0F3h; 2400 baud 12 MHz
setb TR1
setb EA
setb ES
;------------read out the table--------------
mov r2, #00h;
mov dptr, #Text
bi3: mov a, r2
movc a, @a+dptr
cjne a, #endl, bi1; string end ?
ljmp bi2
bi1: lcall serout
inc r2; next Letter
ljmp bi3
bi2: ljmp bi2
;----------------------Serielout-------------
serout: jnb ti, serout
clr ti
mov sbuf, a
ret
;-------------------string-------------------
Text: DB 'hallo'
---------------------------------------------
End
;********************************************

Comments

  • jpablormzjpablormz Posts: 2Member

    : ;----------------------Serielout-------------
    : serout: jnb ti, serout
    : clr ti
    : mov sbuf, a
    : ret

    This routine is wrong. If you wish to send the contents of the accumulator through the serial port you must do a

    MOV SBUF,A

    BEFORE your serout: tag.
Sign In or Register to comment.