Hi,
Can Anybody help me in writing a simple assembly program, like adding of two nos or assembly program for printf??
Printable View
Hi,
Can Anybody help me in writing a simple assembly program, like adding of two nos or assembly program for printf??
mov al, 5 [COLOR="Cyan"]; [COLOR="Red"]bin=00000101b [/COLOR][/COLOR]
mov bl, 10 [COLOR="red"] ; hex=0ah or bin=00001010b [/COLOR]
[COLOR="red"]; 5 + 10 = 15 (decimal) or hex=0fh or bin=00001111b [/COLOR]
add bl, al
[COLOR="red"]; 15 - 1 = 14 (decimal) or hex=0eh or bin=0000[/COLOR]1110b
sub bl, 1
[COLOR="red"]; print result in binary: [/COLOR]
mov cx, 8
print: mov ah, 2 [COLOR="red"]; print function. [/COLOR]
mov dl, '0'
test bl, 10000000b [COLOR="red"]; test first bit. [/COLOR]
jz zero
mov dl, '1'
zero:int 21h
shl bl, 1
loop print
[COLOR="red"]; print binary suffix: [/COLOR]
mov dl, 'b'
int 21h
[COLOR="red"]; wait for any key press: [/COLOR]
mov ah, 0
int 16h
ret
The above one using for 8086 processor and if you want more detail for sample programs then go through the following URL...
[url]http://www.emu8086.com/dr/asm2html/assembler_source_code/[/url]
----------------------
suresh
Yes i , can i have many solved programs of assembly here is your program
data segment
num1 db 20h
num2 db 18h
res db ?
data ends
code segment
assume cs:code, ds:data
mov ax, data ;initialize data segment
mov ds, ax mov al, num1 ;take first number in al
add al, num2 ;add the second to the number
mov res, al ;store the result in location res
mov dl,res
sub dl,30h
mov ah,02h
int 21h
code ends
mov ax, 4c00h ;exit to operating system
int 21h