infinite loop - Printing multiple triangles on MASM x86 (16 bit) -


so trying write program in masm x86 (8086) printout series of right triangles built of asterisks “”. using loops print out triangles. trying make each of triangles 3 9 asterisks high , same number across, in different configurations. got print 1 triangle though. after 1st triangle printed, keeps looping asterisks "" indefinitely. here of code:

 mov ah, 09h ;prints string   mov dx, offset input   int 21h    mov ah, 01h ;reads in character   int 21h    sub al, '0' ;is gunna read lower half default   mov ah, 0 ;blanking higher half of register way doesnt throw off program   mov size, ax   mov cx, ax    mov bx, cx    push bx    mov ah, 02h   mov dl, 13   int 21h     mov dl, 10   int 21h    lines:     push cx     stars:    mov ah, 02h    mov dl, '*'    int 21h     loop stars     mov ah, 02h   mov dl, 13   int 21h     mov dl, 10   int 21h    pop cx     loop lines    mov bx, size     mov ax, 4c00h   int 21h 

im guessing have create register hold variable , possibly create loop.
question is, have pass user input register? , if so, how can pass it?

you've put user input in size variable, that's fine.
after 1st triangle drawn put variable in cx register, change bit (more or less) , repeat code triangle:

; first user defined triangle      mov ah, 02h     mov dl, 13     int 21h       mov dl, 10     int 21h lines:     push cx  stars:     mov ah, 02h     mov dl, '*'     int 21h     loop stars      mov ah, 02h     mov dl, 13     int 21h       mov dl, 10     int 21h     pop cx      loop lines  ; take size , change bit      mov cx, size     add cx, 5  ; second bigger triangle      mov ah, 02h     mov dl, 13     int 21h       mov dl, 10     int 21h lines:     push cx  stars:     mov ah, 02h     mov dl, '*'     int 21h     loop stars      mov ah, 02h     mov dl, 13     int 21h       mov dl, 10     int 21h     pop cx      loop lines 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -