我如何在 TASM 中解决 "Assuming data segment is 32-bit"
How do I solve "Assuming data segment is 32-bit" in TASM
我下面有这个程序,它使用 DOSBox 计数为 100。
它与 .286 完美配合,但我想知道我怎样才能使它与 .386 配合使用。
.286
.model small
setCurPos macro x,y
pusha
mov ah, 02h
mov bh, 0
mov dl, x
mov dh, y
int 10h
popa
endm
writeChar macro char,color,ctr
pusha
mov ah, 9
mov al, char
mov bh, 0
mov bl, color
mov cx, ctr
int 10h
popa
endm
delay macro
mov cx, 0fh
mov dx,4240h
mov ah,86h
int 15h
endm
.stack 100h
.data
percentage db 0
ones db ?
tens db ?
.code
org 100
main proc far
mov ax, @data
mov ds, ax
mov es, ax
mov ah, 0
mov al, 13h
mov bh, 0
int 10h
jmp count
to_printHundred:
jmp printHundred
count:
delay
cmp percentage, 64h
je to_printHundred
cmp percentage, 0ah
jae printTens
;printOnes
mov al, percentage
add al, 30h
mov ones, al
setCurPos 10, 10
writeChar ones, 0fh, 1
inc percentage
jmp count
printTens:
xor ax, ax
mov bx, 0ah
mov al, percentage
div bl
add al, 30h
add ah, 30h
mov tens, al
mov ones, ah
setCurPos 10,10
writeChar tens,0fh,1
setCurPos 11,10
writeChar ones,0fh,1
inc percentage
jmp count
printHundred:
mov tens, 31h
mov ones, 30h
setCurPos 10,10
writeChar tens,0fh,1
setCurPos 11,10
writeChar ones,0fh,2
mov ah, 4ch
int 21h
endp
end main
每当我使用 delay.It 时它就会冻结并输出 Illegal read/write 当程序非常大时不得不一直为条件跳转创建中继。
It freezes up and outputs Illegal read/write whenever I use the delay. It sucks having to create relays all the time for conditional jumps when the program is really big.
这是 DOSBox 的一个问题,它在 int 15h AH=86h
函数上出错。
我通过编写一个基于 BIOS 计时器滴答的延迟机制来解决这个问题。您可以在 a-low-tech-approach-to-measuring-game-speed
中找到所有详细信息
我的第 1 段符合您的问题描述:
Whilst developing a game I needed a delay routine capable of doing delays ranging from 0.5 sec to just a few msec. The obvious choice was to use the BIOS delay function 86h on int 15h. In a true real address mode environment it works correctly but I saw that an emulator like DOSBox messes up things. Tons of illegal reads and writes. So I had to come up with another solution.
如果您担心程序大小,那么您可能希望将这些宏更改为子例程。每次调用宏时,它的所有代码都会插入到程序中,而子例程只需编码一次并仅通过 call
指令调用多次。
.code
org 100
main proc far
mov ax, @data
mov ds, ax
mov es, ax
您确定您的 .model small
程序需要这个 org 100
指令吗?
如果像 一样,您已更改为 .model tiny
,则 ORG
宁愿必须是 org 256
。
我下面有这个程序,它使用 DOSBox 计数为 100。 它与 .286 完美配合,但我想知道我怎样才能使它与 .386 配合使用。
.286
.model small
setCurPos macro x,y
pusha
mov ah, 02h
mov bh, 0
mov dl, x
mov dh, y
int 10h
popa
endm
writeChar macro char,color,ctr
pusha
mov ah, 9
mov al, char
mov bh, 0
mov bl, color
mov cx, ctr
int 10h
popa
endm
delay macro
mov cx, 0fh
mov dx,4240h
mov ah,86h
int 15h
endm
.stack 100h
.data
percentage db 0
ones db ?
tens db ?
.code
org 100
main proc far
mov ax, @data
mov ds, ax
mov es, ax
mov ah, 0
mov al, 13h
mov bh, 0
int 10h
jmp count
to_printHundred:
jmp printHundred
count:
delay
cmp percentage, 64h
je to_printHundred
cmp percentage, 0ah
jae printTens
;printOnes
mov al, percentage
add al, 30h
mov ones, al
setCurPos 10, 10
writeChar ones, 0fh, 1
inc percentage
jmp count
printTens:
xor ax, ax
mov bx, 0ah
mov al, percentage
div bl
add al, 30h
add ah, 30h
mov tens, al
mov ones, ah
setCurPos 10,10
writeChar tens,0fh,1
setCurPos 11,10
writeChar ones,0fh,1
inc percentage
jmp count
printHundred:
mov tens, 31h
mov ones, 30h
setCurPos 10,10
writeChar tens,0fh,1
setCurPos 11,10
writeChar ones,0fh,2
mov ah, 4ch
int 21h
endp
end main
每当我使用 delay.It 时它就会冻结并输出 Illegal read/write 当程序非常大时不得不一直为条件跳转创建中继。
It freezes up and outputs Illegal read/write whenever I use the delay. It sucks having to create relays all the time for conditional jumps when the program is really big.
这是 DOSBox 的一个问题,它在 int 15h AH=86h
函数上出错。
我通过编写一个基于 BIOS 计时器滴答的延迟机制来解决这个问题。您可以在 a-low-tech-approach-to-measuring-game-speed
我的第 1 段符合您的问题描述:
Whilst developing a game I needed a delay routine capable of doing delays ranging from 0.5 sec to just a few msec. The obvious choice was to use the BIOS delay function 86h on int 15h. In a true real address mode environment it works correctly but I saw that an emulator like DOSBox messes up things. Tons of illegal reads and writes. So I had to come up with another solution.
如果您担心程序大小,那么您可能希望将这些宏更改为子例程。每次调用宏时,它的所有代码都会插入到程序中,而子例程只需编码一次并仅通过 call
指令调用多次。
.code org 100 main proc far mov ax, @data mov ds, ax mov es, ax
您确定您的 .model small
程序需要这个 org 100
指令吗?
如果像 .model tiny
,则 ORG
宁愿必须是 org 256
。