精华区代码Revision-C版本[系列四]
程序代码:
;九九乘法口诀表 ;作者:神vLinux飘飘 ;Revision Declare Modified by zaixuexi ;*/ -------------------------------------------------------------------------------------- ;*/ source:http://www. ;*/ author:zaixuexi ;*/ date: 2011-11-28 ;*/ email: asmedu@ ;*/ revision declare: ;*/ 1.add self-estimated c source code. ;*/ 2.adjust all asm source code lower-case style. ;*/ 3.keep all original code designment. ;*/ 4.using tab alignment source code text. ;*/ -------------------------------------------------------------------------------------- ;typedef unsigned char uint8_t; ;typedef unsigned short int uint16_t; ;typedef unsigned int uint32_t; stack segment stack stack ends data segment author db "Write by vlinux$" ;const char *author = "Write by vlinux"; data ends code segment assume cs:code,ds:data,ss:stack _main: mov ch,1d ;uint8_t op2 = 1; _main_next_1: call _print_crlf ;printf("\n"); mov cl,1d ;uint8_t op1 = 1; _main_next_2: mov ah,0d mov al,cl ;uint16_t operand = MAKEWORD(op1, 0); call _print_int ;_print_int(operand); mov dl,42 mov ah,2 int 21h ;putchar('*'); mov ah,0d mov al,ch ;operand = MAKEWORD(op2, 0); call _print_int ;_print_int(operand); mov dl,61 mov ah,2 int 21h ;putchar('='); mov ah,0d mov al,cl mul ch ;operand = MAKEWORD(op1 * op2, 0); call _print_int ;_print_int(operand); call _print_tab ;printf("\t"); mov dl,ch inc dl inc cl ;op1++; cmp cl,dl jne _main_next_2 ;if (op1 != (op2 + 1)) goto _main_next_2; inc ch ;else op1++; cmp ch,10d jne _main_next_1 ;if (op2 != 10) goto _main_next_1; call _print_crlf call _print_crlf ;printf("\n\n"); mov ax,data mov ds,ax mov dx,offset author mov ah,9 int 21h ;puts(author); mov ah,4ch int 21h ;exit(0); _print_int: ;void _print_int(uint16_t operand); push ax push bx ;static uint8_t; push cx push dx pushf mov cx,10000d ;uint16_t divisor = 10000; mov bl,0d ;flag = 0; _print_int_next_1: cwd ;uint32_t dividend = MAKELONG(operand, 0); div cx ;uint16_t quotient = dividend / divisor; uint16_t remainder = dividend % k; push ax push dx cmp al,0d jne _print_int_flag_1 ;if (!LOBYTE(quotient)) goto _print_int_flag_1; cmp bl,0d je _print_int_flag_2 ;else if (flag == 0) goto _print_int_flag_2; _print_int_flag_1: mov ah,2 mov dl,al add dl,48 int 21h ;else putchar(LOBYTE(quotient) + 0x30); mov bl,1d ;flag = 1; _print_int_flag_2: mov ax,cx mov cx,10d cwd ;dividend = MAKELONG(divisor, 0); divisor = 10; div cx mov cx,ax ;divisor = dividend / divisor; pop ax pop dx cmp cx,1d jne _print_int_next_1 ;if (divisor != 1) goto _print_int_next_1; mov dl,al add dl,48 mov ah,2 int 21h ;else putchar(LOBYTE(quotient) + 0x30); popf pop dx pop cx pop bx pop ax ret _print_tab: ;printf("\t"); push ax push dx mov dl,9 mov ah,2 int 21h pop dx pop ax ret _print_crlf: ;printf("\n"); push ax push dx mov dl,10 mov ah,2 int 21h pop dx pop ax ret code ends end _main简评:程序思路清晰,不过进制符号没统一,会让人看的有点不爽.