简体   繁体   中英

How to put label with 8085 microprocessor in assembly language?

I have a code that should convert uppercase letters to lowercase using 8085 microprocessor (the GNUSim8085 simulator). However, the code is not readable, and immediately throws an error in row "lowercase:", that "the line of code must be given a label". Maybe you know how to give a label or fix this error, so, the code could convert uppercase to lowercase letters?

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

exact error: enter image description here

From GNUSim8085's docs, specifically the Assembly Language Guide :

Labels must always be placed in the first column and must be followed by an instruction (no empty line).

This is an awkward restriction but it is documented. So write:

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

To make this look better, you might want to increase your indentation, or use shorter labels.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM