Simple Goldbach conjecture of compilation

Source: Internet
Author: User
Tags split
Simplified song Goldbach conjecture: Any even number greater than 6 can be represented as a sum of two primes. Now from the keyboard input a 0~65535 between the unsigned integer, the test certificate Goethe Bach conjecture.
If input number 12, output:
12=5+7
If input number 20, output:
20=3+17
20=7+13
If input number 7, output:
Must be even
If input number 3, output:

Must is greater than or equal to 6


Here are some diagrams to illustrate the idea







Enter a string of characters from the keyboard, and try to compile a program to test whether a number exists in the string. If so, place CL 5th position 1, otherwise the position will be 0.



In the first address of the word group of data, stored 100H 16-digit complement number, try to write a program, find their average value in the AX register, and find out how many numbers in the array is less than this average, the results are placed in the BX register.



Known quantity Group A contains 15 unequal integers, and array B contains 20 integers that are not equal to each other. Try to compile a program that stores an integer that appears in both A and B in the array C1.



Here's the full-text code

DATAS SEGMENT num DW 0 y DW Ten flag DW 0 a DW 0 B DW 2 d DW 1 e DW 0 F DW 0 Both DW 2 flag2 DW 0 H1 DB "Please input a number:", ' $ ' H2 db 0AH,0DH, "Your input is inlow!", ' $ ' H3  DB 0AH,0DH, "the input must be even or greater than 6", ' $ ' DATAS ENDS STACKS SEGMENT DW-dup (0) STACKS ENDS CODES  SEGMENT assume Cs:codes,ds:datas,ss:stacks main proc far push DS mov ax,0 push ax mov ax,datas mov  Ds,ax Call input Call Check CMP flag,0 JNZ exit call ending exit:
      	MOV ah,4ch int 21h main ENDP;------------------late-night split line-------------------------------------------input proc near Push AX push BX push CX push dx push di push si mov ah,09h lea dx,h1 i  NT 21H mov cx,6 l1:mov ah,01h int 21h xor Ah,ah cmp ax,0dh JE
  L2 CMP ax,30h    	JB L3 CMP ax,40h JNB L3 Sub ax,30h mov di,ax mov ax,a mul y mo
	  	V a,ax add A,di loop L1 Jmp L2 l3:inc flag l2:pop si pop di pop dx pop cx Pop bx pop ax ret input ENDP;----------------------very hungry. Split Line---------------------------------------------Check P  ROC near push AX push BX push CX push dx push di push si cmp flag,0 jnz S1 CMP a,5 JB S2 Test a,01 jnz S2 jmp exit s1:inc flag mov ah,0 9h Lea DX,H2 int 21h jmp exit s2:inc flag mov ah,09h Lea Dx,h3 in T 21h exit:pop si pop di pop dx pop cx pop bx pop ax ret check ENDP;----------------------- Split Line-----supper---------------------------------sushucheck proc near push ax push BX push CX push DX p

    Ush di push Si    
        XOR DX,DX mov ax,b mov si,ax cmp si,1 JZ exit MOV di,0 mov flag2,di mov di,1 mov d,di l1:inc d cmp d,si JNB
        
        
        



Exit2 xor DX,DX mov ax,b div d cmp dx,0 JE exit jmp L1 Exit:inc flag2 exit2:pop si pop di pop dx pop cx pop bx pop AX ret Sushu
	  	Check ENDP;--------------------------still hungry. Split Line-------------------------------print proc near push ax push BX
        
        
Push CX push dx push di push si xor cx,cx xor DX,DX mov ax,f
    	L1:xor dx,dx Div y add dx,30h Push DX Inc CX CMP ax,0 jnz L1 a1:pop DX 
        
        mov ah,02h int 21h loop A1 jmp S1 S1:mov ah,02h mov dl, ' + ' int 21h XOR CX, CX XOR DX,DX mov ax,b l2:xor dx,dx div y add dx,30h Push DX Inc CX CM P ax,0 jnz L2 a2:pop DX mov ah,02h int 21h loop A2 jmp S2 S2:mov ah,02h mo  V dl, ' = ' int 21h xor cx,cx xor DX,DX mov ax,a l3:xor dx,dx Div
    	Y add dx,30h Push DX Inc CX CMP ax,0 jnz L3 a3:pop DX mov ah,02h int 21h Loop A3 exit:pop si pop di pop dx pop cx pop bx pop ax ret print ENDP;--------- ---------------Split line of Tears----------------------------------ending proc near push ax push BX push CX pus
      H dx push di push si l1:inc b call sushucheck cmp flag2,0 jnz L1 mov ax,a
      CMP B,ax JNB Exit Sub ax,b mov bx,b mov b,ax call Sushucheck cmp flag2,0 Je L2 mOV B,BX jmp L1 l2:mov ax,b mov f,ax mov b,bx call print mov ah,02h
	  	mov dx,0ah int 21h jmp L1 exit:pop si pop di pop dx pop cx pop bx

 Pop ax ret ending ENDP CODES ENDS END Main



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.