Find the missing permutation: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add 8080 assembly) |
Not a robot (talk | contribs) (Add 8086 assembly) |
||
Line 139: | Line 139: | ||
db 'DCBA','BACD','BADC','BDAC','CBDA','DBCA','DCAB' |
db 'DCBA','BACD','BADC','BDAC','CBDA','DBCA','DCAB' |
||
db 0 ; end marker </lang> |
db 0 ; end marker </lang> |
||
{{out}} |
|||
<pre>Missing permutation: DBAC</pre> |
|||
=={{header|8086 Assembly}}== |
|||
<lang asm> cpu 8086 |
|||
org 100h |
|||
mov si,perms ; Start of permutations |
|||
xor bx,bx ; First word of permutation |
|||
xor dx,dx ; Second word of permutation |
|||
mov cx,23 ; There are 23 permutations given |
|||
perm: lodsw ; Load first word of permutation |
|||
xor bx,ax ; XOR with first word of missing |
|||
lodsw ; Load second word of permutation |
|||
xor dx,ax ; XOR with second word of missing |
|||
loop perm ; Get next permutation |
|||
mov [mperm],bx ; Store in placeholder |
|||
mov [mperm+2],dx |
|||
mov ah,9 ; Write output |
|||
mov dx,msg |
|||
int 21h |
|||
ret |
|||
msg: db 'Missing permutation: ' |
|||
mperm: db 0,0,0,0,'$' ; Placeholder |
|||
perms: db 'ABCD','CABD','ACDB','DACB','BCDA','ACBD','ADCB','CDAB' |
|||
db 'DABC','BCAD','CADB','CDBA','CBAD','ABDC','ADBC','BDCA' |
|||
db 'DCBA','BACD','BADC','BDAC','CBDA','DBCA','DCAB'</lang> |
|||
{{out}} |
{{out}} |
||
<pre>Missing permutation: DBAC</pre> |
<pre>Missing permutation: DBAC</pre> |