Advertisement
Il_Voza

3.3 Multiplication table

May 12th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Write a program that is able to generate a multiplication table (10x10) and store it
  2.  
  3. DIM EQU 10
  4. .MODEL small
  5. .STACK
  6. .DATA
  7. matr DB DIM*DIM DUP (?)
  8. .CODE
  9. .STARTUP
  10. MOV DI,0
  11. MOV BX,0
  12. MOV CH,1
  13.  
  14. ciclo1:
  15.        MOV CL,1
  16.        ciclo2: ;into this cycle, CL change untile DIM, while CH is kept fixed
  17.               MOV AL,CH
  18.               MUL CL
  19.               MOV WORD PTR matr[BX][DI],AX
  20. ;o scrivo     MOV matr[BX][DI],AL
  21.               INC DI
  22.               INC CL
  23.               CMP DI,DIM
  24.               JNE ciclo2
  25.        MOV DI,0
  26.        INC BX
  27.        INC CH       ;It's as if CH flows in vertical on the rows and CL in horizontal on the columns
  28.                     ;i.e. is as if CH flows together with BX, and CL together with DI
  29.        CMP BX,DIM
  30.        JNE ciclo1
  31.  
  32.  
  33. MOV AH,2
  34. MOV DX,0
  35. MOV BX,0
  36. MOV SI,0
  37. print1:
  38.        print2:
  39.               MOV DL,matr[BX][SI]
  40.               ADD DL,'0'
  41.               INT 21h
  42.               INC SI
  43.               CMP SI,DIM
  44.               JNE print2
  45.        INC BX
  46.        MOV SI,0
  47.        CMP BX,DIM
  48.        JNE print1            
  49. .EXIT
  50. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement