Nasm problem

Programming, for all ages and all languages.
sbeng77
Posts: 17
Joined: Mon Sep 29, 2008 8:06 am
Contact:

Re: Nasm problem

Post 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. :(
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Nasm problem

Post 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
sbeng77
Posts: 17
Joined: Mon Sep 29, 2008 8:06 am
Contact:

Re: Nasm problem

Post 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!
sbeng77
Posts: 17
Joined: Mon Sep 29, 2008 8:06 am
Contact:

Re: Nasm problem

Post 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. :)
sbeng77
Posts: 17
Joined: Mon Sep 29, 2008 8:06 am
Contact:

Re: Nasm problem

Post 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. :)
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Nasm problem

Post 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:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Nasm problem

Post 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...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
sbeng77
Posts: 17
Joined: Mon Sep 29, 2008 8:06 am
Contact:

Re: Nasm problem

Post by sbeng77 »

Exactly. :)
Post Reply