Compare the four types of Interrupt commands that are common in data segments and additional segments and in Assembly

Source: Internet
Author: User

Compare the four types of Interrupt commands that are common in data segments and additional segments and in Assembly
1. input two strings of the same length from the keyboard, put them into the data segment and the additional segment, and use the string comparison command to compare the two strings in the Data Segment and the additional segment. If the two strings are the same, output Y, otherwise, N is output. This program has been debugged for a long time and has two problems. One is the use of the additional segment, which requires the adjustment of the DS pressure stack to ES, that is, 1 PUSH DS2 mov ax, ES 3 mov ds, AX4 ;...... 5 pop ds the second is that the string comparison command CMPSW compares words, while the CMPSB compares bytes and needs to be separated. (In fact, I still don't know why the character comparison fails even if it is a string composed of characters. Do you know why ?) The following is a program: 1 data segment 2 va db 50, 0, 50 DUP (0), '$' 3 V1 DB 'y' 4 V2 DB 'n' 5 enter db 0AH, 0DH, '$'6 data ends 7 DATA2 SEGMENT 8 vb db 50, 0, 50 DUP (0),' $'9 DATA2 ENDS10 CODE SEGMENT11 assume cs: CODE, DS: DATA, ES: DATA212 START: mov ax, DATA; load DS13 mov ds, AX14 mov ax, DATA2; load ES15 mov es, AX16 17 mov dx, offset va; input string VA18 mov ah, 0AH19 INT 21 H 20 21 push dx; press enter to wrap 22 mov dx, OFFSET ENTER23 mov ah, 09H24 INT 21H25 POP DX26 27 PUSH DS28 mov ax, ES; processing of additional segments 29 mov ds, AX30 mov dx, offset vb; input string VB31 mov ah, 0AH32 INT 21H33 POP DS34 35 push dx; press enter to wrap 36 mov dx, OFFSET ENTER37 mov ah, 09H38 INT 21H39 POP DX40 41 lea si, VA; send the source string address to SI42 PUSH DS43 mov ax, ES44 mov ds, AX45 lea di, VB; send the target string address to DI46 POP DS47 48 CLD; clear the direction mark, make forward 49 mov cx, 50; repeat counter 50 repe cmpsb; if equal, repeat. If CX is 0, or if not equal, run 51 JE J1; if equal, jump to 52 mov ah, 253 MOV DL, V254 INT 21H55 JMP J256 J1: mov ah, 257 mov dl, V158 INT 21H59 J2: mov ah, 4CH 60 INT 21H61 CODE ENDS62 end start 2. the following are four common types of interruptions: 1) input characters on the keyboard are interrupted Mov ah, 1 Int 21 h, and the result is the ASCII code of the input characters in the al workflow. 2) the screen displays an interrupted Mov ah, 2 Mov dl, And the ASCII code Int 21 h for the characters to be displayed. (Note: Here al will change to the ASCII code of the characters to be output.) 3) the format of the on-screen display string (called by function 9) is mov dx, the offset address of the string mov ah, 09 h int 21 H. When using the function call of function 9, pay attention to the following issues: ① The string to be displayed must first be placed in the memory data zone (DS segment) and use the '$' symbol as the end mark. ② The base address and offset address of the first string address should be stored in the DS and DX registers respectively. 4) keyboard input string (called by the 0AH function) Format: mov dx, the offset address of the defined buffer zone mov ah, 0AH INT 21 H ① define an input buffer before execution, the first byte in the buffer is defined as the maximum number of characters that can be entered, including the carriage return 0DH. The second byte is retained. After the program is executed, it stores the actual number of characters entered (excluding the carriage return ). The third byte is used to store the ASCII code of characters received from the keyboard. If the actual number of characters entered is less than the defined maximum number of characters, other units in the buffer zone are automatically cleared. If the number of characters entered is greater than the defined number of characters, the subsequent characters are discarded until the Enter key is entered. ② The base address and offset address of the first buffer address should be stored in the DS and DX registers respectively.

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.