提交 53d34f1c 创建 作者: 赵鹏翀's avatar 赵鹏翀

init template

上级
/*.img
/bochs
/Debug
/Release
bochsout.txt
\ No newline at end of file
<?xml version="1.0" encoding="gb2312"?>
<ASMProject Version="1.00" Name="Demo053">
<Configurations>
<Configuration Name="Debug" ConfigurationType="2">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool"/>
<Tool Name="JWASMAssemblerTool" ObjectFormate="5" GenerateDebugInformation="-1" AdditionalOptions="/W0" VersionDebugInfo="-1"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool"/>
<Tool Name="JWlinkLinkerTool" AdditionalOptions="disable 1014"/>
<Tool Name="PostBuildEventTool"/>
</Configuration>
</Configurations>
<Files>
<Filter Name="Դļ" Filter="asm">
<File RelativePath=".\main.asm">
</File>
</Filter>
</Files>
</ASMProject>
添加文件
assume cs:codesg
data segment
dw 0,30,60,90,120,150,180
table dw ag0, ag30, ag60, ag90, ag120, ag150, ag180 ;字符串偏移地址表
ag0 db 'sin(0)=0', 0 ;sin(0)对应的字符串“0”
ag30 db 'sin(30)=0.5', 0
ag60 db 'sin(60)=0.866', 0
ag90 db 'sin(90)=1', 0
ag120 db 'sin(120)=0.866', 0
ag150 db 'sin(150)=0.5', 0
ag180 db 'sin(180)=0', 0
data ends
codesg segment
start:
mov ax, data
mov ds, ax
mov bx, 0
mov cx, 7
s:
mov ax, [bx]
call showsin
inc bx
inc bx
loop s
mov ax, 4c00h
int 21h
showsin: ;用ax向子程序传递角度
jmp short show
show:
push bx
push es
push si
mov bx, 0b800h
mov es, bx
mov ah, 0 ;以下用角度/30作为相对于table的偏移,取得对应的字符串的偏移地址,放在bx中
mov bl, 30
div bl
mov bl, al
mov bh, 0
add bx, bx
;mov bx, table[bx]
mov bx, [ds:table+bx]
mov si, 160*12+40*2 ;以下显示sin(x)对应的字符串
shows:
mov ah, ds:[bx]
cmp ah, 0
je showret
mov es:[si], ah
inc bx
add si, 2
jmp short shows
showret:
call clear ;调用清屏子程序
pop si
pop es
pop bx
ret
clear: ;清屏
push bx
push cx
push es
mov bx, 0b800h
mov es, bx
mov bx, 0
mov cx, 2000
clears:
mov byte ptr es:[bx], ' '
add bx, 2
loop clears
pop es
pop cx
pop bx
ret
codesg ends
end start
\ No newline at end of file
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论