Compilation-Sequencing experiment

Source: Internet
Author: User

I. PURPOSE of INTERNSHIP

The idea and method of writing program in assembly language with Palm grip.

Second, the Internship content

from the first address to 1000H Start Storage Ten Number , which requires the design program to order these numbers from small to large, sorted by the number is still placed at the original address.

Third, the Code

Data segment Count DB 10;   Array db 12,34,56,21,234,54,45,58,96,14; Msgone db ' The source array number is: ', ' $ ' msgtwo db 0AH,0DH, ' the sorted array number is: ', ' $ ' c10 db 10;dat A endsmystack segment stack db DUP (?)  Mystack Endscode segment assume Ds:data,cs:codestart:mov ax,data;  MOV ds,ax;          Lea Dx,msgone;  Output sorted before the array mov ah,09h;  int 21h;  MOV ch,0;  MOV cl,count;  mov Bx,0;outputsource:mov ah,0;  mov AL,ARRAY[BX];    Call Printnum;  mov dl, ' mov ah,02h;    int 21h;  Inc BX;        Loop Outputsource Lea Si,array;  Set parameters, call sort function mov ch,0;  MOV cl,count;    Call Mysort;        Lea Dx,msgtwo;  Output sorted after the array mov ah,09h;  int 21h;  MOV ch,0;  MOV cl,count;  mov Bx,0;outputsortedarray:mov ah,0;  mov AL,ARRAY[BX];    Call Printnum;  mov dl, ' mov ah,02h;    int 21h;  Inc BX;  Loop Outputsortedarray mov ax,4c00h;         int 21h;mysort proc;  Array sorting, the array offset address in SI, and the number of array elements stored in CX push ax;  Push CX;  Dec CX;  MOV Ax,0;loopone:push CX; Push SI      Looptwo:mov Al,byte Ptr[si];      CMP al,byte Ptr[si + 1];            Jbe Next;        Xchg Al,[si + 1];     Xchg Al,[si];    Next:inc si;  Loop looptwo pop si;  Pop CX;  Loop Loopone pop cx;  Pop ax;       Retprintnum proc;  Export the numbers stored in AL to the decimal form of push ax;  Push DX;  Push CX;  mov Cx,0;trantochar:mov ah,0;  CMP al,0;    JZ Outtrantochar;  Div C10;  MOV Dl,ah;  MOV dh,0;    Push DX;  Inc CX;  JMP Trantochar;  OUTTRANTOCHAR:CMP cx,0;  JZ exit_printnum Print:pop DX;  Add dx,30h;  MOV ah,02h;  int 21h;  Loop print Exit_printnum:pop CX;  Pop dx;  Pop ax;  Ret Code endsend Start

Iv. Results of operation



Compilation-Sequencing experiment

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.