码迷,mamicode.com
首页 > 编程语言 > 详细

汇编语言-显示九九乘法表

时间:2017-06-20 22:20:31      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:idp   mpi   ffd   poj   tmm   iam   boa   snr   imm   

1. 题目:以9行9列的形式显示九九乘法表

2. 要求:显示下三角格式如表4.1所示,也可以上三角格式显示。

技术分享
 1 ; Example assembly language program --
 2 ; Author:  Karllen
 3 ; Date:    revised 05/2014
 4 
 5 .386
 6 .MODEL FLAT
 7 
 8 ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
 9 
10 INCLUDE io.h            ; header file for input/output
11 
12 cr      EQU     0dh     ; carriage return character
13 Lf      EQU     0ah     ; line feed
14 
15 .STACK  4096            ; reserve 4096-byte stack
16         
17 .DATA                   ; reserve storage for data
18       
19        flaj     WORD ?
20        
21        
22        promot   BYTE "The program is to print the 9*9 table",cr,Lf,0
23        crlf     BYTE cr,Lf,0
24        char1    BYTE 1 DUP(?),0
25        char2    BYTE 1 DUP(?),0
26        me       BYTE  1 DUP(?),0
27 
28        mulzs    BYTE 1 DUP(?),0
29        brr      BYTE " ",0
30        sh       BYTE 1 DUP(?),0
31    
32       
33 .CODE                           ; start of main program code
34 _start:
35        mov  mulzs,2Ah
36        mov  me,3Dh
37        mov  bx,0
38        mov  char1,30h
39        doFirstWhile:
40               inc  bx
41               inc  char1
42               cmp  bx,9
43               jg   endFirstWhile
44               mov  flaj,1
45               mov  char2,31h
46               doSecondWhile:
47                    cmp flaj,bx
48                    jg  endSecondWhile
49                        mov    ax,bx
50                        mul    flaj
51                        mov    cx,flaj
52                        
53                        output char1
54                        output mulzs
55                        output char2
56                        output me
57                        cmp  ax,10
58                        jl   FindOne
59                             mov dl,10
60                             div dl
61                             mov sh,al
62                             add sh,‘0‘
63                             output sh
64                             mov  sh,ah
65                             add  sh,‘0‘
66                             output sh
67                             jmp  endTwo
68                        
69                        FindOne:
70                           mov  sh,al
71                           add  sh,‘0‘
72                           output sh
73                        endTwo:
74                           output brr
75                        inc    flaj
76                        inc    char2
77                        jmp    doSecondWhile
78               endSecondWhile:
79                        output crlf
80                        jmp    doFirstWhile  
81        endFirstWhile:
82         INVOKE  ExitProcess, 0  ; exit with return code 0
83 
84 PUBLIC _start                   ; make entry point public
85 
86 END                             ; end of source code
技术分享

 

 运行结果:

技术分享

 

汇编语言-显示九九乘法表

标签:idp   mpi   ffd   poj   tmm   iam   boa   snr   imm   

原文地址:http://www.cnblogs.com/xieyulin/p/7056429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!