Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. ORG 100h
  2.  
  3. MOV AH, 01h
  4. INT 21h ;Il numero letto è in AL
  5.  
  6. SUB AL, 30H; sottraggo al numero letto 30 per ricavare il numero equivalente al codice ascii
  7.  
  8. MOV BH, AL; bh : numero
  9.  
  10. ;MOV CH, 0h; AZZERO CH : i
  11.  
  12. MOV DH, 0h; dh : i
  13.  
  14. MOV BL, 0h; bl : k
  15.  
  16.  
  17. MOV AH, 02h; metto 02h in AH per: write character to standard output. INT 21h / AH=02h
  18.  
  19. ciclo:
  20. MOV DL, 0AH; caratteri per
  21. INT 21H
  22. MOV DL, 0DH; andare a capo
  23. INT 21H
  24.  
  25. CMP DH,0 ; if( i == 0)
  26. JE printRigaPiena
  27. mov ch,dh
  28. inc ch
  29. CMP ch, BH ; if( i +1 == numero)
  30.  
  31. MOV BL, 0
  32. JE printRigaPiena
  33.  
  34.  
  35. CMP DH, BH ; if( i < numero)
  36. JE fineProgramma
  37. MOV BL, 0h
  38. MOV DL, '*';
  39. int 21h
  40. JL printRigaInterna
  41.  
  42. JE fineProgramma
  43.  
  44. printRigaPiena:
  45.  
  46. MOV DL, '*';
  47. int 21h
  48. INC BL
  49. CMP BH, BL; if(numero==k)
  50. JNE printRigaPiena
  51. INC DH; i++
  52. CMP BH,DH
  53. JL fineProgramma
  54. JMP CICLO
  55.  
  56. printRigaInterna:
  57.  
  58. MOV DL, ' ';
  59. int 21h
  60. INC BL; k++
  61. MOV CH, BH
  62. DEC CH
  63. DEC CH
  64. CMP CH, BL; if(numer-2==k)
  65.  
  66. JNE printRigaInterna
  67. INC DH; i++
  68. MOV DL, '*';
  69. int 21h
  70. JMP CICLO
  71.  
  72. fineProgramma:
  73. RET
  74.  
  75.  
  76. VS
  77.  
  78.  
  79.  
  80. // QuadratoVuoto.cpp : definisce il punto di ingresso dell'applicazione console.
  81. //
  82.  
  83. #include "stdafx.h"
  84. #include "conio.h"
  85.  
  86.  
  87. int _tmain(int argc, _TCHAR* argv[])
  88. {
  89. int i,j,k;
  90. int numero;
  91.  
  92. scanf("%d",&numero);
  93.  
  94. for (i = 0; i < numero; i++) {
  95.  
  96. printf("\n");
  97.  
  98. if (i==0 || i+1==numero) {
  99.  
  100. for(k=0; k<numero; k++) {
  101.  
  102. printf("*");
  103.  
  104. }
  105.  
  106. }
  107.  
  108. else{
  109. printf("*");
  110.  
  111. for(k=0; k<numero-2; k++) {
  112.  
  113. printf(" ");
  114.  
  115. }
  116.  
  117. printf("*");
  118. }
  119.  
  120. }
  121.  
  122. getch();
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement