求问为什么AL的值不能被送入BYTE属性的变量chr……
;首先上源代码~~;本意是构造一个循环队列,先入后出
;但是根本就生成不了可执行文件啊……
;==============================================
.686P
.MODEL FLAT, STDCALL
.STACK 4096
option casemap:none ;
;----------------------------------------------
printf PROTO C :PTR BYTE, :VARARG
scanf PROTO C :DWORD, :VARARG
gets PROTO C :PTR BYTE
getchar PROTO C
ExitProcess PROTO :DWORD
;----------------------------------------------
INCLUDELIB msvcrt.lib;
;----------------------------------------------
Esc_key EQU 27
exit EQU <INVOKE ExitProcess,0>
PBYTE TYPEDEF PTR BYTE
chr$ MACRO any_text:VARARG
LOCAL txtname
.data
txtname db any_text,0
.code
EXITM <OFFSET txtname>
ENDM
;==============================================
;==============================================
.data?
buf BYTE 16 dup(?)
chr BYTE ?
.data
op PBYTE buf
ip PBYTE buf
B_COUNT DWORD 0
;----------------------------------------------
.code;-----------------------------------------
;READ_CHR--------------------------------------
main PROC
READ_CHR:
INVOKE printf, chr$("Input an character: A letter will be added into the buffer. A '-' will remove and output a letter from the buffer. A '0'will terminate the program.");??????????????????
INVOKE scanf, chr$("%c"),offset chr;
INVOKE getchar
call QUE_CHECK
mov AL, chr;
I_cmp1:
cmp AL,45d;??????????????????????????????
jne I_cmp2
call OQ;
jmp READ_CHR
I_cmp2:
cmp AL,Esc_key;
jne I_cmp3
exit
I_cmp3:
cmp AL,65d
jb I_cmp4
call IQ
jmp READ_CHR
I_cmp4:
cmp AL,90d
ja I_cmp5
call IQ
jmp READ_CHR
I_cmp5:
cmp AL,97d
JB I_cmp6
call IQ
jmp READ_CHR
I_cmp6:
cmp AL,122d
JA READ_CHR
call IQ
jmp READ_CHR
main ENDP
;----------------------------------------------
;QUE_CHECK-------------------------------------
;??????????????????????????????????????????????
;----------------------------------------------
QUE_CHECK PROC USES EAX
QC_cmp1:
cmp B_COUNT,0
ja QC_cmp2
INVOKE printf,chr$("Warning: The buffer is empty.");
jmp QC_ret
QC_cmp2:
cmp B_COUNT,16
jb QC_ret
INVOKE printf,chr$("Warning: The buffer is full.");
QC_ret:
RET
QUE_CHECK ENDP
;----------------------------------------------
;IQ--------------------------------------------
;??????????????????????????????????????????????
;----------------------------------------------
IQ PROC
cmp B_COUNT,16
je IQ_ret
IQ_push:
push EAX
push EBP
IQ_prep:
mov EAX,offset buf
cmp EAX,16
je IQ_tail
mov EBP,ip
IQ_norm:
mov AL,chr;======================================
mov [EBP],AL;====================================此处报错
dec EBP
inc B_COUNT
jmp IQ_pop
IQ_tail:
mov AL,chr;======================================
mov [EBP],AL;====================================此处报错
mov EBP,offset buf
inc B_COUNT
jmp IQ_pop
IQ_pop:
mov ip,EBP
pop EBP
pop EAX
IQ_ret:
RET
IQ ENDP
;----------------------------------------------
;OQ--------------------------------------------
;??????????????????????????????????????????????
;----------------------------------------------
OQ PROC
cmp B_COUNT,0
je OQ_ret
OQ_push:
push EAX
push EBP
OQ_prep:
mov EAX,offset buf
sub EAX,op
je OQ_head
mov EBP,op
OQ_norm:
mov AL,[EBP]
mov chr,AL
INVOKE printf,chr$("%c",chr)
dec EBP
OQ_head:
mov AL,[EBP]
mov chr,AL
INVOKE printf,chr$("%c",chr)
mov EBP,offset buf
sub EBP,16
OQ_pop:
mov op,EBP
pop EBP
pop EAX
OQ_ret:
RET
OQ ENDP
;----------------------------------------------
END main
;点击生成之后出现如下信息:
;1>------ 已启动生成: 项目: Buffer, 配置: Debug Win32 ------
;1> Assembling [Inputs]...
;1>..\Buffer1.asm(185): error A2071: initializer magnitude too large for specified size
;1>..\Buffer1.asm(191): error A2071: initializer magnitude too large for specified size
;1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\masm.targets(49,5): error MSB3721: 命令“ml.exe /c /nologo /Zi /Fo"Debug\Buffer1.obj" /I "C:\Code\ASM\IrvineExamplesVS2010a" /W3 /errorReport:prompt /Ta..\Buffer1.asm”已退出,返回代码为 1。
;========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========