How do I use DATA and DB on 8051 assembler ? - Programmers Heaven

Howdy, Stranger!

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

Categories

How do I use DATA and DB on 8051 assembler ?

oversprayoverspray Posts: 14Member ✭✭
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.