Page 2 of 2

Re: Nasm problem

Posted: Mon Oct 06, 2008 6:12 am
by sbeng77
Ok,
now i've added 0 and $ character.

org 100h

mov al,num1
add al,num2
add al,30h
add al,'$'

mov dx,ax
mov ah,09h
int 21h
mov ah,4Ch ; ah = 4Ch
int 21h

num1 db 5
num2 db 3

When i execute this code it show also some bad character and no sum result. :(

Re: Nasm problem

Posted: Mon Oct 06, 2008 6:18 am
by AJ
Please do the following:

1) Read my previous post paying attention to the bit which hints about learning the usage of [] for loading memory values.
2) Learn what a string is. When you take a character and add the value of '$', that does not make the character a '$' terminated string.
3) See the part about ensuring DS:DX points to the correct location. This does not mean that DX should contain the value you are wanting to print - it is a pointer
4) Before attempting this, you need to start by reading some assembly tutorials and familiarising yourself with some basic programming concepts (pointers, strings variables etc...).

Cheers,
Adam

Re: Nasm problem

Posted: Mon Oct 06, 2008 12:48 pm
by sbeng77
Ok i'll study them.
In my honest opinion exist too assembly version (nasm, tasm, masm for win/linux) and different syntax.
Thank you and excuse me!

Re: Nasm problem

Posted: Tue Oct 07, 2008 12:53 am
by sbeng77
I've result it!

org 100h

main:

mov al,num1
add al,num2
add al,'0'
mov ah,0EH
int 10h
num1 equ 3
num2 equ 6

I used int 10h (with value in al) and is ok. :)

Re: Nasm problem

Posted: Tue Oct 07, 2008 12:54 am
by sbeng77
sbeng77 wrote:I solved my sum question:

org 100h

main:

mov al,num1
add al,num2
add al,'0'
mov ah,0EH
int 10h
num1 equ 3
num2 equ 6

I used int 10h (with value in al) and is ok. :)

Re: Nasm problem

Posted: Tue Oct 07, 2008 10:59 am
by i586coder
Is the problem of how to print integer from register to screen :?:
if so,...,take look @ this code, may be useful for you,it's print the contents of AX register to screen

Code: Select all

print_ax proc
cmp ax, 0
jne print_ax_r
    push ax
    mov al, '0'
    mov ah, 0eh
    int 10h
    pop ax
    ret 
print_ax_r:
    pusha
    mov dx, 0
    cmp ax, 0
    je pn_done
    mov bx, 10
    div bx    
    call print_ax_r
    mov ax, dx
    add al, 30h
    mov ah, 0eh
    int 10h    
    jmp pn_done
pn_done:
    popa  
    ret  
endp
good luck :mrgreen:

Re: Nasm problem

Posted: Tue Oct 07, 2008 2:40 pm
by Combuster
In his case I'd add as homework to explain how that code works in detail. Just posting code won't really help in his case...

Re: Nasm problem

Posted: Wed Oct 08, 2008 6:46 am
by sbeng77
Exactly. :)