English 中文(简体)
救助阵列或护卫,由一夫三28p
原标题:Save array or string and send it by uart assembler avr with atmega328p

试图将一个阵列从高射线到变数,将其送往高射线,一只狗知道在什么地方存在问题,以及该阵列在变数中获救,但无法在终端接收任何数据,很可能没有东西。

.DSEG
.ORG    0X0100
STRNG:      .BYTE   128 ;Strings recommended to be even


.CSEG

STRNG2:     .DB     "Printing aithing from probably the buffer",0X00 ;Strings recommended to be even
            RJMP    MAIN
            
MAIN:       SBI     DDRD,PD1
            LDI     R16,0X00
            LDI     R17,0XCF
            STS     UBRR0L,R17 ;UBRRXL - Usart Baud Rate 0 Register Low| Low byte of Baud Rate
            STS     UBRR0H,R16 ;UBRRXH - Usart Baud Rate 0 Register High| High 4bits of Baud Rate
            LDI     R18,0X22
            STS     UCSR0A,R18 ;UCSRXA - Usart Control and Status Register X A| flags, status and config: (flag after receive)(flag after transmit)(flag buffer data register empty[1 defaul])(flag frame error)(flag buffer overrun)(flag parity error)(U2XX state)(multiprocessor communication state) | set flags acording documentation (all in 0 except UDRE0)
            LDI     R19,0X06
            STS     UCSR0C,R19 ;UCSRXC - Usart Control and Status Register X C| flags, status and config: (Usart modes)(parity mode)(stop bits mode)(character size)(clock polarity[for USART])
            LDI     R20,0X18
            STS     UCSR0B,R20 ;UCSRXB - Usart Control and Status Register X B| config: (after receive interrupt)(after transmit interrupt)(buffer data register empty interrupt)(rx enable)(tx enable)(character size)(receive data bit 8[for 9bit])(transmit data bit 8[for 9bit])

LOOP:       RJMP    RX
            RCALL   WAITT
            RJMP    LOOP

RX:         LDS     R21,UCSR0A
            SBRS    R21,UDRE0
            RJMP    RX

            LDI     XL,LOW(STRNG)       ;Z POINTER  
            LDI     XH,HIGH(STRNG)
            LDS     R22,UDR0

            CPI     R22,0X0D
            BREQ    TX

            LDI     XL,LOW(STRNG)       ;Z POINTER  
            LDI     XH,HIGH(STRNG)
            ST      X+,R22
            RJMP    RX

TX:         LDI     XL,LOW(STRNG)       ;Z POINTER  
            LDI     XH,HIGH(STRNG)
            LD      R23,X+
            CPI     R23,0X00
            BREQ    END

SEND:       LDS     R21,UCSR0A
            SBRS    R21,UDRE0
            RJMP    SEND

            STS     UDR0,R23
            RJMP    TX

END:        RET

WAITT:      LDI  R24, 82
            LDI  R25, 43
L1:         DEC  r25
            BRNE L1
            DEC  r24
            BRNE L1
            RET

我无法理解问题何在。

问题回答

First issue in your program is that AVR8 core starts to execute code from reset vector at address 0 but you have string there. CPU tries to execute its content. Usually at address 0 interrupt vectors table is located. If you don t plan to use interrupts, you can place your code there, but it must start from address 0.

第二个问题是,你的法典通过测试《世界人权宣言》的旗帜,等待美国难民法庭的性质:

RX:         LDS     R21,UCSR0A
            SBRS    R21,UDRE0

UDREn: USART 登记册 就业:美国国旗表示,如果发射缓冲(UDRn)愿意接收新的数据。

您应测试RXC0的国旗,以探测性接收:

RXCn: USART 收到: 如果在接受缓冲器时没有现成的数据,并在得到缓冲器空时予以清除,则该旗帜即为固定。

RX:         LDS     R21,UCSR0A
            SBRS    R21,RXC0

第三个问题是,你在每台护堤上先把目前的守护点(X-register)初步化,另外两度是:在试验线端之前和在储存到缓冲地带之前。

第四个问题是,在斯特鲁埃职能中,你将联卢部队的确定者视为扼杀物的终结,但从未储存过。

整个方案如下。 我不知道西非信托公司的职能是这样消除的。

.DEVICE "ATmega328P"
.DSEG
.ORG    0X0100
STRNG:      .BYTE   128 ;Strings recommended to be even

.CSEG
MAIN:       SBI     DDRD,PD1
            LDI     R16,0x00
            LDI     R17,0xCF
            STS     UBRR0L,R17
            STS     UBRR0H,R16
            LDI     R18,0x22
            STS     UCSR0A,R18
            LDI     R19,0x06
            STS     UCSR0C,R19
            LDI     R20,0x18
            STS     UCSR0B,R20

LOOP:       LDI     XL,LOW(STRNG)       ; Set string pointer to the beginning of buffer
            LDI     XH,HIGH(STRNG)

RX:         LDS     R21,UCSR0A
            SBRS    R21,RXC0    ; USART Receive Complete
            RJMP    RX

            LDS     R22,UDR0

            CPI     R22,0x0D    ; End of line?
            BRNE    STORE       ; No - store received character into buffer

            LDI     R22,0x00    ; Store NUL terminator
            ST      X+,R22

            LDI     XL,LOW(STRNG)       ; Set string pointer to the beginning of buffer
            LDI     XH,HIGH(STRNG)

            RJMP TX             ; Print buffer content

STORE:      ST      X+,R22
            RJMP    RX

TX:         LD      R23,X+
            CPI     R23,0x00
            BREQ    LOOP        ; Read next line

SEND:       LDS     R21,UCSR0A
            SBRS    R21,UDRE0
            RJMP    SEND

            STS     UDR0,R23
            RJMP    TX

我对它进行了实际硬件的测试,但它确实在QEMU工作。

追求优化:你可以使用CR特性(0x0D)作为确定者。 在此情况下,你应当储存乌克兰国家武装部队的特性,但在安全局检查捷克共和国:

...
RX:         LDS     R21,UCSR0A
            SBRS    R21,RXC0    ; USART Receive Complete
            RJMP    RX

            LDS     R22,UDR0    ; Store character into buffer
            ST      X+,R22

            CPI     R22,0x0D    ; End of line?
            BRNE    RX          ; No - receive next character

            LDI     XL,LOW(STRNG)       ; Set string pointer to the beginning of buffer
            LDI     XH,HIGH(STRNG)

TX:         LD      R23,X+
            CPI     R23,0x0D    ; End of line?
            BREQ    LOOP        ; Read next line

SEND:       LDS     R21,UCSR0A
            SBRS    R21,UDRE0
            RJMP    SEND

            STS     UDR0,R23
            RJMP    TX

the fav answer not work to me. The point here is that data not appears in the terminal when i try the fav solution.

使用这些数据在Arduino IDE终端站进行测试,而且i能够继续进行必要的修改,即从现在到现在需要我的解决办法。

这是我的法典:

;------------------------------------------------------------------------
; print uart data:
;------------------------------------------------------------------------
    monitor_serial:   
                LDI     XL,LOW(strSerialRead)       
                LDI     XH,HIGH(strSerialRead)  
    
    read:       LDS     R21,UCSR0A
                SBRS    R21,RXC0    ; USART Receive Complete
                RJMP    read
                LDS     R22,UDR0    ; Store character r22  
                CPI     R22,0x0D    ; End of line?
                BREQ    SEND        ;yes - go to send
                ST      X+,R22  ; No - receive next character
                STS     UDR0,R22            
                rjmp read           
    
    SEND:   
            LD      R16, X ; save data of X register in R16 register
            STS     UDR0,R16 ;pass data from r16 register to udr0 register that will show it in the terminal(UDR0 register transmit all data that was stored there or store all data that was received and)
            ret ; return to initial stack point




相关问题
List of suspected Malicious patterns

I am doing an anti-virus project by disassembling its code and analyzing it. So I want a list of the Suspected Malicious pattern codes, so I can observe which is suspected and which is not? So I want ...

Prefetch for Intel Core 2 Duo

Has anyone had experience using prefetch instructions for the Core 2 Duo processor? I ve been using the (standard?) prefetch set (prefetchnta, prefetcht1, etc) with success for a series of P4 ...

How are mutex and lock structures implemented?

I understand the concept of locks, mutex and other synchronization structures, but how are they implemented? Are they provided by the OS, or are these structures dependent on special CPU instructions ...

Installing GNU Assembler in OSX

No matter how hard I google, I can t seem to find a (relatively) easy-to-follow instruction on how to install the GNU Assembler on a mac. I know I can use gcc -c (Apple Clang on a Mac) to assemble .s ...

8086 assembler,INT 16,2

I got stuck at this thing,I want to see if right shift button has been pressed,so I have this assambler code: mov ah,2 int 16h ;calling INT 16,2 - Read Keyboard Flags interrupt mov ah,...

Translate a FOR to assembler

I need to translate what is commented within the method, to assembler. I have a roughly idea, but can t. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, ...

热门标签