x86汇编VS利用它的内存位置实际上得到一个变量值 [英] x86 Assembly Actually get a Variables Value vs using its memory location

查看:238
本文介绍了x86汇编VS利用它的内存位置实际上得到一个变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/12663971/x86-assembly-move-on-byte-from-on-memory-location-to-another\">x86大会字节移动从内存位置到另一个

好了,basicly我已经在这个问题上花了三天时间。这里就是我认为正在发生的事情,我想如果可能的话摸不着头脑。好了,我pretty很多正在写在大会一操作系统,采用NASM,它运行在保护模式下,并且是32位。现在,我想创建一个简单的字节变量,与104的价值,这是一个H。现在,我想在这个变量移动值,寄存器,我想'斧头'就可以了,然后移动104,内存位置0xB8000。这里是我的code应该做到这一点,是不是,所以我需要一些帮助。谢谢 - 马特

Ok, so basicly I have spent three days on this problem. And here's what I think is happening, and I would like to figure this out, if at all possible. Ok, so I pretty much am writing a Operating System in Assembly, using Nasm, it runs in Protected mode, and is 32 bit. Now I am trying to create a simple One Byte Variable, with the value of 104, which is a 'h'. Now I want to move the value in this variable to, a register, I guess 'ax' would be fine, and then move the 104, to memory location '0xB8000'. Here's my code that should do this, and isn't so I need some help. Thanks - Matt


%ifndef ELF_COMPILATION
use32
org 0x200000
[map all main.map]
%endif
section .data
%ifndef ELF_COMPILATION
MultibootSignature dd 464367618
MultibootFlags dd 65539
MultibootChecksum dd -464433157
MultibootHeaderAddr dd MultibootSignature
MultibootLoadAddr dd MultibootSignature
MultibootLoadEndAddr dd EndCode
MultibootBSSEndAddr dd EndCode
MultibootEntryAddr dd START
%endif
%ifdef ELF_COMPILATION
MultibootSignature dd 464367618
MultibootFlags dd 3
MultibootChecksum dd -464367621
%endif
MultibootGraphicsRuntime_VbeModeInfoAddr dd 2147483647
MultibootGraphicsRuntime_VbeControlInfoAddr dd 2147483647
MultibootGraphicsRuntime_VbeMode dd 2147483647
MultiBootInfo_Memory_High dd 0
MultiBootInfo_Memory_Low dd 0
Var2: db 104
section .text
jmp START
START:
    ;Print out letter out.
    call DisplayMessage
    jmp Halt
DisplayMessage:
    mov ax, Var2
    mov [0xB8000], ax
    ret
Halt:
    jmp Halt
EndCode:

不管怎么说,我问类似这样的东西的问题,也没有运气。我知道大会,在大多数情况下,但我不明白为什么这是行不通的。我只能推测是其推VAR2的内存地址VS斧的实际值。如果是这样的话,我怎么加载从地址到AX 104,并进入0xB8000?谢谢你们。

Anyways, I asked a question to something similar like this and had no luck. I know Assembly, for the most part, but I don't see why this isn't working. All I can figure is its putt Var2's memory address vs the actual value in ax. If this is the case, how do I load 104 from that address into ax, and into 0xB8000? Thanks guys.

差点忘了,我现在用的引导加载器的SysLinux。

Almost forgot, the bootloader I am using is SysLinux.

推荐答案

这样的事情应该工作:

mov ah, Var2
mov edi, 0xb8000
mov [edi], ah

...带寄存器内存引用 [EDI] 而不是内存地址直接使用1字节的寄存器,用于存储数据。

...referencing memory with register [edi] instead of memory address direct and using 1 byte register for data.

这篇关于x86汇编VS利用它的内存位置实际上得到一个变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