Hereby the code i have wrote about a small porgram to to find the maximum number from three numbers.
Waiting your comments,,,
GET AX;
MOV BX,AS;
GET AX;
MOV CX, AX;
GET AX;
CMP AX,BX;
CMP AX,CX
Put AX
End
Hereby the code i have wrote about a small porgram to to find the maximum number from three numbers.
Waiting your comments,,,
GET AX;
MOV BX,AS;
GET AX;
MOV CX, AX;
GET AX;
CMP AX,BX;
CMP AX,CX
Put AX
End
And this works? It's better if you mention whether the code works or not so we can adjust our comments accordingly. Here are the things that I took note of:
>MOV BX,AS;
This looks like a typo, and you probably meant AX. You also don't need to terminate a statement with a semicolon in assembly. What you're doing is starting an empty comment. It's harmless, but confusing.
>CMP AX,BX;
>CMP AX,CX
>Put AX
How is this supposed to place the largest of the three values in AX? The cmp instruction doesn't write to either of its operands, so you're basically setting the flags for ax-bx, then overwriting the flags with ax-cx. Whatever ax was originally is printed, so your algorithm won't work as you intend.
You need to either print the correct register, or move the correct value to AX, and that means a conditional test, which means a jump:
cmp ax,bx
jnl .axbigger1
mov ax,bx
.axbigger1:
cmp ax,cx
jnl .axbigger2
mov ax,cx
.axbigger2:
put ax
That's the obvious way to do it. You can play math arithmetic games, but that destroys clarity.
Thanks,
But what do you mean by : jnl
Thanks,
But what do you mean by : jnl
The mnemonic jnl means jump if not less
Here's code that finds the maximum value in an array
of bytes.
bits 16
org 100h
start:
mov bx, arr
mov al, [bx]
xor di, di
inc di
start_l:
cmp byte [bx+di], 0
jz exit
cmp al, [bx+di]
jb swap
return:
inc di
jmp start_l
swap:
mov al, [bx+di]
jmp return
exit:
xor ah, ah
call disphex
int 0x20
arr db 2, 3, 1, 0
disphex:
push ax
shr ax, 8
call dispbyte
pop ax
push ax
and ax, 0xff
call dispbyte
pop ax
ret
dispbyte:
push ax
shr al, 4
call dispasc
pop ax
push ax
and al, 0xf
call dispasc
pop ax
ret
dispasc:
push ax
push dx
add al, 0x30
cmp al, 0x39
jle dispasc_e
add al, 0x7
dispasc_e:
mov dl, al
mov ah, 2
int 0x21
pop dx
pop ax
ret
here's code that finds the maximum value in an array
of bytes.bits 16 org 100h start: Mov bx, arr mov al, [bx] xor di, di inc di start_l: Cmp byte [bx+di], 0 jz exit cmp al, [bx+di] jb swap return: Inc di jmp start_l swap: Mov al, [bx+di] jmp return exit: Xor ah, ah call disphex int 0x20 arr db 2, 3, 1, 0 disphex: Push ax shr ax, 8 call dispbyte pop ax push ax and ax, 0xff call dispbyte pop ax ret dispbyte: Push ax shr al, 4 call dispasc pop ax push ax and al, 0xf call dispasc pop ax ret dispasc: Push ax push dx add al, 0x30 cmp al, 0x39 jle dispasc_e add al, 0x7 dispasc_e: Mov dl, al mov ah, 2 int 0x21 pop dx pop ax ret
heres a dos debug prog which makes a fractal.
N fractal.com
a
xor ax,ax
mov ax,0002
int 12
mov ah,00
mov al,13
int 10
xor ax,ax
mov ax,4f02
mov bx,0100
int 10
mov ax,a000
mov es,ax
loop 011c
xor di,di
xor dx,dx
wait
finit
fld dword ptr [01ae]
fstp dword ptr [01be]
xor bx,bx
fld dword ptr [01aa]
fstp dword ptr [01ba]
wait
finit
fldz
fldz
mov cx,0040
fld st(0)
fmul st,st(0)
fxch st(1)
fmul st,st(2)
fadd st,st(0)
fxch st(2)
fmul st,st(0)
fsubp st(1),st
fxch st(1)
fadd dword ptr [01be]
fxch st(1)
fadd dword ptr [01ba]
fld st(1)
fmul st,st(0)
fld st(1)
fmul st,st(0)
faddp st(1),st
fsqrt
fistp word ptr [01c2]
cmp word ptr [01c2],+02
ja 0176
loop 0141
mov al,cl
stosb
fld dword ptr [01ba]
fadd dword ptr [01b2]
fstp dword ptr [01ba]
inc bx
cmp bx,0140
jb 0137
fld dword ptr [01be]
fsub dword ptr [01b6]
fstp dword ptr [01be]
inc dx
cmp dx,00c8
jb 012d
xor ah,ah
int 16
mov ax,0003
int 10
int 20
int cc
or al,c0
add [bx+si],al
mov al,[9a3f]
cwd
sbb [si],di
int cc
dec sp
cmp al,8b
r cx
100
w
q
i have a problem though. I want only one on the screen in the same resolution which it is currently? Any suggestions?
Thank you very much if you can help, and also for trying...
Also, how do you get your posted code in those funky colors?
Much appreciated.
please send me afull assembly code for maximum fider from three numbers
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.