汇编练习Complementary DNA

Description:

Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.

If you want to know more http://en.wikipedia.org/wiki/DNA

In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You have a function with one side of the DNA (string, except for Haskell); you need to get the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell).

More similar exercise are found here http://rosalind.info/problems/list-view/ (source)

DNA_strand ("ATTGC") # return "TAACG"

DNA_strand ("GTAT") # return "CATA"



SECTION .text
global dna_strand
extern strdup
dna_strand:
  call strdup
  xor  rcx,rcx
  .b:movzx rdx,byte[rax+rcx]
     mov   dl,[.replace+rdx-'A']
     mov   [rax+rcx],dl
     inc   rcx
     cmp   byte[rax+rcx],0
  jne .b   
  ret
 .replace      db 'T',0,'G',0,0,0,'C'
 times 'T'-'H' db 0
               db 'A'

代码摘自:https://www.codewars.com/kata/554e4a2f232cdd87d9000038/solutions

代码是codewar上面的,记录一下这总写法,过几天自己再来写一遍这道题,并且使用该方法

posted @ 2020-09-07 16:49  PYozo_free  阅读(184)  评论(0编辑  收藏  举报