My assembly language language

xiaoxiao2021-03-06  40

Assembly language board test report

1) Master multi-level programming using jump table

2) Master the comprehensive design capability of assembly language procedures

3) Master the basic method of assembling language commissioning using DEBUG

Content: Writing Program implements the following 5 functions (optional 3), enters menu selection by input from the keyboard 1 ~ 5:

1. Press the number button "

1

"

, Complete transformation of lowercase letters in the string to uppercase letters. The user inputs a string of English case or numbers 0 to 9 (ends in the back of the car). After the transformation is displayed in the following format: , for example: abcdgyt0092 Abcdgyt0092 Press any key to recall, press the ESC key to return to the main menu.

2. Press the numeric key "2" to complete the maximum value in the string. The user inputs a string of alphabet and numbers 0 to 9 with English case (end). After finding the maximum, press the following format on the screen: The maximum is Press any key to recall, press the ESC key to return to the main menu.

3. Press the numeric key "3" to complete the sort of the input data group. The user enters a set of decimal values ​​(less than 255), then converts to hexadecimal numbers, and sorts them in increasing mode, displayed on the screen below: Press any key to reconcile, Press the ESC button to return to the main menu.

4. Press the numeric key "4" to complete the display. First, remind the user to change the timer HH: mm: SS (end of the cargo, the end of the carriage return), and then display time on the screen: hh: mm: ss Press any key to returns, press ESC to return main menu.

5. Press the number key "5", end the operation of the program, return to the operating system.

programming:

The use of each sub-function is designed to a subroutine, and the main program is called each subroutine to complete various functions. Use the jump table to call the subroutine.

Designed to complete features 1, 2, 4, and 5.

***************************************

StrDisp macro _string; macro displaying strings

Lea dx, _string

Mov Ah, 09h

Int 21h

ENDM

************************************************************ *****

Stack Segment Stack

DW 0FFH DUP (?)

Top Label Word

Stack ends

Data segment

Mainmenu DB 0DH, 0AH, 'Please Select:', 0DH, 0AH,

'1.Transform Lower to Upper', 0DH, 0AH,

'2.Find the max', 0DH, 0AH,

'3.Transform Dec to Hex and sort (undone)', 0DH, 0AH,

'4.change Time', 0DH, 0AH,

'5.exit', 0DH, 0AH,

'Input Your Choice: $'

STRSUB1 DB 0DH, 0AH, 'PLEASE INPUT STRING:', 0DH, 0AH, '$'

STRSUB2 DB 'PRESS ESC to EXIT, PRESS Anyhey To Continue ...', '$' STRBUF DB 40H DUP (?)

Table DW proc1; jump table

DW proc2

DW Proc3

DW proc4

DW proc5

CLRF DB 0DH, 0AH, '$'

Data ends

Codem segment

Assume CS: Codem, DS: Data, SS: Stack, ES: DATA

Main

: MOV AX, DATA

MOV DS, AX

Again: STRDISP Mainmenu; Show main menu

MOV AH, 01H; read into user selection

Int 21h

SUB Al, 30h; convert characters to numbers

CMP

Al

,1

JB Again

CMP

Al

, 5

Ja Again

Sub

Al

,1

SHL

Al

,1

CBW

MOV BX, AX

JMP Table [BX]

Proc1: Call Far PTR Upper; Call Proc1

JMP Again

Proc2: Call Far Ptr Maximum; Call Proc2

JMP Again

PROC3: NOP; Call Proc3

JMP Again

Proc4: Call Far PTR Settime; Call Proc4

JMP Again

Proc5: JMP EXIT

EXIT: MOV AH, 4CH

Int 21h

Codem Ends

************************************************************ **********

Code1 segment

Assume CS: Code1, DS: Data

Upper proc

FAR

Push dx

PUSH CX

Push BX

Push AX

Push Si

Push di

Mov AX, DATA

MOV DS, AX

Again1: strDisp strsub1; output 'please input string:'

MOV BYTE PTR STRBUF, 40H

Lea DX, Strbuf

MOV AH, 0AH; Enter strings to strbuf

Int 21h

MOV Al, Strbuf 1;

Add Al, 1

CBW

LEA SI, STRBUF 2

Add Si, AX

MOV BYTE PTR [Si], '$'

MOV CX, AX

LOOP1: MOV BX, CX; cycle reduction write letters to uppercase letters

CMP Byte Ptr strbuf [bx], 'a'

JB DONE

CMP Byte Ptr strbuf [bx], 'z'

Ja Done

Sub Byte Ptr strbuf [bx], 20h

DONE: loop loop1; loop

STRDISP CLRF; Enter Renewal

LEA DX, STRBUF 2

MOV AH, 09H; String INT 21H after output conversion

STRDISP CLRF

STRDISP STRSUB2

MOV AH, 07H

Int 21h

CMP Al, 01BH; Judging whether the user input is ESC

JZ EXIT1; if it exits the subroutine

JMP Again1

EXIT1: POP DI

POP Si

POP AX

POP BX

POP CX

POP DX

RET

Upper endp

Code1 Ends

************************** Sub function 2 ******************* **********

Sub2Data segment

Sub2Str1 DB 'please inout String:', 0DH, 0AH, '$'

Sub2Str2 DB 'Press Esc To EXIT, PRESS ANYKEY TO Continue ... $'

SUB2STR3 DB 'The maximum is: $'

