guys i need to translate it in masm assembler because i've made this code in emu8086 and unfortunately there are many errors...plsss help me...i've made my job...but the problem is my instructor tell me suddenly that masm should be the assembler....
.model small
.stack 100h
.data
msg db 'Enter hex: $'
msg2 db 0ah,0dh,'Enter hex: $'
buf db 5,6 dup('$')
buf2 db 3,4 dup('$')
msg3 db 0ah,0dh,'The quotient is: ',0ah,0dh,'$'
.code
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,buf
int 21h
mov cx,0h
mov cl,buf[1]
mov bx,2h
again:
sub buf,30h
cmp buf,10h
jg alpha
here:
inc bx
loop again:
mov ah,09h
lea dx,msg2
int 21h
mov ah,0ah
lea dx,buf2
int 21h
mov cx,0h
mov cl,buf2[1]
mov bx,2h
again2:
sub buf2,30h
cmp buf2,10h
jg alpha2
here2:
inc bx
loop again2:
mov ax,0h
mov ax,buf[2]
shl al,04h
add ah,al
mov dh,ah
mov ax,0h
mov ax,buf[4]
shl al,04h
add ah,al
mov cx,0h
mov cx,buf2[2]
shl cx,01h
mov cx,buf[3]
mov al,dh
xchg al,ah
mov bx,0h
mov bx,buf2[2]
mov dl,buf2[1]
cmp dl,01h
je dex
shl bl,04h
ambs:
add bh,bl
mov bl,bh
mov bh,00h
mov dx,0h
div bx
mov dl,ah
and dl,0F0h
shr dl,04h
mov buf[2],dl
mov dl,ah
and dl,0Fh
mov buf[3],dl
mov dl,al
and dl,0F0h
shr dl,04h
mov buf[4],dl
mov dl,al
and dl,0Fh
mov buf[5],dl
mov bx,2h
mov cx,0h
mov cl,buf[1]
res:
cmp buf,0Ah
jg alp
add buf,30h
this:
inc bx
loop res
mov ah,09h
lea dx,msg3
int 21h
mov cx,0h
mov bx,002h
mov cl,buf[1]
ans:
mov dl,0h
mov dl,buf
mov ah,02h
int 21h
inc bx
loop ans
mov ax,4c00h
int 21h
dex proc
mov bh,0h
jmp ambs
dex endp
alp proc
cmp buf,0Ah
je alpA
cmp buf,0Bh
je alpB
cmp buf,0Ch
je alpC
cmp buf,0Dh
je alpD
cmp buf,0Eh
je alpE
cmp buf,0Fh
je alpF
alp endp
alpha proc
sub buf,10h
cmp buf,1h
je alA
cmp buf,2h
je alB
cmp buf,3h
je alC
cmp buf,4h
je alD
cmp buf,5h
je alE
cmp buf,6h
je alF
alpha endp
alpha2 proc
sub buf2,10h
cmp buf2,1h
je alA2
cmp buf2,2h
je alB2
cmp buf2,3h
je alC2
cmp buf2,4h
je alD2
cmp buf2,5h
je alE2
cmp buf2,6h
je alF2
alpha2 endp
alA proc
mov buf,0Ah
jmp here
alA endp
alB proc
mov buf,0Bh
jmp here
alB endp
alC proc
mov buf,0Ch
jmp here
alC endp
alD proc
mov buf,0Dh
jmp here
alD endp
alE proc
mov buf,0Eh
jmp here
alE endp
alF proc
mov buf,0Fh
jmp here
alF endp
alA2 proc
mov buf2,0Ah
jmp here2
alA2 endp
alB2 proc
mov buf2,0Bh
jmp here2
alB2 endp
alC2 proc
mov buf2,0Ch
jmp here2
alC2 endp
alD2 proc
mov buf2,0Dh
jmp here2
alD2 endp
alE2 proc
mov buf2,0Eh
jmp here2
alE2 endp
alF2 proc
mov buf2,0Fh
jmp here2
alF2 endp
alpA proc
mov buf,41h
jmp this
alpA endp
alpB proc
mov buf,42h
jmp this
alpB endp
alpC proc
mov buf,43h
jmp this
alpC endp
alpD proc
mov buf,44h
jmp this
alpD endp
alpE proc
mov buf,45h
jmp this
alpE endp
alpF proc
mov buf,46h
jmp this
alpF endp
and i've tried to compile it on tasm because they are much related but i also have an error like this
Assembling file: draft.asm
**Error** draft.asm(33) Need expression
**Error** draft.asm(54) Need expression
**Error** draft.asm(57) Operand types do not match
**Error** draft.asm(63) Operand types do not match
**Error** draft.asm(68) Operand types do not match
**Error** draft.asm(70) Operand types do not match
**Error** draft.asm(77) Operand types do not match
*Warning* draft.asm(112) Reserved word used as symbol: THIS
**Fatal** draft.asm(278) Unexpected end of file encountered
Error messages: 8
Warning messages: 1
Passes: 1
Remaining memory: 446k
plss help me..i'm in a nick of time to pass this subject...btw that is 8086 version of asm
.model small
.stack 100h
.data
msg db 'Enter hex: $'
msg2 db 0ah,0dh,'Enter hex: $'
buf db 5,6 dup('$')
buf2 db 3,4 dup('$')
msg3 db 0ah,0dh,'The quotient is: ',0ah,0dh,'$'
.code
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,buf
int 21h
mov cx,0h
mov cl,buf[1]
mov bx,2h
again:
sub buf,30h
cmp buf,10h
jg alpha
here:
inc bx
loop again:
mov ah,09h
lea dx,msg2
int 21h
mov ah,0ah
lea dx,buf2
int 21h
mov cx,0h
mov cl,buf2[1]
mov bx,2h
again2:
sub buf2,30h
cmp buf2,10h
jg alpha2
here2:
inc bx
loop again2:
mov ax,0h
mov ax,buf[2]
shl al,04h
add ah,al
mov dh,ah
mov ax,0h
mov ax,buf[4]
shl al,04h
add ah,al
mov cx,0h
mov cx,buf2[2]
shl cx,01h
mov cx,buf[3]
mov al,dh
xchg al,ah
mov bx,0h
mov bx,buf2[2]
mov dl,buf2[1]
cmp dl,01h
je dex
shl bl,04h
ambs:
add bh,bl
mov bl,bh
mov bh,00h
mov dx,0h
div bx
mov dl,ah
and dl,0F0h
shr dl,04h
mov buf[2],dl
mov dl,ah
and dl,0Fh
mov buf[3],dl
mov dl,al
and dl,0F0h
shr dl,04h
mov buf[4],dl
mov dl,al
and dl,0Fh
mov buf[5],dl
mov bx,2h
mov cx,0h
mov cl,buf[1]
res:
cmp buf,0Ah
jg alp
add buf,30h
this:
inc bx
loop res
mov ah,09h
lea dx,msg3
int 21h
mov cx,0h
mov bx,002h
mov cl,buf[1]
ans:
mov dl,0h
mov dl,buf
mov ah,02h
int 21h
inc bx
loop ans
mov ax,4c00h
int 21h
dex proc
mov bh,0h
jmp ambs
dex endp
alp proc
cmp buf,0Ah
je alpA
cmp buf,0Bh
je alpB
cmp buf,0Ch
je alpC
cmp buf,0Dh
je alpD
cmp buf,0Eh
je alpE
cmp buf,0Fh
je alpF
alp endp
alpha proc
sub buf,10h
cmp buf,1h
je alA
cmp buf,2h
je alB
cmp buf,3h
je alC
cmp buf,4h
je alD
cmp buf,5h
je alE
cmp buf,6h
je alF
alpha endp
alpha2 proc
sub buf2,10h
cmp buf2,1h
je alA2
cmp buf2,2h
je alB2
cmp buf2,3h
je alC2
cmp buf2,4h
je alD2
cmp buf2,5h
je alE2
cmp buf2,6h
je alF2
alpha2 endp
alA proc
mov buf,0Ah
jmp here
alA endp
alB proc
mov buf,0Bh
jmp here
alB endp
alC proc
mov buf,0Ch
jmp here
alC endp
alD proc
mov buf,0Dh
jmp here
alD endp
alE proc
mov buf,0Eh
jmp here
alE endp
alF proc
mov buf,0Fh
jmp here
alF endp
alA2 proc
mov buf2,0Ah
jmp here2
alA2 endp
alB2 proc
mov buf2,0Bh
jmp here2
alB2 endp
alC2 proc
mov buf2,0Ch
jmp here2
alC2 endp
alD2 proc
mov buf2,0Dh
jmp here2
alD2 endp
alE2 proc
mov buf2,0Eh
jmp here2
alE2 endp
alF2 proc
mov buf2,0Fh
jmp here2
alF2 endp
alpA proc
mov buf,41h
jmp this
alpA endp
alpB proc
mov buf,42h
jmp this
alpB endp
alpC proc
mov buf,43h
jmp this
alpC endp
alpD proc
mov buf,44h
jmp this
alpD endp
alpE proc
mov buf,45h
jmp this
alpE endp
alpF proc
mov buf,46h
jmp this
alpF endp
and i've tried to compile it on tasm because they are much related but i also have an error like this
Assembling file: draft.asm
**Error** draft.asm(33) Need expression
**Error** draft.asm(54) Need expression
**Error** draft.asm(57) Operand types do not match
**Error** draft.asm(63) Operand types do not match
**Error** draft.asm(68) Operand types do not match
**Error** draft.asm(70) Operand types do not match
**Error** draft.asm(77) Operand types do not match
*Warning* draft.asm(112) Reserved word used as symbol: THIS
**Fatal** draft.asm(278) Unexpected end of file encountered
Error messages: 8
Warning messages: 1
Passes: 1
Remaining memory: 446k
plss help me..i'm in a nick of time to pass this subject...btw that is 8086 version of asm
The problems are due to your choice of memory model.
Your relative jumps are too far apart.
Your relative jumps are too far apart.
umm what would i do to fix that?? could you give me example homer?? please
Hi web4,
I'm Nasmist, and can't help you with Masm syntax (if you're supposed to use Masm, use Masm - Tasm is not quite the same...). Perhaps I can make some suggestions that will help...
I don't understand what Homer says about the "memory model" being wrong. The problem, I think, is that your "conditional jumps" (je, etc.) are out of range - they'll only go forward or backward 127 bytes in your code. You've apparently tried "far", which is not what you want. What you might want is "near" jumps. However, those instructions weren't available on the 8086. To enable them, I think Masm wants ".286" (or better), but if you're supposed to be using 8086 code, there's a workaround:
cmp ax, bx
je someplace
...
If "someplace" is too far away, you can do:
cmp ax, bx
jne notsomeplace
jmp someplace
notsomeplace:
...
Better, if you can do it, is to rearrange your code so the so your jumps are in range. Look at some of the "nearly repetitive" parts of your code. Can you see any "patterns" that you could take advantage of? For example...
sub buf, 10h
cmp buf, 1
je alA
cmp buf, 2
je alB
...
Then at "alA"...
alA proc
mov buf,0Ah
jmp here
alA endp
alB proc
mov buf,0Bh
jmp here
alB endp
...
Could you....
mov al, buf
sub al, 10h
cmp al, 1
jb not_this_routine
cmp al, 6
ja not_this_routine
add al, 9
mov buf, al
not this routine:
cmp al, ???
...
You use "proc" and "endp" a lot. Do you know what they do? Usually, they'd be used in a PROCedure that's "call"ed and "ret"urned from. Do you know how to use "call" and "ret"? Learning them might simplify your code a lot.
To be honest, I think you should start over - don't worry, you can use most of the same code. First, just write comments to indicate what you need to do:
; display first prompt
; get first number from user
; (what do you do if the idiot enters something wrong?)
; convert text to number
; store first number
; display second prompt
; get second number from user
; convert text to number
; store second number
; divide first number by second number
; convert number to text
; display the quotient
...
I think it will help you organize your code so that the conditional jumps are in range, and will make it easier to follow your code. I can't really tell if your code would work as intended - looks like it might be good with tomato sauce and basil. :)
Don't worry, it gets easier as you go along...
Best,
Frank
I'm Nasmist, and can't help you with Masm syntax (if you're supposed to use Masm, use Masm - Tasm is not quite the same...). Perhaps I can make some suggestions that will help...
I don't understand what Homer says about the "memory model" being wrong. The problem, I think, is that your "conditional jumps" (je, etc.) are out of range - they'll only go forward or backward 127 bytes in your code. You've apparently tried "far", which is not what you want. What you might want is "near" jumps. However, those instructions weren't available on the 8086. To enable them, I think Masm wants ".286" (or better), but if you're supposed to be using 8086 code, there's a workaround:
cmp ax, bx
je someplace
...
If "someplace" is too far away, you can do:
cmp ax, bx
jne notsomeplace
jmp someplace
notsomeplace:
...
Better, if you can do it, is to rearrange your code so the so your jumps are in range. Look at some of the "nearly repetitive" parts of your code. Can you see any "patterns" that you could take advantage of? For example...
sub buf, 10h
cmp buf, 1
je alA
cmp buf, 2
je alB
...
Then at "alA"...
alA proc
mov buf,0Ah
jmp here
alA endp
alB proc
mov buf,0Bh
jmp here
alB endp
...
Could you....
mov al, buf
sub al, 10h
cmp al, 1
jb not_this_routine
cmp al, 6
ja not_this_routine
add al, 9
mov buf, al
not this routine:
cmp al, ???
...
You use "proc" and "endp" a lot. Do you know what they do? Usually, they'd be used in a PROCedure that's "call"ed and "ret"urned from. Do you know how to use "call" and "ret"? Learning them might simplify your code a lot.
To be honest, I think you should start over - don't worry, you can use most of the same code. First, just write comments to indicate what you need to do:
; display first prompt
; get first number from user
; (what do you do if the idiot enters something wrong?)
; convert text to number
; store first number
; display second prompt
; get second number from user
; convert text to number
; store second number
; divide first number by second number
; convert number to text
; display the quotient
...
I think it will help you organize your code so that the conditional jumps are in range, and will make it easier to follow your code. I can't really tell if your code would work as intended - looks like it might be good with tomato sauce and basil. :)
Don't worry, it gets easier as you go along...
Best,
Frank
thanks fbkotler i really appreciate your time reading my source code that is too long....and i've minize it because you point out my mistake...but the one you discuss about the "conditional jumps" part i don't get it...i'm sorry you can really see from my code that i am really a noob..
Ahhh... conditional jumps... ja, jae, jb, jbe, jc, jg, jl,... jz. There are quite a few of them! On the 8086, these were available only in "short" form. On the 80186 (maybe not until 80286), a "near" form was introduced which will jump a longer distance. As an experiment, try adding ".286" to the top of your code (not sure whether it goes before or after ".model small" - RTFM). This will enable Masm/Tasm to use those instructions. If that helps any, check with your instructor whether you're allowed to use it.
You seem to understand the dos interrupts you need to use, so you're off to a good start there. You might benefit from studying the routine you found by searching "hex string" in the other thread. It's 32-bit, so you won't be able to use it directly, but figure out what it does, and you can do it in 16-bit code. The first version given should be fast enough for your purposes. :)
If you've got time, look into the "call" and "ret" instructions. A subroutine will allow you to convert both text inputs into numbers with one routine, but you can do it "inline" twice (or jumping from place to place) as you're doing, if you don't have time to learn that...
Again, comment your code. It will not only help us folks reading it (and get you a better grade!), but it'll help you keep track of what you're doing, and what you need to do next.
Don't worry about being a "noob". Nobody was born knowing this stuff. It takes a while to "get" it.
Best,
Frank
You seem to understand the dos interrupts you need to use, so you're off to a good start there. You might benefit from studying the routine you found by searching "hex string" in the other thread. It's 32-bit, so you won't be able to use it directly, but figure out what it does, and you can do it in 16-bit code. The first version given should be fast enough for your purposes. :)
If you've got time, look into the "call" and "ret" instructions. A subroutine will allow you to convert both text inputs into numbers with one routine, but you can do it "inline" twice (or jumping from place to place) as you're doing, if you don't have time to learn that...
Again, comment your code. It will not only help us folks reading it (and get you a better grade!), but it'll help you keep track of what you're doing, and what you need to do next.
Don't worry about being a "noob". Nobody was born knowing this stuff. It takes a while to "get" it.
Best,
Frank
.model small
.stack 100h
.data
msg db 'Enter hex: $'
msg2 db 0ah,0dh,'Enter hex: $'
buf db 5,6 dup('$')
buf2 db 3,4 dup('$')
msg3 db 0AH,0DH,'The quotient is: $'
.code
start:
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,buf
int 21h
mov cx,0h
mov cl,buf[1]
mov bx,2h
again:
mov al,buf
sub al,30h
call well
mov buf,al
inc bx
loop again
mov ah,09h
lea dx,msg2
int 21h
mov ah,0ah
lea dx,buf2
int 21h
mov cx,0h
mov cl,buf2[1]
mov bx,2h
again2:
mov al,buf2
sub al,30h
mov buf2,al
call well
mov buf2,al
inc bx
loop again2
mov ax,0h
mov al,buf[2]
shl al,01h
shl al,01h
shl al,01h
shl al,01h
mov ah,buf[3]
add ah,al
mov dh,ah
mov ax,0h
mov al,buf[4]
shl al,01h
shl al,01h
shl al,01h
shl al,01h
mov ah,buf[5]
add ah,al
mov cx,0h
mov cl,buf2[2]
shl cx,01h
mov cl,buf[3]
mov al,dh
xchg al,ah
mov bx,0h
mov bl,buf2[2]
mov dl,buf2[1]
cmp dl,01h
je dex
ambs:
shl bl,01h
shl bl,01h
shl bl,01h
shl bl,01h
mov bh,buf2[3]
add bh,bl
mov bl,bh
mov bh,00h
mov dx,0h
div bx
mov dl,ah
and dl,0F0h
shr dl,01h
shr dl,01h
shr dl,01h
shr dl,01h
mov buf[2],dl
mov dl,ah
and dl,0Fh
mov buf[3],dl
mov dl,al
and dl,0F0h
shr dl,01h
shr dl,01h
shr dl,01h
shr dl,01h
mov buf[4],dl
mov dl,al
and dl,0Fh
mov buf[5],dl
mov bx,2h
mov cx,0h
mov cl,buf[1]
res:
mov al,buf
add al,7h
cmp al,10h
jl let
add al,30h
lab:
mov buf,al
inc bx
loop res
MOV BUF,'$'
mov ah,09h
lea dx,msg3
int 21h
MOV AH,09H
LEA DX,BUF
ADD DX,2
INT 21H
mov ah, 01h
int 21h
mov ax,4c00h
int 21h
dex:
mov bh,0h
jmp ambs
well proc
cmp al,10h
jg alpha
here:
ret
well endp
alpha:
sub al,10h
cmp al,1h
je alA
cmp al,2h
je alB
cmp al,3h
je alC
cmp al,4h
je alD
cmp al,5h
je alE
cmp al,6h
je alF
alA:
mov al,0Ah
jmp here
alB:
mov al,0Bh
jmp here
alC:
mov al,0Ch
jmp here
alD:
mov al,0Dh
jmp here
alE:
mov al,0Eh
jmp here
alF:
mov al,0Fh
jmp here
let:
sub al,7h
add al,30h
jmp lab
main endp
end start
I have given up....don't know what the errors means....
draft2.asm(164): error a2006 :alpha
draft2.asm(186): error a2006 :here
draft2.asm(190): error a2006 :here
draft2.asm(194): error a2006 :here
draft2.asm(198): error a2006 :here
draft2.asm(202): error a2006 :here
draft2.asm(206): error a2006 :here
please help me...don't know what are the meaning of the error a2006 because it seems my code works well in other compiler but my instructor tells us to do in masm611
you could download my assembler here:
http://downloadzone.ucoz.com/publ/14-1-0-24
.stack 100h
.data
msg db 'Enter hex: $'
msg2 db 0ah,0dh,'Enter hex: $'
buf db 5,6 dup('$')
buf2 db 3,4 dup('$')
msg3 db 0AH,0DH,'The quotient is: $'
.code
start:
main proc
mov ax,@data
mov ds,ax
mov ah,09h
lea dx,msg
int 21h
mov ah,0ah
lea dx,buf
int 21h
mov cx,0h
mov cl,buf[1]
mov bx,2h
again:
mov al,buf
sub al,30h
call well
mov buf,al
inc bx
loop again
mov ah,09h
lea dx,msg2
int 21h
mov ah,0ah
lea dx,buf2
int 21h
mov cx,0h
mov cl,buf2[1]
mov bx,2h
again2:
mov al,buf2
sub al,30h
mov buf2,al
call well
mov buf2,al
inc bx
loop again2
mov ax,0h
mov al,buf[2]
shl al,01h
shl al,01h
shl al,01h
shl al,01h
mov ah,buf[3]
add ah,al
mov dh,ah
mov ax,0h
mov al,buf[4]
shl al,01h
shl al,01h
shl al,01h
shl al,01h
mov ah,buf[5]
add ah,al
mov cx,0h
mov cl,buf2[2]
shl cx,01h
mov cl,buf[3]
mov al,dh
xchg al,ah
mov bx,0h
mov bl,buf2[2]
mov dl,buf2[1]
cmp dl,01h
je dex
ambs:
shl bl,01h
shl bl,01h
shl bl,01h
shl bl,01h
mov bh,buf2[3]
add bh,bl
mov bl,bh
mov bh,00h
mov dx,0h
div bx
mov dl,ah
and dl,0F0h
shr dl,01h
shr dl,01h
shr dl,01h
shr dl,01h
mov buf[2],dl
mov dl,ah
and dl,0Fh
mov buf[3],dl
mov dl,al
and dl,0F0h
shr dl,01h
shr dl,01h
shr dl,01h
shr dl,01h
mov buf[4],dl
mov dl,al
and dl,0Fh
mov buf[5],dl
mov bx,2h
mov cx,0h
mov cl,buf[1]
res:
mov al,buf
add al,7h
cmp al,10h
jl let
add al,30h
lab:
mov buf,al
inc bx
loop res
MOV BUF,'$'
mov ah,09h
lea dx,msg3
int 21h
MOV AH,09H
LEA DX,BUF
ADD DX,2
INT 21H
mov ah, 01h
int 21h
mov ax,4c00h
int 21h
dex:
mov bh,0h
jmp ambs
well proc
cmp al,10h
jg alpha
here:
ret
well endp
alpha:
sub al,10h
cmp al,1h
je alA
cmp al,2h
je alB
cmp al,3h
je alC
cmp al,4h
je alD
cmp al,5h
je alE
cmp al,6h
je alF
alA:
mov al,0Ah
jmp here
alB:
mov al,0Bh
jmp here
alC:
mov al,0Ch
jmp here
alD:
mov al,0Dh
jmp here
alE:
mov al,0Eh
jmp here
alF:
mov al,0Fh
jmp here
let:
sub al,7h
add al,30h
jmp lab
main endp
end start
I have given up....don't know what the errors means....
draft2.asm(164): error a2006 :alpha
draft2.asm(186): error a2006 :here
draft2.asm(190): error a2006 :here
draft2.asm(194): error a2006 :here
draft2.asm(198): error a2006 :here
draft2.asm(202): error a2006 :here
draft2.asm(206): error a2006 :here
please help me...don't know what are the meaning of the error a2006 because it seems my code works well in other compiler but my instructor tells us to do in masm611
you could download my assembler here:
http://downloadzone.ucoz.com/publ/14-1-0-24
Hi web4,
"I have given up..."
No, no, no, no no! There are three important rules for learning asm.
1) never give up
2) never give up
3) never give up
Besides, you're really close! You've really only got one error - " a2006" - and on two labels. That's a lot better than when you started off!
Being Nasmist (I thought Nasm's error messages were unhelpful!), I have no idea what "a2006" means. I could download Masm - I ASSume there are docs? - and look it up, but you might as well learn to do it. Probably not the last error message you'll see! :)
I'll take a wild guess, though. I notice that both of the labels barfing up errors are between "proc" and "endp". I'm going to guess that these are "local" labels, "visible" only within the procedure. A simple way to test this theory would be to comment out "well proc" and "well endp". Just put "well:" before your procedure... and of course it ends with "ret" (congratulations!). "proc" and "endp" are fine macros, and in some cases they generate useful code. In this case, I'm pretty sure they aren't generating anything you need, and they may be screwing you up. I hope this theory is correct - it might solve all your problems. Well... might get it to assemble - there "could" still be bugs. :)
You might also be able to improve this code further...
alA:
mov al,0Ah
jmp here
alB:
mov al,0Bh
jmp here
alC:
mov al,0Ch
jmp here
alD:
mov al,0Dh
jmp here
...
Can you see a "pattern" developing here? If al is greater than 10, we jump off to "alpha", where we subtract 10 from al, and then if al = 1, jump off to put 0Ah in al, if al =2, put 0Bh in al... and then, in each case, jump back to "here:". Would an "add" instruction help here? If you could squeeze all that cruft inside your "well" "proc", it might work even with the "proc" and "endp" (but I still don't think they do anything for ya).
To make this work, you might need to reverse the sense of the "conditional jumps" we were discussing. They all (almost all?) have "n" forms - "jg alpha", "jng not_alpha"...
As I was reading through your code, I thought "this is looking good!", so I was disappointed to see the errors at the end, but I don't think it's too "serious". You still need to think about what you're going to do with invalid input (check ASAP, is my advice). And note that the "div" instruction gives you both quotient and remainder. For "extra credit", you might want to show the remainder, too. Depends on how much time you've got...
Best,
Frank
"I have given up..."
No, no, no, no no! There are three important rules for learning asm.
1) never give up
2) never give up
3) never give up
Besides, you're really close! You've really only got one error - " a2006" - and on two labels. That's a lot better than when you started off!
Being Nasmist (I thought Nasm's error messages were unhelpful!), I have no idea what "a2006" means. I could download Masm - I ASSume there are docs? - and look it up, but you might as well learn to do it. Probably not the last error message you'll see! :)
I'll take a wild guess, though. I notice that both of the labels barfing up errors are between "proc" and "endp". I'm going to guess that these are "local" labels, "visible" only within the procedure. A simple way to test this theory would be to comment out "well proc" and "well endp". Just put "well:" before your procedure... and of course it ends with "ret" (congratulations!). "proc" and "endp" are fine macros, and in some cases they generate useful code. In this case, I'm pretty sure they aren't generating anything you need, and they may be screwing you up. I hope this theory is correct - it might solve all your problems. Well... might get it to assemble - there "could" still be bugs. :)
You might also be able to improve this code further...
alA:
mov al,0Ah
jmp here
alB:
mov al,0Bh
jmp here
alC:
mov al,0Ch
jmp here
alD:
mov al,0Dh
jmp here
...
Can you see a "pattern" developing here? If al is greater than 10, we jump off to "alpha", where we subtract 10 from al, and then if al = 1, jump off to put 0Ah in al, if al =2, put 0Bh in al... and then, in each case, jump back to "here:". Would an "add" instruction help here? If you could squeeze all that cruft inside your "well" "proc", it might work even with the "proc" and "endp" (but I still don't think they do anything for ya).
To make this work, you might need to reverse the sense of the "conditional jumps" we were discussing. They all (almost all?) have "n" forms - "jg alpha", "jng not_alpha"...
As I was reading through your code, I thought "this is looking good!", so I was disappointed to see the errors at the end, but I don't think it's too "serious". You still need to think about what you're going to do with invalid input (check ASAP, is my advice). And note that the "div" instruction gives you both quotient and remainder. For "extra credit", you might want to show the remainder, too. Depends on how much time you've got...
Best,
Frank
Ah, it's my favorite: MASM versions. MASM 5.1 (without defined language type) treats labels inside PROC … ENDP as global, MASM 6.11 assumes they're local to enclosing PROC (thus reference can't cross PROC boundary). Add OPTION NOSCOPED directive somewhere at the beginning, it will fix this issue.
How do you expect to learn MASM (or whatever) without manuals?
How do you expect to learn MASM (or whatever) without manuals?
Thank you so much baldr...you are truly a masm expert....thank very much also fbkotler for keeping me realizing on where to improve my poor codings....thank you so much!!!! God bless you