Assembly(tasm) program crashes in run but works fine in debugger(turbo debugger)

后端 未结 1 603
北荒
北荒 2021-01-28 09:59

My program(assembly tasm 16bit) supposed to print a bar graph represtion for an array.Right now its only supports specificarray but I will add support for general cases in the f

相关标签:
1条回答
  • 2021-01-28 10:29

    Turbo Debugger sets a bunch of registers to 0 when it loads the program. When MS-DOS starts these registers are not set to null. The information which register needs to be null you can achieve by adding

    xor ax, ax
    xor bx, bx
    xor cx, cx
    xor dx, dx
    xor si, si
    xor di, di
    xor bp, bp
    

    at the beginning of the start procedure and by commenting it out successively. It will turn out that the delinquent is DX. So search for the first function or instruction which expects a null in this register. I found it in the first div instruction in FindWidthForColAndSpace. This div performs DX:AX/BX and needs therefore a value in DX. Is it an accident that the line xor dx, dx follows the div? It must be in front of it.

    0 讨论(0)
提交回复
热议问题