loops - How to draw a square with dimensions given by the user in Assembly language? -
i have far, think problem in code lies in how screen clears? also, if use "mov ah, 7 & int 21h" getch(), work if variables compare them byte-sized, while "mov ah, 0 & int 16h" works when variables word-sized?
.model tiny .code org 100h project: call clearscreen mov ah, 0 int 16h mov xlimit, ax ; number of "rows" mov ah, 0 int 16h mov ylimit, ax ; number of "columns" call border int 20h clearscreen: mov ah, 7 mov al, 25 mov ch, 0 mov cl, 0 mov dh, 24 mov dl, 79 int 10h mov ah, 2 mov bh, 0 mov dh, 0 mov dl, 0 int 10h ret ; ---------------------------------------------------- border: mov dh, 0 mov dl, 0 mov ah, 2 int 10h mov dl, 95 int 21h mov cx, xlimit bucle: mov dl, cl mov dh,0 int 10h mov dl, 95 int 21h mov dx, ylimit mov dh, dl mov dl, cl int 10h mov dl, 95 int 21h loop bucle mov cx, ylimit xor dh, dh bucle2: mov dl, 0 mov dh, cl int 10h mov dl, 95 int 21h mov dx, xlimit mov dh, cl int 10h mov dl, 95 int 21h loop bucle2 ret ; --------------------------------------------------- ; global variables ylimit dw ? xlimit dw ? end project
mov ah, 0 int 16h mov xlimit, ax ; number of "rows"
this code waits until key pressed , gives ascii in al , scancode in ah. meaningful number have convert number.
if p.e. type character "1" "9" convert subtracting 48 al , storing in xlimit. continu using limits word clear ah before storing xlimit.
mov ah, 0 int 16h sub al, 48 cbw mov xlimit, ax ; number of "rows"
this comment should read number of columns
bonus: clearscreen routine needs parameter before calling bios.
clearscreen: mov ah, 7 mov al, 25 mov bh, 07h ;attribute blanked area, whiteonblack mov ch, 0 mov cl, 0 mov dh, 24 mov dl, 79 int 10h mov ah, 2 mov bh, 0 mov dh, 0 mov dl, 0 int 10h ret
Comments
Post a Comment