使用TASM 5和3组装我的代码(我尝试使用两个版本的TASM)给我一些错误,我不知道为什么!
**Error** fonts.txt(4) Illegal instruction **Error** fonts.txt(15) Illegal instruction **Error** fonts.txt( 148) Undefined symbol: FONT1 **Error** fonts.txt( 154) Undefined symbol: FONT2
我的代码:
.MODEL LARGE, PASCAL
.386
.DATA
FONT1
db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,060h,070h,070h,038h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,044h,0FCh,0F8h,060h,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,04Ah,0FEh,0F4h,060h,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,04Eh,0F0h,0FEh,07Ch,030h,030h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,030h,038h,02Ch,044h,042h,082h,092h,0FEh,06Ch,000h,000h,000h
db 000h,000h,000h,000h,040h,07Ch,03Ch,004h,004h,004h,006h,007h,003h,000h,000h,000h
db 000h,000h,000h,000h,082h,0C6h,0C6h,06Ch,028h,038h,010h,010h,010h,000h,000h,000h
db 000h,000h,000h,000h,010h,010h,010h,038h,028h,06Ch,0C6h,0C6h,082h,000h,000h,000h
db 000h,000h,000h,000h,070h,0F8h,088h,0F8h,078h,008h,00Ch,00Eh,006h,000h,000h,000h
FONT2
db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,030h,038h,038h,01Ch,00Ch,00Ch,004h,004h,004h,000h,000h,000h
db 000h,000h,000h,000h,022h,07Eh,07Ch,030h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,025h,07Fh,07Ah,030h,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,027h,078h,07Fh,03Eh,018h,018h,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,018h,01Ch,016h,022h,021h,041h,041h,07Fh,036h,000h,000h,000h
db 000h,000h,000h,000h,042h,07Eh,03Eh,004h,004h,004h,006h,003h,003h,001h,000h,000h
db 000h,000h,000h,000h,041h,063h,063h,036h,014h,01Ch,008h,008h,008h,000h,000h,000h
db 000h,000h,000h,000h,008h,008h,008h,01Ch,014h,036h,063h,063h,041h,000h,000h,000h
db 000h,000h,000h,000h,038h,07Ch,044h,07Ch,03Ch,004h,004h,006h,007h,003h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,018h,020h,038h,038h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,0FFh,000h,000h,000h,000h,000h
db 000h,000h,000h,01Ch,03Eh,022h,020h,010h,008h,008h,000h,008h,000h,000h,000h,000h
db 000h,002h,032h,04Ch,000h,010h,018h,018h,018h,018h,018h,018h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,010h,008h,011h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,010h,00Ch,00Ah,014h,008h,000h,000h,000h,000h
db 000h,000h,000h,010h,018h,018h,018h,018h,018h,018h,018h,018h,000h,000h,000h,000h
db 000h,000h,000h,008h,008h,008h,008h,008h,008h,00Fh,007h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,041h,081h,0FFh,07Eh,000h,008h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,020h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,041h,081h,0FFh,07Eh,000h,028h,010h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,050h,020h,000h,000h
db 000h,000h,000h,000h,000h,028h,000h,041h,081h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,028h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,010h,028h,000h,041h,081h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,010h,028h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,044h,040h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,008h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,04Ah,044h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,038h,010h,000h,000h
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,01Fh,03Fh,060h,040h,040h,061h,03Eh
db 000h,000h,000h,000h,000h,000h,01Ch,026h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,01Ch,026h,003h,01Fh,03Fh,060h,040h,040h,061h,03Eh
db 000h,000h,000h,000h,008h,000h,01Ch,026h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,006h,003h,03Fh,03Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,00Ch,006h,003h,03Fh,03Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,002h,007h,003h,003h,006h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,000h,002h,000h,002h,007h,003h,003h,007h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,004h,00Ah,000h,002h,007h,003h,003h,006h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,000h,000h,000h,001h,049h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,014h,000h,001h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,008h,014h,000h,001h,049h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,003h,005h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,000h,000h,006h,009h,051h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,008h,000h,003h,005h,015h,09Fh,09Eh,098h,088h,088h,0F8h,070h
db 000h,000h,000h,000h,004h,000h,006h,009h,051h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,020h,020h,020h,02Eh,031h,021h,0FFh,0FEh,000h,000h,000h,000h,000h
db 011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h,011h,044h
db 055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh,055h,0AAh
db 0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h,0DDh,077h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0F6h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FEh,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0F8h,018h,0F8h,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,0F6h,006h,0F6h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0FEh,006h,0F6h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,0F6h,006h,0FEh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FEh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,0F8h,018h,0F8h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0F8h,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,01Fh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,01Fh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,037h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,037h,030h,03Fh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,03Fh,030h,037h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,0F7h,000h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0F7h,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,037h,030h,037h,036h,036h,036h,036h,036h,036h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,0F7h,000h,0F7h,036h,036h,036h,036h,036h,036h
db 018h,018h,018h,018h,018h,018h,018h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,000h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FFh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,0FFh,000h,0FFh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,03Fh,000h,000h,000h,000h,000h,000h
db 018h,018h,018h,018h,018h,018h,018h,01Fh,018h,01Fh,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,01Fh,018h,01Fh,018h,018h,018h,018h,018h,018h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,03Fh,036h,036h,036h,036h,036h,036h
db 036h,036h,036h,036h,036h,036h,036h,036h,036h,0FFh,036h,036h,036h,036h,036h,036h
db 018h,018h,018h,018h,018h,018h,018h,0FFh,018h,0FFh,018h,018h,018h,018h,018h,018h
db 018h,018h,018h,018h,018h,018h,018h,018h,018h,0F8h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,01Fh,018h,018h,018h,018h,018h,018h
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh
db 0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h,0F0h
db 00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh,00Fh
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,020h,024h,020h,02Eh,031h,021h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,00Ch,01Eh,020h,03Eh,03Eh,040h,080h,080h,0C1h,0FEh,07Ch
db 000h,000h,000h,000h,000h,000h,038h,044h,038h,03Fh,04Fh,080h,080h,0C2h,0FCh,078h
db 000h,000h,000h,000h,000h,000h,01Ch,022h,01Ch,0FFh,0E7h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,00Ch,01Eh,020h,0FEh,0FCh,000h,000h,000h,000h,000h
db 000h,000h,000h,004h,000h,00Ch,01Eh,020h,03Eh,03Eh,040h,080h,080h,0C1h,0FEh,07Ch
db 000h,000h,000h,000h,010h,000h,038h,044h,038h,03Fh,04Fh,080h,080h,0C2h,0FCh,078h
db 000h,000h,000h,000h,008h,000h,01Ch,022h,01Ch,0FFh,0E7h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,004h,000h,00Ch,01Eh,020h,0FEh,0FCh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,002h,000h,002h,047h,085h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,002h,000h,002h,007h,005h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,014h,000h,002h,007h,005h,087h,081h,081h,083h,07Eh,03Ch,000h
db 000h,000h,000h,000h,00Ah,000h,002h,007h,005h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,001h,003h,006h,00Ch,008h,00Ch,086h,083h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,001h,003h,006h,00Ch,008h,00Ch,006h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,005h,00Bh,016h,00Ch,008h,00Ch,086h,083h,0FFh,07Eh,000h,000h,000h,000h,000h
db 000h,005h,00Bh,016h,00Ch,008h,00Ch,006h,003h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,001h,001h,001h,001h,001h,001h,001h,081h,081h,0FEh,07Ch,000h,000h
db 000h,000h,000h,001h,061h,031h,019h,009h,005h,007h,00Eh,038h,000h,000h,000h,000h
db 000h,000h,000h,001h,001h,001h,001h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,006h,00Bh,07Fh,0FEh,080h,080h,080h,080h,080h
db 000h,000h,000h,000h,000h,000h,000h,006h,00Fh,0FDh,0FFh,006h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,010h,001h,081h,081h,081h,0FEh,07Ch,000h
db 000h,000h,000h,000h,000h,004h,000h,001h,001h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,006h,009h,00Fh,00Fh,003h,00Eh,03Ch,000h,000h
db 000h,000h,000h,000h,004h,00Eh,00Fh,013h,013h,01Fh,00Eh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,010h,0F3h,0F3h,00Ch,004h,000h,000h,000h
db 000h,000h,000h,000h,000h,00Ch,01Eh,03Fh,0C9h,0FFh,0FEh,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,007h,007h,00Eh,083h,081h,0FFh,07Eh,000h
db 000h,000h,000h,000h,000h,000h,006h,00Fh,010h,01Eh,08Fh,081h,081h,0FEh,07Ch,000h
db 000h,000h,000h,000h,000h,000h,000h,001h,001h,0FFh,0FEh,000h,024h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
.CODE
Assume es:@DATA
public Font
FONT proc PASCAL
lea bp, FONT1
mov dx,48
mov bx,1000h
mov cx,10
mov ax,1110h
int 10h
lea bp,FONT2
mov dx,128
push ds
pop es
mov bx,1000h
mov cx,127
mov ax,1110h
int 10h
ret
FONT ENDP
END
有些朋友说:第14,15行在标签末尾需要一个“:”,例如。FONT1:
,但这些不是标签,这些是“db”组的NAME。当我尝试在标签末尾用冒号(FONT1:
和FONT2:
)进行汇编时,它会给我这些错误:
**Error** fonts.txt(4) CS UNREACHABLE FROM CURRENT SEGMENT **Error** fonts.txt(15) CS UNREACHABLE FROM CURRENT SEGMENT
如何修复此代码以避免这些错误?
答案 0 :(得分:1)
我会把它放在评论中,但不确定它是否清晰可见。使用TASM将标签放在带有数据的行上,而不是单独放置。如果你只是做一些修改,它可能会有用:
FONT1
db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,060h,070h,070h,038h,018h,018h,008h,008h,008h,000h,000h,000h
[snip for brevity]
是:
FONT1 db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,060h,070h,070h,038h,018h,018h,008h,008h,008h,000h,000h,000h
[snip for brevity]
对FONT2
执行相同的操作:
FONT2 db 000h,000h,000h,000h,000h,000h,000h,030h,048h,048h,030h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,030h,038h,038h,01Ch,00Ch,00Ch,004h,004h,004h,000h,000h,000h
[snip for brevity]
答案 1 :(得分:0)
“CS无法访问”
我没有要测试的TASM,但是您可能正在将其构建为exe文件,因此.DATA
在加载二进制文件后处于单独的段中,并且要获取它的完整地址,您还必须使用段注册
cs
已经指向.CODE
,我没有看到任何进一步的段注册设置(好吧,你将ds
复制到es
中间程序,但这对我没有任何意义,因为ds
未定义。)
所以你可能想要的是在你的程序的早期某处使用mov ax,@DATA
mov es,ax
(你也可以在程序的开始/结束时push es
/ pop es
来保存原始内容)。并且lea bp,[es:FONT1]
(在TASM中可能是lea bp,es:[FONT1]
),因为那里已经有ASSUME
子句。也许MOV bp,OFFSET FONT1
可能会起作用(我不确定TASM会对前缀lea做什么,我有点担心它会将它组装成具有真实es:
前缀的机器码,这是没有意义的,因为lea
只会设置bp
,而不是真正访问内存。
关于冒号:MASM / TASM(实际上几乎所有的汇编程序)语法不是很连贯,并且有许多例外,快捷方式和模糊的简化。
所以:
someLabel DB 1
等于(更准确,更一致并由我推荐):
someLabel: DB 1
例如,在NASM中,即使在代码内的普通非DB行上也可以创建没有冒号的标签,但是仍然强烈建议在每个标签后放置冒号,以避免出现例如标签命名不好的情况,以及你写loop
作为循环的标签,可以没有尾随冒号与loop
指令混淆。因此,每次添加冒号将有助于汇编程序不会将任何标签与其他内容混淆。
FONT1
不是 GROUP 的 NAME 。它是指向下一个定义的机器代码字节的标签(地址)。下一个机器代码字节由long db
中的第一个值定义。其余定义的字节与FONT1
没有任何关系,它会编译为相同的标签,无论你只做FONT1 DB 1
还是FONT1 DB 1, 2, 3, 4
......第一个{{1定义字节,这是标签1
指向的内存地址。剩余的字节只是编译成FONT1
之后的机器代码。
编辑:如果您不打算使用MASM,并且您可以完全控制TASM使用(版本+ CLI选项),我建议您使用TASM“理想”模式,它的语法略有不同来自MASM(更加严格和连贯)。我最后一次使用TASM(大约在1998年),最少的版本是3.something,4.x确实产生了错误的机器代码,即使在中等大小的源上,5.x确实看起来几乎稳定,但是其中一个我最大的来源也确实产生了错误的机器代码,所以我回到了一些晚期的3.x(无法回想起确切的版本)。但是我不记得版本之间的语法有太多问题,看起来我用运气以兼容的方式编写了源代码。无论如何,检查您使用的版本的正确TASM文档应该可以帮助您澄清特定的语法细微之处。