emu8086 change case of the entered string and reverse it [closed]

陌路散爱 提交于 2019-11-29 18:28:33

I didn't really read your massive wall of uncommented code.

To reverse a buffer in-place, get pointers to the first and last characters, then:

  • Load the bytes into registers, then store the opposite registers back to the pointers.

  • Increment the start pointer si, decrement the end pointer di.

  • loop as long as start < end: cmp si, di / jb

Downcasing can be done on a single character, so you can do that on both bytes separately, when you have them in registers while you're swapping. Just check that it's between 'A' and 'Z', then add 0x20. (You unfortunately can't just or al, 20H unless you know that your character is already either a lower or uppercase letter, and not some other ASCII character).

Reversing to a new buffer is even easier. Just go forwards in one array and backwards in the other, for count bytes.

If your target baseline CPU feature set included 386 instructions, you could have loaded 4B at a time and used bswap to reverse bytes 4 at a time. Or with SSSE3, pshufb to reverse 16B at a time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!