Giter Club home page Giter Club logo

codingmaster's Issues

第17话 汇编读取硬盘 关于硬盘读取结束条件的问题

.readword:
in ax, dx
mov [ds:di], ax
add di, 2
or ah, 0x00
jnz .readword

只判断ah是否为0x00,这样的判定条件是否存在问题?以本例使用的data.asm为例,该字符串总长为32字节,每次读2字节,读到字符串结尾后,再进行一次读写,0x00应该位于al中,此时并没有结束读取的循环。是否应该对al和ah都进行为0的判断?

第18话 label 的作用范围问题

经过编译后,ProgramEnd 的值是0x00000000。似乎在nasm 中,标签都是相对于section的偏移地址

Size dd ProgramEnd;4B 0x00

通过下面指令,并不能获取编译后的代码长度
section end align=16
ProgramEnd:

见第六行:

     1                                  NUL equ 0x00
     2                                  SETCHAR equ 0x07
     3                                  VIDEOMEM equ 0xb800
     4                                  STRINGLEN equ 0xffff
     5                                  section head align=16 vstart=0
     6 00000000 [00000000]                Size dd ProgramEnd;4B 0x00
     7                                    SegmentAddr:
     8 00000004 [00000000]                CodeSeg dd section.code.start;4B 0x04
     9 00000008 [00000000]                DataSeg dd section.data.start;4B 0x08
    10 0000000C [00000000]                StackSeg dd section.stack.start;4B 0x0c
    11                                    SegmentNum:
    12 00000010 03                        SegNum db (SegmentNum-SegmentAddr)/4;1B 0x10
    13 00000011 [0000]                    Entry dw CodeStart;2B 0x11
    14 00000013 [00000000]                      dd section.code.start;4B 0x13

第18话 运行启动扇区外的程序 关于栈段使用的问题

CodeStart:
mov ax, [DataSeg]
mov ds, ax
xor si, si
call PrintString
jmp $

在Program.asm中预留了128字节作为栈段,但是在程序运行过程中,仍然使用的是原有的栈区,并没有使用创建好的栈段。是否可以通过添加以下代码的方式,修改栈?

CodeStart:
  mov bx, [StackSeg]
  mov ss, bx
  mov sp, 128
  mov ax, [DataSeg]
  mov ds, ax
  xor si, si

  call PrintString
  jmp $

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.