0

I need to transform any input characters from lowercase to uppercase and vice versa. This currently only reads the input and prints it out. I'm using HEW with GNU for H8S/2600 Series. I'm new to this language so I'm sorry if I'm missing something.

    .h8300s

    .equ    PUTS,0x114
    .equ    GETS,0x113
    .equ    syscall,0x1FF00

    .data
input:  .space  100
prompt: .asciz "Zadejte vstupni data: "

    .align  2
par_input:  .long  input
par_prompt: .long  prompt

    .align  1
    .space  100
stck:

    .text
    .global _start

transform the string here:

transform:  

lab1:   rts
_start: mov.l   #stck,ER7
    mov.l   #input,ER2

    mov.w   #PUTS,R0
    mov.l   #par_prompt,ER1
    jsr     @syscall

    mov.w   #GETS,R0
    mov.l   #par_input,ER1
    jsr     @syscall

    xor.l   ER1,ER1

lab2:   mov.b   @ER2,R0L
    cmp.b   #0x0A,R0L
    beq     print
    jsr     @transform
    shll.l  #2,ER1
    shll.l  #2,ER1
    or.b    R0L,R1L
    inc.l   #1,ER2
    bra     lab2

print:
        mov.w   #PUTS,R0
        mov.l   #par_input,ER1
        jsr     @syscall
        jmp @lab3

lab3:   jmp @lab3
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • I'm not familiar with https://en.wikipedia.org/wiki/H8_Family. Apparently the Linux kernel has an `h8300` port. Is that the same as this, or should this be tagged h8s-architecture, or h8-300h or something? – Peter Cordes Jun 03 '20 at 11:58
  • For an algorithm, just check if a byte is an ASCII alphabetic character, and if so XOR with `0x20`: [What is the idea behind ^= 32, that converts lowercase letters to upper and vice versa?](https://stackoverflow.com/a/54585515) / [How to access a char array and change lower case letters to upper case, and vice versa](https://stackoverflow.com/a/35936844). As I said, I don't know this ISA so I'll leave it up to you to loop over an array. – Peter Cordes Jun 03 '20 at 12:01

0 Answers0