assembly 如何用汇编语言标注8085微处理器?

ctrmrzij  于 2022-12-29  发布在  其他
关注(0)|答案(1)|浏览(135)

我有一个代码,应该转换大写字母为小写使用8085微处理器(GNUSim8085模拟器)。然而,代码是不可读的,并立即抛出一个错误行“lowercase:“,即“该行代码必须给予标签”。也许你知道如何给予标签或修复此错误,所以,代码可以转换大写字母为小写字母?

jmp lowercase 

lowercase:
    mov b, a ; move N (length of text) to register B
    mov c, h ; move high byte of HL to register C
    mov d, l ; move low byte of HL to register D

lowercase_loop:
    ldax d ; load character from memory address pointed to by HL into accumulator
    cpi 'A' ; compare character in accumulator with uppercase 'A'
    jc lowercase_skip ; if character is less than 'A', skip to next character
    cpi 'Z'+1 ; compare character in accumulator with one greater than uppercase 'Z'
    jnc lowercase_skip ; if character is not less than or equal to 'Z', skip to next character
    add a, 'a'-'A' ; convert uppercase character to lowercase
    stax d ; store character in accumulator back to memory address pointed to by HL

lowercase_skip:
    inx h ; increment high byte of HL
    inx d ; increment low byte of HL
    dec b ; decrement B (counter)
    jnz lowercase_loop ; repeat loop until B becomes zero
    ret ; return to caller

hlt

精确误差:enter image description here

yfjy0ee7

yfjy0ee71#

来自GNUSim8085的文档,特别是Assembly Language Guide
标签必须始终放置在第一列,后面必须有说明(无空行)。
这是一个尴尬的限制,但它是有据可查的。所以写:

lowercase: mov b, a ; move N (length of text) to register B
    mov c, h ; move high byte of HL to register C
    mov d, l ; move low byte of HL to register D

若要使其看起来更好,您可能需要增加缩进,或使用较短的标签。

相关问题