![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
hi,
i had a problem converting a number to characters to output it to the screen. i solved this problem by writing a macro, but now when i try to call the macro 3 times within the same code i get the following error while compiling: Quote:
![]() since the code in the macro is put into the place where i put the calling, i get multiple labels with the same name. how can i make this work without having to create at least 3 different macros with as only difference the label names? here's the macro i have written: ;#################### ;printvalue macro ;print value 0234 = 234 ;#################### printvalue macro number push ax bx cx dx mov ax,number xor cx,cx thousand: cmp ax,1000 jl hundred sub ax,1000 inc cx jmp thousand hundred: cmp cx,0 je next1 mov bx,1 push ax mov dl,cl add dl,48 mov ah,02h int 21h pop ax xor cx,cx next1: cmp ax,100 jl ten sub ax,100 inc cx jmp next1 ten: cmp bx,1 je go_on cmp cx,0 je last go_on: mov bx,2 push ax mov dl,cl add dl,48 mov ah,02h int 21h pop ax xor cx,cx last: cmp ax,10 jl final sub ax,10 inc cx jmp last final: cmp bx,2 je next2 cmp cx,0 je finish next2: push ax mov dl,cl add dl,48 mov ah,02h int 21h pop ax finish: mov dl,al add dl,48 mov ah,02h int 21h pop dx cx bx ax endm ;################## i also don't want to create a procedure from this since i would like to use it in multiple programs without having to rewrite the proc everytime i start writing another program. any ideas? thanks in advance ![]()
__________________
http://www.white-scorpion.nl |
|
|
|
|
|
|
#2 |
|
Newbie
Join Date: Mar 2005
Location: South Africa
Posts: 21
Rep Power: 0
![]() |
This code seems rather long. If you're using it 3 times I strongly consider making into a proc. You can just drag the code to your new project if you wish.
__________________
Small is beautiful |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
thanks,
i'll keep that in mind as soon as i start working with 16-bit assembly again, currently i'm using masm32 a lot, as it is a lot more useful to me at this time.
__________________
http://www.white-scorpion.nl |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2005
Location: South Africa
Posts: 21
Rep Power: 0
![]() |
I found a proper solution. Use the @@: label and jmp @F or jmp @B to jump forwards or backwards to a @@ label.
__________________
Small is beautiful |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5
![]() |
Thanks, i know about the @@ labels now.. but like i said, i'm not really using 16-bits assembly at the moment.. i also know it is possible to use these labels with masm32, so it can indeed be a nice solution
![]()
__________________
http://www.white-scorpion.nl |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|