How to change one or more characters from a string entered into the keyboard in MASM32

43 views Asked by At
movzx eax, byte ptr [a]
movzx ebx, byte ptr [m]
add al, bh

I used the above command but the program doesn't show anything

I want to change the characters according to the Caesar cipher, that is, the letter a to b,c,d with that change between the number entered in the keyboard for example m=1 then a to b m=2 then a to c

1

There are 1 answers

0
Sep Roland On
add al, bh

I used the above command but the program doesn't show anything

You don't actually output anything to a screen, so I understand that you are using the word 'show' loosely here, in the sense that the addition add al, bh simply does not change the AL register.
The reason for this is that the BH register is zero because of the movzx ebx, byte ptr [m] instruction. So it is a typo and what you meant to happen is adding BL to AL. And because you are writing 32-bit code, that would better become add eax, ebx:

; Caesar cipher loop
    movzx ebx, byte ptr [m]  ; CONST
.a: movzx eax, byte ptr [a]  ; Current character
    add   eax, ebx
    cmp   eax, "z"
    jbe   .b
    sub   eax, 26
.b: mov   byte ptr [a], al
    ...