Training assembly language design-Enter 1-12 to display the abbreviated month

Source: Internet
Author: User

Enter 1-12 to display the abbreviated month

Title home
Datasg segment
Three DB 3
Monin DB 3, 4 DUP (?)
Alfmon db '??? ',' $'
Montab dB 'jna ', 'feb', 'mar', 'apr', 'may', 'jun'
DB 'jul', 'aug', 'sept', 'oct', 'nov', 'dec'
Datasg ends
Codesg segment para 'code'
Assume Cs: codesg, DS: datasg, ES: datasg
Main proc far
PUSH DS
Sub ax, ax
PUSH AX
MoV ax, datasg
MoV ds, ax
MoV es, ax
L1: mov ah, 0ah
Int 21 h
Cmp dl, 3
JZ exit

Call Input
Call locate
Call display
MoV ah, 2
MoV DL, 0ah; implements carriage return and line feed
Int 21 h
MoV DL, 0dh
Int 21 h
JMP L1
Exit: Ret
Main endp

Input proc near
Push DX
MoV ah, 0ah
Lea dx, Monin
Int 21 h
MoV ah, Monin + 2
MoV Al, Monin + 3
XOR ax, 3030 H
CMP ah, 00
JZ return
Sub ah, ah
Add Al, 10
Return: Pop DX
RET
Input endp
 
Locate proc near
Push Si
Push di
Push CX
Lea Si, montab
Dec al
Mul three
Add Si, ax
MoV CX, 03
ClD
Lea Di, alfmon
Rep movsb
Pop CX
Pop di
Pop Si
RET
Locate endp

Display proc near
Push DX
Lea dx, alfmon
MoV ah, 09
Int 21 h
Pop DX
RET
Display endp
 
Codesg ends

End main

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.