Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG 100h
- MOV AH, 01h
- INT 21h ;Il numero letto è in AL
- SUB AL, 30H; sottraggo al numero letto 30 per ricavare il numero equivalente al codice ascii
- MOV BH, AL; bh : numero
- ;MOV CH, 0h; AZZERO CH : i
- MOV DH, 0h; dh : i
- MOV BL, 0h; bl : k
- MOV AH, 02h; metto 02h in AH per: write character to standard output. INT 21h / AH=02h
- ciclo:
- MOV DL, 0AH; caratteri per
- INT 21H
- MOV DL, 0DH; andare a capo
- INT 21H
- CMP DH,0 ; if( i == 0)
- JE printRigaPiena
- mov ch,dh
- inc ch
- CMP ch, BH ; if( i +1 == numero)
- MOV BL, 0
- JE printRigaPiena
- CMP DH, BH ; if( i < numero)
- JE fineProgramma
- MOV BL, 0h
- MOV DL, '*';
- int 21h
- JL printRigaInterna
- JE fineProgramma
- printRigaPiena:
- MOV DL, '*';
- int 21h
- INC BL
- CMP BH, BL; if(numero==k)
- JNE printRigaPiena
- INC DH; i++
- CMP BH,DH
- JL fineProgramma
- JMP CICLO
- printRigaInterna:
- MOV DL, ' ';
- int 21h
- INC BL; k++
- MOV CH, BH
- DEC CH
- DEC CH
- CMP CH, BL; if(numer-2==k)
- JNE printRigaInterna
- INC DH; i++
- MOV DL, '*';
- int 21h
- JMP CICLO
- fineProgramma:
- RET
- VS
- // QuadratoVuoto.cpp : definisce il punto di ingresso dell'applicazione console.
- //
- #include "stdafx.h"
- #include "conio.h"
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i,j,k;
- int numero;
- scanf("%d",&numero);
- for (i = 0; i < numero; i++) {
- printf("\n");
- if (i==0 || i+1==numero) {
- for(k=0; k<numero; k++) {
- printf("*");
- }
- }
- else{
- printf("*");
- for(k=0; k<numero-2; k++) {
- printf(" ");
- }
- printf("*");
- }
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement