MASM:如何解决错误“不允许立即操作数"?

编程入门 行业动态 更新时间:2024-10-27 00:35:04
本文介绍了MASM:如何解决错误“不允许立即操作数"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的汇编程序具有以下结构:

My assembly program has following structure:

BPB_FAT16 STRUCT ; Base BPB_FAT16. Size=0x19=25. BytesPerSector DW 0x0200 ; Size of HW sector, usualy 512. SectorsPerCluster DB 0x01 ; Valid values 1,2,4,8,16,32,64,128. ReservedSectors DW 0x0001 ; NrOfSectors preceding FAT. NumberOfFats DB 0x02 ; RootEntries DW 0x00E0 ; Max number of YWORD entries in the ;root dir. SmallSectors DW 0x0B40 ; See also .LargeSectors. MediaDescriptor DB 0xF0 ; 0xF0 floppy disk, 0xF8 hard disk. SectorsPerFat DW 0x0009 ; SectorsPerTrack DW 0x0012 ; NumberOfHeads DW 0x0002 ; HiddenSectors DW 0x00000000 LargeSectors DW 0x00000000 ; Extended BPB_FAT16. Size=0x1A=26. PhysicalDriveNumber DB 0x00 ; 0x00 floppy disk, 0x80 hard disk. Reserved DB 0x00 ; ExtBootSignature DB 0x29 ; Or 0x28. VolumeSerialNumber DW 1212121 ; Randomly generated number. VolumeLabel DB "NO NAME " ; Space-padded to size=11. FileSystemType DB "FAT12 " ; Space-padded to size=8. BPB_FAT16 ENDS ; Total BPB_FAT16. Size=0x33=51.

我的程序仅对下面给出的一行代码显示两个错误:

My program is showing two errors for only one line of code given below:

Bpb BPB_FAT16{}

这两个错误是:

error1: missing operator in expression error2: initializer magnitude too large for specified size

我该怎么办?请引导我.

What should I do? Please guide me.

推荐答案

在将0x前缀用作十六进制值的每一行上都可能出现错误消息missing operator in expression. MASM不支持该功能,它使用h后缀表示十六进制值.

The error message missing operator in expression is likely occurring on every line where you use 0x prefix for hexadecimal values. MASM doesn't support that and it use the h suffix to denote hexadecimal values.

错误initializer magnitude too large for specified size是因为值1212121 不能适合您为VolumeSerialNumber指定的DW(16位WORD). BPB中的VolumeSerialNumber必须是DD(32位DWORD).

The error initializer magnitude too large for specified size is because the value 1212121 can't fit in the DW (16-bit WORD) you specified for VolumeSerialNumber. VolumeSerialNumber in a BPB needs to be a DD (32-bit DWORD).

尽管它不会产生错误,但BPB中的字段HiddenSectors和LargeSectors是32位DWORD,因此它们应使用类型DD而不是DW.

Although it didn't generate an error, the fields HiddenSectors and LargeSectors in a BPB are a 32-bit DWORD so they should be using the type DD instead of DW.

您的结构本可以定义为:

Your structure could have been defined as:

BPB_FAT16 STRUCT ; Base BPB_FAT16. Size=0x19=25. BytesPerSector DW 200h ; Size of HW sector, usualy 512. SectorsPerCluster DB 1h ; Valid values 1,2,4,8,16,32,64,128. ReservedSectors DW 1h ; NrOfSectors preceding FAT. NumberOfFats DB 2h ; RootEntries DW 0E0h ; Max number of YWORD entries in the ; root dir. SmallSectors DW 0B40h ; See also .LargeSectors. MediaDescriptor DB 0F0h ; 0xF0 floppy disk, 0xF8 hard disk. SectorsPerFat DW 9h ; SectorsPerTrack DW 12h ; NumberOfHeads DW 2h ; HiddenSectors DD 0h LargeSectors DD 0h ; Extended BPB_FAT16. Size=0x1A=26. PhysicalDriveNumber DB 0h ; 0x00 floppy disk, 0x80 hard disk. Reserved DB 0h ; ExtBootSignature DB 29h ; Or 0x28. VolumeSerialNumber DD 1212121 ; Randomly generated number. VolumeLabel DB "NO NAME " ; Space-padded to size=11. FileSystemType DB "FAT12 " ; Space-padded to size=8. BPB_FAT16 ENDS ; Total BPB_FAT16. Size=0x33=51.

通过这些更改,您的结构现在正好是51个字节,这就是您期望的FAT16 DOS 4.0 EBPB .

With these changes your structure is now exactly 51 bytes which is what you'd expect for a FAT16 DOS 4.0 EBPB.

更多推荐

MASM:如何解决错误“不允许立即操作数"?

本文发布于:2023-10-23 04:22:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   如何解决   错误   操作   MASM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!