3 cases of credit conversion

xiaoxiao2021-03-06  70

1, the keyboard input N hexadecimal data, one bit (0 ~ f), accumulate it, and stored in the SUM unit; if the number of input non-hetex is ended; the value of the SUM unit will be Use the hexadecimal data to go out.

data segment num db? adtab dw addr1, addr2, addr4, addr8 tb1 db 'I am student2 $' tb2 db 'You are students3 $' tb4 db 'You are students5 $' tb8 db 'You are students9 $' next db 0dh, 0AH, '$' Data Ends

Code Segment Assume CS: Code, DS: DataStart: Mov AX, Data MoV DS, AX MOV AH, 01H INT 21h Sub Al, 30H MOV NUM, Al Lea DX, Next MOV AH, 09H INT 21H MOV Al, Num Lea BX, Adtablop: SHR AX, 1 JNC NXT JMP WORD PTR [BX] NXT: Add BX, Type Adtab JMP LOP

Addr1: Lea DX, TB1 MOV AH, 09H INT 21H JMP EXIT

Addr2: Lea DX, TB2 MOV AH, 09H INT 21H JMP EXIT

Addr4: Lea DX, TB4 MOV AH, 09H INT 21H JMP EXIT

Addr8: Lea DX, TB8 MOV AH, 09H INT 21h

EXIT: MOV AH, 4CH INT 21HCODE Ends End Start

2, keyboard input N hexadecimal data, one bit (0 ~ f), accumulate it, and stored in the SUM unit; if the input is not a hetex number, the value of the SUM unit Live the bank with binary data. Data Segment Num DB? TABLE DB?,?,?,? next db 0dh, 0ah, '$' Count DW 0DATA ENDS

Code Segment Assume CS: Code, DS: DataStart: Mov AX, Data MoV DS, AX LOP: MOV AH, 01H INT 21H CMP AL, 0DH JZ OUTPUSH0 CMP AL, '0' JB Other CMP Al, '9' Ja Other Sub Al, 30H NEG Al Add Al, 30H Mov Si, Count Mov Table [Si], Al Mov CX, Count Add CX, 1 MOV Count, CX JMP Lopother: Mov Si, Count Mov Table [Si], Al Mov CX, Count Add CX, 1 MOV Count, CX JMP LOP OUTPUSH0: LEA DX, NEXT MOV AH, 9 INT 21h MOV CX, 0 MOV Count, CX MOV BX, 4OUTPUSH: CMP BX, Count JZ EXIT MOV SI, Count MOV DL, TABLE [ Si] MOV AH, 2 INT 21h MOV CX, Count Add CX, 1 MOV Count, CX JMP Outpushexit: MOV AH, 4CH INT 21HCODE Ends End S Tart

3, the keyboard inputs 4 hexadecimal data, outputs its corresponding binary number.

Data Segment Number0 DB? Number1 DB? TB1 DB 0DH, 0AH, 'Jan', 0DH, 0AH, '$' TB2 DB 0DH, 0AH, 'FAB', 0DH, 0AH, '$' TB3 DB 0DH, 0AH, 'Mar ', 0DH, 0AH,' $ 'TB5 DB 0DH, 0AH,' MAY ', 0DH, 0AH,' $ 'TB6 DB 0DH, 0AH,' Jun ', 0DH, 0AH,' $ 'TB7 DB 0DH, 0AH,' JLY ', 0DH, 0AH,' $ 'TB8 DB 0DH, 0AH,' Aug ', 0DH, 0AH,' $ 'TB9 DB 0DH, 0AH, 'SEP', 0DH, 0AH, '$' TB10 DB 0DH, 0AH, 'Oct', 0DH, 0AH, '$' TB11 DB 0DH, 0AH, 'NOV', 0DH, 0AH, '$' TB12 DB 0DH, 0AH , 'DEC', 0DH, 0AH, '$' NEXT DB 0DH, 0AH, '$' MSG DB 'Input A Function Number (1 ~ 12), End with "Enter":', '$' Errmsg DB 0DH, 0AH , 'Invalid function number.', 0dh, 0ah, '$' AddrTbl dw func0, Func1, Func2, Func3, Func4, Func5, Func6, Func7, Func8, Func9, Func10, Func11data endscode segment assume cs: code, ds: datastart : MOV AX, Data MoV DS, AX Lea DX, MSG MOV AH, 9 INT 21h MOV AH, 1 INT 21h MOV Number0, Al Mov AH, 1 INT 21H MOV NUMBER1, Al Mov Al, Number1 CMP AL, 0DH JZ EQU1 Add Al, 10 JMP Equalequ1: MOV Al Number0equal: CMP Al, '0' JC Error CMP Al, '<'

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

New Post(0)