English 中文(简体)
简单的NAM“boot方案”无法正确获取记忆?
原标题:Simple NASM "boot program" not accessing memory correctly?

** 说明,当我说是会间方案时,我不说是把一名顾问召集在一起的方案。 我指的是,一个简单的方案,在你开始计算机并做一些事情时运行。

右手,那么我就没有在议会/全国人民军中广为宣传的extremely,但我认为,我有足够的把握来撰写简单的boot节目。

Well, I thought 我的感受非常好。 显然没有。

我在网上尝试了一个简单的boot方案。 罚款(英文字母A)。 然后,我修改了这封信,以印制一份储存在记忆中的信件。 它失败了;它不印刷A,而是印刷了微笑。 (我穿戴,现在用电脑ugh。)

这是来文方档案中的法典:

[BITS 16]    ; We start up in 16-bit real mode
[ORG 0x7C00] ; We re booted into memory at this address. (Or so I m told)

mov ah, 0x0E       ; Teletype command
mov bh, 0x00       ; Page number
mov bl, 0x07       ; Attributes (7 == white foreground, black background)
mov al, [testChar] ; Character to print; load it from the memory referenced by testChar.

int 0x10  ; Tell the BIOS to execute the teletype command.

jmp $  ; Infinite loop prevents us from going off and executing the other junk in memory

testChar db 65  ; This is the character we want to print.  A .

; The following code pads the rest of the outputted binary file
;   and concludes it with the bootloader signature so I don t have
;   to do so manually.
times 510-($-$$) db 0
dw 0xAA55

If I replace move al, [testChar] with move al, 65 , the letter A is printed correctly. I ve tried moving the memory declaration around, I ve tried every combination of brackets or no brackets around BITS and ORG, and I ve tried incrementing and decrementing testChar (i.e. [testChar+1]). Every time, it prints either a smiley, an inverse smiley (when I increment testChar), or nothing at all (when I put the memory declaration before the code, probably because no code is being executed =P). I can t get the damn thing to work.

如今,对于规格(由于其可能具有相关性):

  • I m与一家英特尔Pentium II处理器操作一个Dell Latitude CPi,因为所有I ve都不得不测试(I m不用正常计算机测试组装)。 页: 1 I m pretty 我相信,处理器是x86,因为I ve跑道是Windows XP、Utub和Archit。

  • I m目前使用国家宇宙航行局撰写和汇编关于海底含水层的方案。

  • boot方案由一盘软盘操作。

  • I use nasm -f bin FILENAME to codification the Code.

  • 然后,我利用马托醇一揽子计划对AL的模拟指挥,通过<>mformat-f 1440-B BOOTPROGRAM A:将所编的boot方案转至一盘.。

So, what did I screw up this time? Or is it a problem with my processor/BIOS?

问题回答

DS可能填充一些停车场价值,因此:

push cs
pop ds

or

mov ax, cs
mov ds, ax
mov es, ax

Better yet, don t trust CS and do:

xor ax, ax
mov ds, ax

:一些BIOSes可能使用07c0:0000而不是传统的0:7c00,特别是在使用ElTorito的CD-ROM时。

正在编制以下法典(简而言之,在您汇编的法典中采用 ob)。

00000000  B40E              mov ah,0xe
00000002  B700              mov bh,0x0
00000004  B307              mov bl,0x7
00000006  A00D7C            mov al,[0x7c0d]
00000009  CD10              int 0x10
0000000B  EBFE              jmp short 0xb
0000000D  41                inc cx ; this is actually your testChar
                                   ; ignore the opcode translation

现在,如果你位于0x7C00,那么[0x7c0d]就将成为最后的 by(即0x41或65,或ASCII“A”)。 但是,如果像另一个贡献者之一(ninjalj)提到你有一些奇生物群,这意味着你没有位于0x7C00,那么[0x7c0d]是任何gues。

当我第一次跑时,它会受到罚款! 它印刷了A。 使用指挥系统[档案名称]-o [档案名称.com] -l [档案名称]

我使用了新生的OSbad.asm-o OSbad.com。 利用印度遥感学会制作一个可模版图像文档OSbad.iso,并使用Windows软盘燃烧器将其烧成DVD/RW。 Loaded Blake RV, 并制作了一个新的虚拟机器,有256个Mb RAM、CD/DVD、2GB的硬盘。 带DVD,在屏幕上打印A。

因此,我猜想你的方案正在发挥作用。 这必须是你正在做的其他事情,使它无法发挥作用。





相关问题
Windows Mobile 6 Emulator change storage?

How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: Increasing Windows Mobile 5 Emulator Storage But it only helps for the 5.0 version. Isnt there any way ...

CUDA Memory Allocation accessible for both host and device

I m trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that ...

RAM memory reallocation - Windows and Linux

I am working on a project involving optimizing energy consumption within a system. Part of that project consists in allocating RAM memory based on locality, that is allocating memory segments for a ...

Should I send retain or autorelease before returning objects?

I thought I was doing the right thing here but I get several warnings from the Build and Analyze so now I m not so sure. My assumption is (a) that an object I get from a function (dateFromComponents: ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

doubts regarding Memory management in .net

I m learning about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; ...

Objective-C returning alloc d memory in a function == bad?

This is on the iPhone. So what if I have a function like - (SomeObject*)buildObject; Do I need to pass in a variable that I have already alloc d outside like - (void)assignObject(SomeObject** out);...

热门标签