0

The code is:

.model small
.data
ar db ffh
.code
mov ax,@data
mov ds,ax
mov ah,00h
mov al,ar
mov bl,40h
clc
adc ax,bx
mov ah,4ch
int 21h
end
  1. It is throwing error at line 3 saying

    Symbol not defined: ffh

    I don't understand how isn't it recognising a0h which is just a hexadecimal number.

  2. Also, please tell me whether at the end ax will store the sum with carry or sum without carry. Because I am confused about whether adc takes CF set by its own addition or from any previous instruction which last affected the carry flag.
Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
agr
  • 127
  • 1
  • 12
  • 4
    If a hexadecimal number using an `h` suffix starts with a letter (a, b, c, d, e, f) it needs to be preceded by a 0 (zero). So `ar db ffh` needs to be `ar db 0ffh` – Michael Petch Mar 15 '17 at 04:11
  • 1
    The previously set _CF_ is used. `clc` clears the carry flag. so adc will always add a value of 0 (not 1) so is the equivalent of using `add` in that case, – Michael Petch Mar 15 '17 at 04:13
  • `adc` takes previous value of CF to allow you to add arbitrary bits long numbers. If you do `add` for first group of bits (least significant/lowest), then you can continue adding remaining groups of higher bits using `adc`, which will use the CF of previous group, and set up CF for next group, thus the bit exceeding your "group" limit is not lost, but propagates further into higher groups. The final overflow on the most significant bits addition will be the final CF value after such chain of `adc` instructions. – Ped7g Mar 15 '17 at 04:37
  • Thanks a lot guys – agr Mar 16 '17 at 07:31

2 Answers2

2

Use 0ffh because if you just write ffh, asembler would get confused wether its a number or a variable name.

-1

use 0ffh instead of ffh,you will get.

Here is the sample code...

.model small

.stack 64

.data

ar db 0ffh

.code

main proc far

mov ax,@data

mov ds,ax

mov ah,00h

mov al,ar

mov bx,40h

adc ax,bx

mov ah,4c00h

int 21h

main endp

end main


ax will store upto ffffh that is if you add two number in ax which will give result greater than ffffh(65535 in decimal number) then carry will contains the msb digit.

ex:

mov ax,1234

add ax,2345

;then ax will have 1234+2345 = 3579

but if

mov ax,fffeh

add ax,03h

;then ax will have 0001 and carry flag will contain 1.

Adarsh Jaiswal
  • 19
  • 1
  • 1
  • 4