Howdy, Stranger!

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


How do I use DATA and DB on 8051 assembler ?

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

;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
serout: jnb ti, serout
clr ti
mov sbuf, a
Text: DB 'hallo'


  • jpablormzjpablormz Member Posts: 2

    : ;----------------------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


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