问题描述
好吧,我正在 MARS IDE 中编写 MIPS 程序集。我试图在位图显示中绘制一个圆,单位宽和高为 8,显示宽和高为 512。我大致了解并编写了一个矩形。但我想知道尝试和编码圆圈的最佳方法是什么?说中心在显示器的中间,我该如何编码?有没有办法知道我在哪一行哪一列?这是我目前所拥有的。
.eqv GRAY 0x999997 #hex value for gray
.eqv BLACK 0x000000 #hex value for black
.eqv WHITE 0xFFFFFF #hex value for white
.text
.globl main
main:
li $s0,BASEADRESS #save in $s0
li $s1,GRAY #save green in s1
li $s2,BLACK #save black in s2
li $s3,WHITE #save white in s3
#Initialize
li $t0,0 #load 0 into t0
li $t1,4096 #load 4096 into t1
move $t3,$s0 #store baseaddress in t3
drawRectangle:
#if current pixel >= 2048 and <= 3000 draw the color
li $t6,1023
li $t7,1500
sgt $t4,$t0,$t6 #If greater than 2048 true
slt $t5,$t7 #If less than 3000 true
and $t4,$t4,$t5 #If both true 1
bnez $t4,drawPixel #Draw gray pixel
#False branch
sw $s2,0($t3) #Stick black into the shape
addi $t3,$t3,4
add $t0,1
b drawRectangle
drawPixel:
sw $s1,0($t3)
addi $t3,4
add $t0,1
b drawRectangle
startLoop:
#test
slt $t4,$t1 #test to see if we have colored all 256 bits
beqz $t4,endLoop #if we have,end program
#Write the color to the display memory
sw $s1,0($t3) #Shove green into that value
#updates
addi $t3,4 #increment the base address by 4 to point to next pixel
add $t0,1 #Increment the index by 1
b startLoop #do the loop again
endLoop:
#End program
li $v0,10
syscall
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)