Compile the switch_case Theory

Source: Internet
Author: User

Mystack segment Stack
DB 0ffh DUP (?)
Mystack ends
Mydata segment
Szcase0 dB 'case 0 $'
Szcase1 dB 'case 1 $'
Szcase2 dB 'case 2 $'
Szcase3 dB 'case 3 $'
Mydata ends
Mycode segment
Start:
MoV ax, mydata
MoV ds, ax
MoV es, ax

MoV ax, 3
MoV ah, 2; required
Mul ah
MoV BX, offset jmp_table
MoV Si, ax
JMP word PTR Cs: [bx + Si]

Case0:
MoV dx, offset szcase0
MoV ah, 9
Int 21 h
JMP switch_end
Case1:
MoV dx, offset szcase1
MoV ah, 9
Int 21 h
JMP switch_end
Case2:
MoV dx, offset szcase2
MoV ah, 9
Int 21 h
JMP switch_end
Case3:
MoV dx, offset szcase3
MoV ah, 9
Int 21 h
JMP switch_end
Switch_end:
MoV ax, 4c00h
Int 21 h

Jmp_table DW offset case0, offset case1,
Offset case2, offset case3
Mycode ends
End start

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.