Practical training assembly language design-16-digit split into 4 groups

Source: Internet
Author: User

Practical training: In ax, 16 digits are divided into 4 groups (1234 divided into 1, 2, 3, 4), each group with 4 digits placed in Al, BL, Cl, DL

A:

Data Segment

Data ends

Cseg segment

Assume Cs: cseg, DS: Data

Start:

MoV ax, 1234 H

MoV cl, 4

MoV dx, ax

And dx, 0fh

MoV BX, ax

Shr bx, Cl

And BX, 0fh

MoV CH, BL

MoV BX, ax

Shr bx, Cl

Shr bx, Cl

And BX, 0fh

SHR ax, Cl

SHR ax, Cl

SHR ax, Cl

And ax, 0fh

MoV Cl, CH

And CX, 0fh

MoV BH, BL

MoV DH, DL

MoV DL, Al

Add DL, 40 h

MoV ah, 2

Int 21 h

MoV DL, BH

Add DL, 40 h

MoV ah, 2

Int 21 h

 

MoV DL, Cl

Add DL, 40 h

Int 21 h

MoV DL, DH

Add DL, 40 h

Int 21 h

MoV ah, 1

Int 21 h

Exit:

MoV ah, 4ch

Int 21 h

Cseg ends

End start

Output: ABCD (corresponding: Al = 01 H, BL = 02 h, CL = 03 h, DL = 04 H)

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.