SUB2STR4 DB 0DH, 0AH, '$'

SUB2BUF DB 40H DUP (?)

Sub2Data Ends

Code2 segment

Assume Cs: Code2, DS: Sub2Data, ES: Sub2Data

Maximum Proc Far

Push dx

PUSH CX

Push BX

Push AX

Push DS

Push ES

Push Si

Push di

MOV AX, Sub2Data

MOV DS, AX

Mov ES, AX

Sub2again:

STRDISP SUB2STR4; output carriageway

STRDISP SUB2STR1; Output 'Please Inout String:'

MOV BYTE PTR SUB2BUF, 40H

LEA DX, SUB2BUF

MOV AH, 0AH; Enter strings to SUB2BUF

Int 21h

MOV Al, Sub2Buf 1

CBW

MOV CX, AX; the length of string

Lea Si, Sub2Buf 2

Add Si, AX

MOV BYTE PTR [Si], '$'

Lea Di, Sub2Buf 2

SUB DI, 1

MOV

Al

0

CLD

LOOPSUB2: ScaSB; Scan string, scaSB uses Al to reduce the value of ES: [DI] points to the value setting flag

CMP Al, ES: [DI]

Ja loopsub2nd; al> es: [di] jump to loopsub2nd

MOV Al, ES: [Di]; Al

Loopsub2end:

Loop

Loopsub2

CBW

Push AX

STRDISP SUB2STR4; output carriageway

STRDISP SUB2STR3; Output 'The Maximum IS: $'

POP AX

MOV DL, Al

MOV AH, 02H; Output Maximum Character

Int 21h

STRDISP SUB2STR4; Output Enter Covenible STRDISP SUB2STR2; Output End Tips

MOV AH, 07H; Read button

Int 21h

CMP AL, 01BH; Compare with ESC

JZ EXIT2;

JMP sub2again; no, jump to the beginning, loop

EXIT2: POP DI

POP Si

POP ES

POP DS

POP AX

POP BX

POP CX

POP DX

RET

Maximum ENDP

Code2 Ends

***************************************

Trans Macro_Seg ,_Memo; Macro: Convert binary number to digital characters

MOV

Al

_Seg

CBW

Div Ten

Add Ah, THIRTY

Add

Al

, Thidy

Mov_Memo,

Al

Mov_Memo 1, AH

ENDM

Dectobin macro _Memory, _SEGMENT; macro: convert two decimal numbers into binary

MOV

Al

_Memory

Sub

Al

, Thidy

Mul Byte Ptr Ten

Add Al, _Memory 1

Sub

Al

, Thidy

Mov_Segment,

Al

ENDM

************************************************************ *************

Sub4Data segment

Hour db '00 $ '

Minute db '00 $ '

SECOND DB '00 $ '

COLON

DB ': $'

Ten DB 10D

ThiRTY DB 30H

SUB4STR1 DB 'TIME: $'

Strend DB 'Press Esc to EXIT, PRESS Anyother Key To Continue ... $'

CLRF4 DB 0DH, 0AH, '$'

TimeBuf DB 12, 8, 'HH: mm: ss $'

Subst2 DB 'please Inputt The Time (HH: mm: SS): $'

Substr3 DB 'Do You Want To Reset Time (Y / N)? $'

Subst4 DB 'SetTime Error $'

Sub4Data Ends

Code4 segment

Assume CS: Code4, DS: Sub4Data, ES: Sub4Data

SetTime Proc Far

Push dx

PUSH CX

Push BX

Push AX

Push DS

Push ES

Push Si

Push di

Mov AX, Sub4Data

MOV DS, AX

Mov ES, AX

SUB4AGAIN:

STRDISP CLRF4

MOV AH, 2CH; Take the system time

Int 21h

Trans Ch, Hour

Transcl, Minute

TRANS DH, SECOND

STRDISP SUB4STR1; display time

STRDISP HOURSTRDISP

COLON

STRDISP Minute

STRDISP

COLON

STRDISP Second

STRDISP CLRF4

STRDISP SUBSTR3

Mov Ah, 01; Input a letter INTO

Al

Int 21h

CMP Al, 'Y'

Je Resettime

CMP

Al

'Y'

JNE NoreSetTime; if

Al

Is Not 'Y' or 'Y' Then End

RESETTIME:

STRDISP CLRF4

STRDISP SUBSTR2

Lea DX, TIMEBUF

MOV AH, 0AH; Input the Time String

Int 21h

Dectobin TimeBuf 2, CH

DECTOBIN TIMEBUF 5, CL

Dectobin TimeBuf 8, DH

MOV AH, 2DH; SET TIME

Int 21h

CMP Al, 0; judgment whether or not set up success

JZ Sub4Again; Al is 00 successful, failure for 0FF

STRDISP CLRF4

STRDISP SUBSTR4; Display Error Information

JMP Sub4Again

NoresetTime:

STRDISP CLRF4

STRDISP STREND

MOV AH, 07H; Read button

Int 21h

CMP AL, 01BH; Compare with ESC

JZ EXIT4;

JMP sub4again; no, jump to the beginning, loop

EXIT4: POP DI

POP Si

POP ES

POP DS

POP AX

POP BX

POP CX

POP DX

RET

SETTIME ENDP

Code4 Ends

End

Main

转载请注明原文地址:https://www.9cbs.com/read-77359.html

New Post(0)