-4

first of all, I am a beginner in assembly language and right now I am studying microprocessor. We programed some small programs. However, I am working on program called "Basic Encryption Scheme (BES)" The idea is to to toggles the low order of bit of a character entered by the user. then, take input from 1-9 and add it to the toggled character. finally, print it out. For example, if the input character is A and the input key value is 6. the program should take the ASCIl value of A, 01000001, toggle bit [o:o], producing 01000000 and then add the input value key, 6. The final output character would be 01000110. which is the ASCII value F

The good news is that I programmed almost everything : => I programmed a message that take more than one characters and save them in [si] => I programmed a message that take input key value and convert it to register and save it in bl => I programmed a cod that will take the string from [si] and [di] and print them on screen.

just what I need a cod that apply the method of Basic Encryption Scheme by taking the string from [si] and key from (bl).

thank you

  • 1
    [`xor`](http://x86.renejeschke.de/html/file_module_x86_id_330.html), [`add`](http://x86.renejeschke.de/html/file_module_x86_id_5.html) (keep in mind `'z' + 6 == 128`, so you should probably decide, if the ending letters rotate back to A/a (i.e. `Z`->`B` for 2, and `z`->`b` for 2 => a bit complex logic), or if you will rotate inside some "valid range" like 32-122, so `Z`->`a` for 7, and `z`->`` for 1)) – Ped7g May 05 '17 at 13:44
  • 2
    If you did all that programming, you should have some code to show us. Maybe a [MCVE], with a comment or two showing the parts where you're stuck. – Cody Gray - on strike May 05 '17 at 13:49
  • no need to rotate back from z to a , I want valid range – jack russel May 05 '17 at 13:50
  • So do it. If stuck, take a look at 8086 instruction set list (it's quite short for original 8086, I think wikipedia has it per CPU generation) and go through it, what sounds usable, then check details. For the code you are doing you need probably only (without I/O parts, which are platform specific in assembly and can be copied from examples): `mov, add/sub, j, cmp, xor, jmp` ... `call/ret` may be handy to avoid code duplicity and give it some structure, `push/pop` is simple way to temporarily preserve values. But keep exploring all of them, it will help you to get the feel for it. – Ped7g May 05 '17 at 14:03

1 Answers1

2

Top:

taking the string from [si]

mov dl, [si]

toggle bit [o:o]

xor dl, 1

add the input value key

add dl, bl

print them on screen.

mov ah, 02h
int 21h

Since you already

programed a massage that take more than one characters and save them in [si]

you will have saved the length of this string in some memory location or register. I think the CX register would have been a good place.

To process the whole string, then, you:

  • increment the pointer SI
  • decrement the length CX
  • if the length is not zero, you repeat from the Top:
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Fifoernik
  • 9,779
  • 1
  • 21
  • 27