首页 > 解决方案 > 装配:无法在图形模式下绘制正方形

问题描述

我在汇编中编写了该代码:

[bits 16]
[org 0x7c00]

mov ah, 0   ;
mov al, 13h ; set graphic mode
int 10h     ; 

mov cx, sx 
mov dx, sy  
mov ah, 0ch 

colcount:
inc cx
int 10h
cmp cx, hh
jne colcount

mov cx, sx  
inc dx      
cmp dx, ww
jne colcount

;;; vars section
sx dd 0     ;start x position
sy dd 0     ;start y position
hh dd 30    ;height
ww dd 30    ;width

times 510 - ($ - $$) db 0x0
dw 0xaa55

我希望这段代码在屏幕的左上角绘制一个正方形,但它只在中间绘制一个矩形。
我不知道问题出在哪里。
我使用 nasm 作为编译器,没有任何错误消息。
我从这里获取了部分代码,感谢YonBruchim

标签: assemblygraphicsx86nasm

解决方案


推荐阅读