Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

assembly code help needed urgent please

Status
Not open for further replies.

john2020

Full Member level 5
Joined
Nov 13, 2005
Messages
292
Helped
12
Reputation
24
Reaction score
8
Trophy points
1,298
Activity points
4,911
please help me what does the following 8051 assembly code do?



Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
uart_tx_isr: 
PUSH ACC 
PUSH REG0 
PUSH MPAGE 
CLR UTX1IF 
MOV A, uart_tx_head 
XRL A, uart_tx_tail 
JNZ uart_tx_next_byte 
CLR uart_tx_busy 
ANL IEN2, #~008h 
JMP uart_tx_isr_end 
uart_tx_next_byte: 
MOV MPAGE, #HIGH uart_tx_buffer 
MOV R0, uart_tx_tail 
MOVX A, @R0 
INC uart_tx_tail 
MOV U1DBUF, A 
uart_tx_isr_end: 
POP MPAGE 
POP REG0 
POP ACC 
RETI

 
Last edited by a moderator:

please help me with basic assembly programming. i am newbie,so unable to understadn this code.
 

Hi,

I do not do 8051 assembler coding but that bit of code is just a small part of a bigger routine.

Its part of the programs ISR ,Interrupt Service Routine, which when activated sends out some data on the Serial port.

Perhaps if you explain what you are wanting to do someone can help more or direct you to a good 8051 assembler tutorial or book..
 

here uart tx and rx is written as an isr and whenever interrupt occurs it gets trigerred...what do u think?
 

It is a UART transmit interrupt routine.
The size of the transmit buffer is 256 bytes, but it is considered full when 255 bytes are stored.

I have added some comments to the code.

Code:
uart_tx_isr: 
PUSH ACC                         ; save the registers we modify in this interrupt routine so we can restore them before we return
PUSH REG0 
PUSH MPAGE 
CLR UTX1IF                       ; clear the UART transmit interrupt
MOV A, uart_tx_head              ; get the address where the next element will be stored in the transmit queue
XRL A, uart_tx_tail              ; xor with the address of the first element in the transmit queue
JNZ uart_tx_next_byte            ; if they are equal we get a zero result, and the queue is empty now
CLR uart_tx_busy                 ; the queue is empty, clear the flag that says that we are busy with transmit
ANL IEN2, #~008h                 ; disable the UART TX interrupt
JMP uart_tx_isr_end              ; we are done
uart_tx_next_byte:               ; the transmit queue is not empty
MOV MPAGE, #HIGH uart_tx_buffer  ; map the memory page where the transmit queue is located
MOV R0, uart_tx_tail             ; load the address of the next byte to be sent
MOVX A, @R0                      ; read the byte from memory
INC uart_tx_tail                 ; increment the address
MOV U1DBUF, A                    ; put the byte in the UART transmit buffer
uart_tx_isr_end: 
POP MPAGE                        ; restore all registers that we have modified in this interrupt routine
POP REG0 
POP ACC 
RETI                             ; return from this interrupt routine
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top