Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Debug

  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Debug

    hi all im new...... just got a little problem making a small program in debug which adds a number in AX and BX and puts them in DX

    when it adds the 2 numbers the result is a hex number

    also im trying to put into a memory location the difference between the 2 numbers which i do not have a clue how to do.

    heres the code i am using so far

    debug

    a 100

    dw 28
    dw 16
    enter


    -a 108
    MOV AX,[100]
    MOV BX,[102]
    ADD DX,AX
    ADD DX,BX
    MOV DX,[104]

    (formatted to show exactly how i do it)

    thanks for your help

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    It might help people saying what language you are trying to do this in
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry. im using MS-Dos debug

  • #4
    Regular Coder
    Join Date
    Feb 2004
    Location
    WA
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Whoa!

    I am unable to offer any help, but I could not resist my amusement at someone trying to do some work in MSDOS!

    I used to be a MSDOS pro long back.. now I seem to have lost all touch with it. I can safely blame all the high level languages that are popular now

    good luck with your program!

    Oh, by the way, its called assembly language
    Nobody is Perfect. I am Nobody.

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol. trust me mate i wouldnt be using dos if i had another choice..... unfortunately my uni course has decided to make me use dos for it

  • #6
    Regular Coder
    Join Date
    Feb 2004
    Location
    WA
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    alright, i finally recollected enough to get a debug session going

    addition
    Code:
    -a
    0B2A:0100 jmp 120
    0B2A:0102 dw 28
    0B2A:0104 dw 16
    0B2A:0106
    -a 120
    0B2A:0120 mov ax,[102]
    0B2A:0123 mov bx,[104]
    0B2A:0127 add dx,ax
    0B2A:0129 add dx,bx
    0B2A:012B mov [106],dx
    0B2A:012F
    -g =100
    
    Program terminated normally
    -d
    0B2A:0100  EB 1E 28 00 16 00 3E 00-A1 00 01 8B 1E 02 01 01   ..(...>.........
    0B2A:0110  C2 01 DA 8B 16 04 01 F8-C3 AA 41 FE 34 00 19 0B   ..........A.4...
    0B2A:0120  A1 02 01 8B 1E 04 01 01-C2 01 DA 89 16 06 01 2D   ...............-
    0B2A:0130  91 2E 89 36 2F 91 FC 2E-89 0E 94 90 2E C7 06 96   ...6/...........
    0B2A:0140  90 00 00 2E C7 06 A9 90-00 00 2E C7 06 9A 90 00   ................
    0B2A:0150  00 2E C7 06 66 91 5B 5D-2E C7 06 68 91 7C 3C 2E   ....f.[]...h.|<.
    0B2A:0160  C7 06 6A 91 3E 2B 2E C7-06 6C 91 3D 3B E8 83 09   ..j.>+...l.=;...
    0B2A:0170  73 13 B8 FF FF 53 26 8B-1D 26 3A 0F 73 03 B8 02   s....S&..&:.s...
    subtraction
    Code:
    -a 120
    0B2A:0120 MOV     AX,[0102]
    0B2A:0123 MOV     BX,[0104]
    0B2A:0127 MOV     DX,AX
    0B2A:0129 SUB     DX,BX
    0B2A:012B MOV     [0106],DX
    
    -d 100
    0B2A:0100  EB 1E 28 00 16 00 12 00-A1 00 01 8B 1E 02 01 01   ..(.............
    0B2A:0110  C2 01 DA 8B 16 04 01 F8-C3 AA 41 FE 34 00 19 0B   ..........A.4...
    0B2A:0120  A1 02 01 8B 1E 04 01 89-C2 29 DA 89 16 06 01 2D   .........).....-
    0B2A:0130  91 2E 89 36 2F 91 FC 2E-89 0E 94 90 2E C7 06 96   ...6/...........
    0B2A:0140  90 00 00 2E C7 06 A9 90-00 00 2E C7 06 9A 90 00   ................
    0B2A:0150  00 2E C7 06 66 91 5B 5D-2E C7 06 68 91 7C 3C 2E   ....f.[]...h.|<.
    0B2A:0160  C7 06 6A 91 3E 2B 2E C7-06 6C 91 3D 3B E8 83 09   ..j.>+...l.=;...
    0B2A:0170  73 13 B8 FF FF 53 26 8B-1D 26 3A 0F 73 03 B8 02   s....S&..&:.s...
    let me know if you need explanation for anything. would be glad to explain what's going on.
    Nobody is Perfect. I am Nobody.

  • #7
    New Coder
    Join Date
    Mar 2004
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry just one more small thing. is there another way to find the difference between the two numbers. as im not sure how subtract will work if the first number is less than the number you are subtracting from it

  • #8
    Regular Coder
    Join Date
    Feb 2004
    Location
    WA
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It will work just fine - SUB instruction is capable of dealing with any numbers.

    lets take your example again and reverse the numbers. so we subtract 0x28 from 0x16. if we do the math ourselves, we can see that the result should be 0xFFEE = -18 (this is how negative numbers look like in hex)

    A little background on 2's complement notation of integers:
    http://www.cs.ualberta.ca/~casey/c10...tes/2comp.html

    so, for 0xFFEE = 1111 1111 1110 1110
    note that the most significant bit is 1 - which tells us that it is a negative number.

    if you convert this to decimal you will see that it is -18 which indeed is the result of subtracting 0x28(40) from 0x16(22)

    now, if you look at the memory location, you will see this
    Code:
    -d 100
    0B2A:0100  EB 1E 16 00 28 00 EE FF-B8 01 00 D3 E0 0B E8 59   ....(..........Y
    0B2A:0110  5F 07 B0 00 AA 5F 9D F8-C3 AA 41 FE 34 00 19 0B   _...._....A.4...
    Note that it is written backwards, just like the numbers we started with.

    hope that cleared up somethings about subtraction.
    Last edited by Unit; 03-18-2004 at 07:33 PM.
    Nobody is Perfect. I am Nobody.

  • #9
    New Coder
    Join Date
    Mar 2004
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks alot mate been a big help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •