Back | Reverse | Quick Reply | Post Reply |

assembly language
Link | by child_of_extreme on 2005-10-14 14:48:02
i was thinking about this and i confused how do you use the basic operations when adding these,(i can do it with a computer but i can't show the solution)

here is the sample:
ax bx cx dx
mov ax,a222 aa22 - - -
mov bx,33ff aa22 33ff - -
not ax 55dd 33ff - -
add ax,bx 89dc 33ff - -
or bx,ffff 89dc ffff - -
mov cx,1abe 89dc ffff 1abe -
add ax,cx a49a ffff 1abe -
mov dh,33 a49a ffff 1abe 3300
mov al,45 a495 ffff 1abe 3300
xor ax,ax 0000 ffff 1abe 3300
not dx 0000 ffff 1abe ccff
sub bx,cx 0000 e541 1abe ccff

i was wondering how do you add,subtract this because even though i can get it easily using a computer,however we are required to show how it was added/subtracted.

i am the way to the city of woe, i am the way to the forsaken people, i am the way to eternal sorrow - Raven

Re: assembly language
Link | by Inggo on 2005-10-16 00:30:51
Assembly language uses binary arithmetic.
I didn't exactly understand what you needed to know, but I'll try to do it step by step.

mov ax, A222h
; Place A222 (in hexadecimal) to AX

mov bx, 33FFh
; Place 33FF (in hexadecimal) to BX

not ax
; NOT Inverts all bits of AX
; Since the value of AX is A222, or 1010001000100010 in binary,
; inverting the ones to zeroes and you'll get
; 0101110111011101 or 5DDD

add ax, bx
; Now you add AX to BX. Your AX is 5DDD and BX is 33FF, and the formula
; is basically AX = AX + BX
; Substituting, AX = 5DDD + 33FF
; Finally AX = 89DC

or bx, FFFFh
; OR compares every bit of the register in the left to your input in the right
; If both of them are 0, the bit will be 0, otherwise, it's 1
; BX is 33FF, or 11001111111111 in binary,
; The value you entered is FFFF, or 1111111111111111 in binary
; Since in every bit, there's a 1, ORing all bits will yield a 1, or
; 1111111111111111, or basically FFFF
; Your BX then becomes FFFF

mov cx, 1ABEh
; Place 1ABE to CX

add ax, cx
; Like earlier, you add AX to CX. Your AX is 89DC and CX is 1ABE
; AX = AX + CX; AX = 89DC + 1ABE
; AX = A49A

mov dh, 33
; Now, you move 33 to the High-order bytes of DX. Originally, DX is 0000
; You only place 33 to the first two bytes of DX.
; Therefore, your DX becomes 3300

mov al, 45
; This time, you move 45 to the Low-order bytes of AX.
; Those are the last two bytes of AX. You replace the 9A of A49A
; Your AX becomes A445

xor ax, ax
; XORing the same value basically resets the value of the register to 0000
; What XOR does is compares each bit, and if the bits are the same,
; the bit becomes 0, if they are different, it becomes 1
; Your AX now becomes 0000

not dx
; This time, invert the bits of DX
; Your DX is 3300, or 11001100000000
; When inverted, it is 00110011111111 or
; CCFF

sub bx, cx
; You subtract the value in CX from BX and put it in BX.
; The formula is BX = BX - CX
; Your CX is 1ABE and your BX is FFFF
; FFFF - 1ABE = E541


You mentioned that you were required to show how they were added or subtracted. These methods require the use of hexadecimal arithmetic, so you need to know how to add and subtract hexadecimal numbers. If you don't know how, you can substitute the hexadecimal numbers to their decimal values and then perform the operation, then substitute them back to their hexadecimal values.

Hope this helps. ^^,

Back | Reverse | Quick Reply | Post Reply |

Copyright 2000-2024 Gendou | Terms of Use | Page loaded in 0.0023 seconds at 2024-12-27 14:10:06