Written in front: Also years have not updated the blog ... It's 21 years old. Look back and find the sophomore completely not updated blog ... Many reasons, one is the feeling of finishing blog although can deepen the understanding of learning to help a lot but still very much time, the benefits are relatively low, it is better to read more books brush problem, the other can be said to be the most important reason, big 21 years of comparative utilitarian, work learning is also very focused on cost-effective, Try to brush well and then bar a national scholarship, so rarely update the blog. This update records the last time we compiled the experiment, very basic but completely self-taught and then forcibly removed, the inner feeling is still very happy. Just feel that this is my state in a freshman, full-time to conquer a more difficult problem, godless on a whole day, the ultimate harvest of happiness is the brush performance points which are blind a few water can not be compared. All right, here's the text.
1.1 Experiment Content:
Set DATA1 begins with a string of signed Word data in a memory unit that requires a bubbling sorting algorithm (Bubble sort) to sort from small to large and to have the ordered data exist in a DATA1-starting unit. Then the output of the display in the order of the data, the middle with ', ' separated.
The sequencing takes the loop program.
The output data uses subroutine mode.
PS: Here the output is required to do subroutine, because as long as the output related to the display and ASCII, need to do a step binary to 10 binary and digital to ASCII conversion.
PPS: Flowchart did not pass up, because the relatively large transmission should not look good, refer to the source code behind the article is not difficult to draw a flowchart.
1.2 Algorithm Analysis:
This experiment content is relative to the previous several times, is more comprehensive, therefore we need to carry on the modularization analysis in the algorithm analysis, each individual module breaks down.
1.2.1 Bubble Sort :
there is a high-level language learning foundation for this content will not be unfamiliar, we completed two steps below, the first simple language to describe the bubble sort of ideas and algorithm steps, for the following assembly program to lay the groundwork, the second we give a bubbling sort of assembler flowchart.
1.2.1.1 bubble sorting algorithm idea:
The whole is divided into two layers of cycle, assuming that the first level of the indicator variable is i, the second layer indicates the variable is J, then according to the idea of bubble sequencing, our first layer of the cycle of the purpose is to put this array of the penultimate I The correct value of the position is determined, in order to complete the outer loop, the inner loop needs to scan the 0~n-i position of the array, compare the adjacent two positions, if the previous large, then one exchange.
The 1.2.1.2 pseudo-code is described as follows:
Bubble_sort (A) 1. For i = 0 to n-1 2. For j = 1 to N-i 3. If (A[j] > A[j-1]) 4. Exchange A[j] with a[j-1]
1.2.2 Output section:
According to the requirements of the topic, this is the way to use the sub-program output. That is, when we are outputting, we set up a loop control in the outer layer, and the output of each memory unit is in the form of a number of binary numbers.
The whole idea of 1.2.2.1 algorithm:
first of all, the overall consideration of this algorithm design needs to pay attention to what the problem, the topic is clearly given in the number of symbols, so that in the output of the time for the intuitive, we need to show the symbol '-', This requires the design of the algorithm to consider the number of positive or negative. Second, we also need to consider how to convert the number of machines to the corresponding decimal number, similar to the high-level language, we set the iterative process, using the DIV instruction, the original data more than 10 , and the remainder is taken out of the stack, and then the corresponding value (30H) to obtain the corresponding number of ASCII Code, and then output.
1.3 Code
1 DATAS SEGMENT2DATA DB2,1,0, -1,-23COUNT DB54 DATAS ENDS5 6 STACKS SEGMENT7 ; Enter the stack segment code here8 STACKS ENDS9 Ten CODES SEGMENT One assume Cs:codes,ds:datas,ss:stacks A START: - MOV Ax,datas - MOV Ds,ax the MOV CL, 0H - - - ; bubble sort Start + MOV CL, COUNT; outer loop indicator variable - Outloop: + MOV AL, CL; internal loop indicator Variable initialization A DEC AL at MOV CH, AL -MOV BX, OFFSET DATA +1; Data pointers - Inloop: -MOV AH, [bx-1] - MOV AL, [BX] - CMP AH, AL in JS Not_change - MOV [BX], AH toMOV [BX-1], AL + Not_change: - INC BX the DEC CH * jnz inloop $ DEC CLPanax NotoginsengCMP CL,1 - jnz outloop; bubble sort End the + ; start the output A the MOV BX, OFFSET DATA + MOV CL, COUNT - Print_loop: $ MOV AL, [BX] $ MOV AH, 00H - INC BX - Call Fun the DEC CL - JZ enddWuyi MOV AH, 02H theMOV DX,',' - INT 21H Wu and Cl, cl - jnz print_loop About $ endd: - MOV ah,4ch - INT 21H - A + the Fun PROC near -; MOV DL,Ten $ Shabi: the PUSH CX the MOV CL, 00H the and Al, Al the JNS POS - PUSH AX in MOV AH, 02H theMOV DX,'-' the INT 21H About POP AX the NEG AL the POS: theMOV DL,Ten +DIV DL; [ax]/TenAl is quotient, AH is the remainder - MOV DL, AH the and AH, 0H; free numberBayiADD DL, - the MOV DH, 00H the PUSH DX - INC CL - and Al, Al the jnz Shabi the the PRINT: the POP DX - MOV AH, 02H the INT 21H the DEC CL the jnz PRINT94 the POP CX the RET the Fun ENDP98 About CODES ENDS -END START
8086 compilation write bubbling sort and output results based on sub-programming