Simple Program Design experiment

Source: Internet
Author: User
Tags mul
1. Compile the computing program

Data Segment

X dB 29

Y dB 8

Z dB 25

F DW?

Data ends

Code segment

Assume DS: data, CS: Code

Main proc far

Start: PUSH DS

Sub ax, ax

PUSH AX

MoV ax, data; data segment register DS Initialization

MoV ds, ax

 

MoV Al, X; MoV Al x

Mul y; Mul completes the x * Y operation and stores the result in ax.

MoV BH, 0

MoV BL, Z

Add ax, BX; complete x * Y + z

Sub ax, 500

MoV F, ax; sub final ax is sent to F

 

RET

Main endp

Code ends

End start

2. Implement logic circuit Functions

Stacka segment Stack

DB 100 DUP (?)

Stacka ends

Data Segment

In1 dB 201711b

In2 dB 10101010b

In3 dB 111111b

In4 dB 11111011b

F DB?

Data ends

Code segment

Assume DS: data, CS: Code

Main proc far

Start: PUSH DS

Sub ax, ax

PUSH AX

MoV ax, data; data segment register DS Initialization

MoV ds, ax

 

MoV Al, in1

Not al

MoV ah, in2

Or Al, ah

MoV BL, in3

And BL, in4

XOR Al, BL

MoV F, Al

 

RET

Main endp

Code ends

End start

3. Compile a 32-bit unsigned number division program

Stacka segment Stack

DB 100 DUP (?)

Stacka ends

Data Segment

Num1 dd 2a8b7654h

Num2 DW 5 abch

Num3 DW?

Num4 DW?

Data ends

Code segment

Assume DS: data, CS: Code

Manum proc far

Start: PUSH DS

Sub ax, ax

PUSH AX

MoV ax, data; data segment register DS Initialization

MoV ds, ax

 

MoV ax, word PTR num1

MoV dx, word PTR num1 + 2

Div num2

MoV num3, ax

MoV num4, DX

 

RET

Manum endp

Code ends

End start

4. Compile a "word splitting" program

Stacka segment Stack

DB 100 DUP (?)

Stacka ends

Data Segment

Ary dB 12 h

Data ends

Code segment

Assume DS: data, CS: Code

Manum proc far

Start: PUSH DS

Sub ax, ax

PUSH AX

MoV ax, data; data segment register DS Initialization

MoV ds, ax

 

MoV Si, offset ary

MoV ah, 0

MoV Al, [Si]

MoV BL, 10 h

Div BL

MoV [Si + 1], Al

MoV Al, [Si]

And Al, 0fh

MoV [Si + 2], Al

 

RET

Manum endp

Code ends

End start

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.