汇编程序消息:错误:在Linux上运行时出现垃圾

时间:2017-09-07 22:45:23

标签: linux assembly operating-system kernel

我目前正在研究作者使用mingw在Windows中创建操作系统的材料here。我正在尝试跟随并且我正在使用Ubuntu,但是当我到达特定阶段,即组装目标文件时,我收到错误。

我使用的命令是:

as -o boot.o boot.s

这是我的错误:

as -o boot.o boot.s
boot.s: Assembler messages:
boot.s:22: Error: junk `iResSect' after expression
boot.s:24: Error: invalid character ',' in mnemonic
Makefile:10: recipe for target 'boot.o' failed
make: *** [boot.o] Error 1

以下是一些文件:

boot.s:

.code16
.intel_syntax noprefix
.text
.org 0x0

LOAD_SEGMENT = 0x1000       # Load the 2nd Stage to Here
FAT_SEGMENT = 0x0ee0        # Load FAT to here

.global main

main:
    jmp short start
    nop

.include "bootsector.s"
.include "macros.s"

start:
    mInitSegments
    mResetDiskSystem
    mWriteString loadmsg
    mFindFile filename, LOAD_SEGMENT
    mReadFAT FAT_SEGMENT
    mReadFile LOAD_SEGMENT, FAT_SEGMENT
    mStartSecondStage

#
# Booting has failed because of a disk error
# Inform the user and reboot.
#
bootFailure:
    mWriteString diskerror
    mReboot

.include "functions.s"

# DATA
filename:   .asciz "2NDSTAGEBIN"
rebootmsg:  .asciz "Press any key to reboot.\r\n"
diskerror:  .asciz "Disk error. "
loadmsg:    .asciz "Loading SamOS...\r\n"

root_strt:  .byte 0,0   # Holds offset of Root Dir on disk
root_scts:  .byte 0,0   # Hold No. Sectors in Root Dir
file_strt:  .byte 0,0   # Hold offset of bootloaded on disk

.fill (510-(.-main)), 1, 0
BootMagic:  .int 0xAA55

bootsector.s:

bootsector:
    iOEM:        .ascii "DevOS   "  # OEM String
    iSectSize:       .word 0x200    # Bytes per Sector  
    iClustSize:      .byte 1        # Sectors per Cluster
    iResSect:        .word 1        # No. Reserved Sectors
    iFatCnt:         .byte 2        # No. FAT Copies
    iRootSize:       .word 224      # Size of Root Dir.
    iTotalSect:      .word 2880     # Total no. of sectors (<32mb)
    iMedia:      .byte 0xF0     # Media Descriptor
    iFatSize:        .word 9        # Size of each FAT
    iTrackSect:      .word 9        # Sectors per Track
    iHeadCnt:        .word 2        # No. Read/Write Heads
    iHiddenSect:     .int 0     # No. Hidden Sectors
    iSect32:         .int 0     # No. Sectors if > 32mb
    iBootDrive:      .byte 0        # Boot Sectors comes from here
    iReserved:       .byte 0        # No. Reserved Sectors
    iBootSign:       .byte 0x29     # Extended boot sect. signature
    iVolID:      .ascii "seri"  # Disk Serial
    acVolLabel:      .ascii "MYVOLUME   "   # Placeholder
    acFSType:        .ascii "FAT16   "

有关为何发生这种情况的任何建议?

0 个答案:

没有答案