Asembler: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(Dodałem kolorowanie składni asemblera.)
Linia 8: Linia 8:
{|
{|
||
||
<span style='color:#00f'><span style='color:#f00'>ss</span></span> stos
TITLE hello-w
<span style='color:#00f'>align</span> 1,1
ss stos
<span style='color:#00f'>int</span> zero
algin 1,1
<span style='color:#00f'>add</span> tekst
int zero
<span style='color:#08f'>.code</span>
add tekst
<span style='color:#00f'>text</span> tekst
.code
text tekst
wyswietl:
wyswietl:
pop stos,viewer
<span style='color:#00f'>pop</span> stos,viewer
view tekst
<span style='color:#00f'>view</span> tekst
goto przypisz
<span style='color:#00f'>goto</span> przypisz
goto wyswietl
<span style='color:#00f'>goto</span> wyswietl
<span style='color:#08f'>.data</span>
.data
kielich=kradnij(kielich)
kielich=kradnij(kielich)
kieliszek=kielich(zdrobienie,for (wino or winko))
kieliszek=kielich(zdrobienie,for (wino or winko))
Linia 29: Linia 28:
szklaneczka=zdrobnienie(szklanka))
szklaneczka=zdrobnienie(szklanka))
tekst=[[Hello World]]
tekst=[[Hello World]]
txt = tekst
<span style='color:#00f'>txt</span> = tekst
<span style='color:#08f'>.code</span>
.code
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
txt Hello
<span style='color:#00f'>txt</span> Hello
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
push dx
<span style='color:#00f'>mov</span> tekst,<span style='color:#f00'>dx</span>
mov tekst,dx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
open piwo
<span style='color:#00f'>open</span> piwo
wlej kufel,piwo
<span style='color:#00f'>wlej</span> kufel,piwo
pij kufel
<span style='color:#00f'>pij</span> kufel
<span style='color:#00f'>push</span> <span style='color:#f00'>ax</span>
push ax
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>bx</span>
add ax,bx
<span style='color:#00f'>int</span> 21h
int 21h
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>int</span> 10h
int 10h
newlist lista,dx
<span style='color:#00f'>newlist</span> lista,<span style='color:#f00'>dx</span>
open wódka
<span style='color:#00f'>open</span> wódka
wlej wódka,szklaneczka
<span style='color:#00f'>wlej</span> wódka,szklaneczka
pij szklaneczka
<span style='color:#00f'>pij</span> szklaneczka
add szklaneczka,bx
<span style='color:#00f'>add</span> szklaneczka,<span style='color:#f00'>bx</span>
<span style='color:#00f'>add</span> <span style='color:#f00'>bx</span>,<span style='color:#f00'>ax</span>
add bx,ax
<span style='color:#00f'>add</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>ax</span>
add dx,ax
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
push dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>bx</span>
pop bx
<span style='color:#00f'>push</span> <span style='color:#f00'>cx</span>
push cx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>mov</span> <span style='color:#f00'>bx</span>,<span style='color:#f00'>ax</span>
mov bx,ax
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>cx</span>
add ax,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>dx</span>
add ax,dx
<span style='color:#00f'>int</span> 21h
int 21h
open bimber
<span style='color:#00f'>open</span> bimber
wlej bimber,beczka
<span style='color:#00f'>wlej</span> bimber,beczka
pij beczka
<span style='color:#00f'>pij</span> beczka
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>cx</span>
add ax,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>cx</span>,<span style='color:#f00'>dx</span>
add cx,dx
<span style='color:#00f'>add</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>cx</span>
add dx,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>dx</span>
add ax,dx
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>cx</span>
mov dx,cx
<span style='color:#00f'>push</span> <span style='color:#f00'>cx</span>
push cx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>cs</span>
pop cs
<span style='color:#00f'>pop</span> <span style='color:#f00'>ds</span>
pop ds
<span style='color:#00f'>pop</span> <span style='color:#f00'>ds</span>
pop ds
<span style='color:#00f'>pop</span> <span style='color:#f00'>es</span>
pop es
<span style='color:#00f'>pop</span> <span style='color:#f00'>ds</span>
pop ds
<span style='color:#00f'>pop</span> <span style='color:#f00'>es</span>
pop es
open wino
<span style='color:#00f'>open</span> wino
wlej wino,kieliszek
<span style='color:#00f'>wlej</span> wino,kieliszek
pij kieliszek
<span style='color:#00f'>pij</span> kieliszek
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
exec Hello
<span style='color:#00f'>exec</span> Hello
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>push</span>
push
int linie
<span style='color:#00f'>int</span> linie
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>nop</span>
nop
Lista:
Lista:
(1)=:=Hello
(1)=:=Hello
(2)=:=World
(2)=:=World
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span>
push
create LIST,Lista2
<span style='color:#00f'>create</span> LIST,Lista2
<span style='color:#00f'>a<span style='color:#00f'>int</span></span> i
aint i
char znak
<span style='color:#00f'>char</span> znak
Przypisz:
Przypisz:
i=znak(number)
i=znak(number)
znak-i
znak-i
add Lista2(i),znak
<span style='color:#00f'>add</span> Lista2(i),znak
push znak
<span style='color:#00f'>push</span> znak
goto przypisz
<span style='color:#00f'>goto</span> przypisz
<span style='color:#00f'>end</span>
end
Lista: Lista
Lista: Lista
|}
|}
Linia 140: Linia 139:
W asemblerze rozwiązanie tego samego problemu wygląda tak:
W asemblerze rozwiązanie tego samego problemu wygląda tak:


<span style='color:#00f'>align</span> 1024
.data
align 1024
wino dw 2 ; 1
wino dw 2 ; 1
kiełbasa dw 5 ; 2
kiełbasa dw 5 ; 2
Linia 148: Linia 146:
dodaj dd 0 ; |
dodaj dd 0 ; |
ile dw 3 ; <-
ile dw 3 ; <-
<span style='color:#08f'>.code</span>
.code
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
jmp start
<span style='color:#00f'>jmp</span> start
dodawaj proc near
dodawaj proc near
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ax</span>
push ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>sub</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>ax</span>
sub ax,ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ds</span>
push ds
<span style='color:#00f'>nop</span>
nop
mov ds, seg w_sumie
<span style='color:#00f'>mov</span> <span style='color:#f00'>ds</span>, seg w_sumie
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
push dx
<span style='color:#00f'>nop</span>
nop
mov dx, offset w_sumie
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>, <span style='color:#08f'>offset</span> w_sumie
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>ds</span>:<span style='color:#f00'>dx</span>, <span style='color:#f00'>ax</span>
mov ds:dx, ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>, <span style='color:#08f'>offset</span> ile
mov dx, offset ile
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ecx</span>
push ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>cx</span>, <span style='color:#f00'>ds</span>:<span style='color:#f00'>dx</span>
mov cx, ds:dx
<span style='color:#00f'>nop</span>
nop
int cyferka=0
<span style='color:#00f'>int</span> cyferka=0
cyferka+1=
cyferka+1=
drukuj
<span style='color:#00f'>drukuj</span>
lista:
lista:
0+0
0+0
888=888
888=888
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>, <span style='color:#08f'>offset</span> wino
mov dx, offset wino
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>dx</span>
dec dx
<span style='color:#00f'>nop</span>
nop
align 4096
<span style='color:#00f'>align</span> 4096
lista:
lista:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>dx</span>
inc dx
<span style='color:#00f'>nop</span>
nop
call proc
call proc
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>dx</span>
inc dx
<span style='color:#00f'>nop</span>
nop
loop lista
<span style='color:#00f'>loop</span> lista
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>ecx</span>
pop ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>ds</span>
pop ds
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>ax</span>
pop ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>ret</span>
ret
dodawaj endp
dodawaj <span style='color:#00f'>end</span>p
dodaj proc near
dodaj proc near
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ecx</span>
push ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>xor</span> <span style='color:#f00'>ecx</span>, <span style='color:#f00'>ecx</span>
xor ecx, ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>cx</span>, <span style='color:#f00'>ds</span>:<span style='color:#f00'>dx</span>
mov cx, ds:dx
<span style='color:#00f'>nop</span>
nop
jmp bbb
<span style='color:#00f'>jmp</span> bbb
align 3
<span style='color:#00f'>align</span> 3
aaa:
aaa:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>bx</span>, <span style='color:#f00'>ds</span>:<span style='color:#f00'>dx</span>
mov bx, ds:dx
<span style='color:#00f'>nop</span>
nop
align 65536
<span style='color:#00f'>align</span> 65536
dodawanie:
dodawanie:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bx</span>
inc bx
<span style='color:#00f'>nop</span>
nop
loop dodawanie
<span style='color:#00f'>loop</span> dodawanie
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>ds</span>:<span style='color:#f00'>dx</span>, <span style='color:#f00'>bx</span>
mov ds:dx, bx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
pop dx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>bx</span>
pop bx
<span style='color:#00f'>nop</span>
nop
jmp ccc
<span style='color:#00f'>jmp</span> ccc
align 49
<span style='color:#00f'>align</span> 49
bbb:
bbb:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>bx</span>
push bx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
push dx
<span style='color:#00f'>nop</span>
nop
mov dx, offset w_sumie
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>, <span style='color:#08f'>offset</span> w_sumie
jmp aaa
<span style='color:#00f'>jmp</span> aaa
align 107
<span style='color:#00f'>align</span> 107
ccc:
ccc:
<span style='color:#00f'>pop</span> <span style='color:#f00'>ecx</span>
pop ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>ret</span>
ret
endp dodaj
<span style='color:#00f'>endp</span> dodaj
pisz proc near
pisz proc near
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>bp</span>
push bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>bp</span>, 3
mov bp, 3
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ax</span>
push ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>bx</span>
push bx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ah</span>
inc ah
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ah</span>
inc ah
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>sub</span> <span style='color:#f00'>bx</span>, <span style='color:#f00'>bx</span>
sub bx, bx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>push</span> <span style='color:#f00'>ecx</span>
push ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>ecx</span>, 1
mov ecx, 1
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>add</span> <span style='color:#f00'>ecx</span>,2
add ecx,2
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>bp</span>
inc bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>ecx</span>
inc ecx
<span style='color:#00f'>nop</span>
nop
align 32768
<span style='color:#00f'>align</span> 32768
znak1:
znak1:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>and</span> <span style='color:#f00'>ah</span>, 0
and ah, 0
<span style='color:#00f'>nop</span>
nop
or ah, 1
or <span style='color:#f00'>ah</span>, 1
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>add</span> <span style='color:#f00'>dl</span>, <span style='color:#f00'>ah</span>
add dl, ah
<span style='color:#00f'>nop</span>
nop
shl <span style='color:#f00'>ah</span>, <span style='color:#f00'>ah</span>
shl ah, ah
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>add</span> <span style='color:#f00'>dl</span>, <span style='color:#f00'>ah</span>
add dl, ah
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>inc</span> <span style='color:#f00'>dl</span>
inc dl
<span style='color:#00f'>nop</span>
nop
loop znak1
<span style='color:#00f'>loop</span> znak1
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>xor</span> <span style='color:#f00'>ah</span>, <span style='color:#f00'>ah</span>
xor ah, ah
<span style='color:#00f'>nop</span>
nop
int 21h
<span style='color:#00f'>int</span> 21h
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>add</span> <span style='color:#f00'>ecx</span>, <span style='color:#f00'>bp</span>
add ecx, bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>ecx</span>
dec ecx
<span style='color:#00f'>nop</span>
nop
align 8192
<span style='color:#00f'>align</span> 8192
znak2:
znak2:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>dl</span>
dec dl
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>dl</span>
dec dl
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>dl</span>
dec dl
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>dec</span> <span style='color:#f00'>dl</span>
dec dl
<span style='color:#00f'>nop</span>
nop
loop znak2
<span style='color:#00f'>loop</span> znak2
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>ecx</span>
pop ecx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>bx</span>
pop bx
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>ax</span>
pop ax
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>pop</span> <span style='color:#f00'>bp</span>
pop bp
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>ret</span>
ret
endp pisz
<span style='color:#00f'>endp</span> pisz
align 2048
<span style='color:#00f'>align</span> 2048
start:
start:
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
nop
call dodawaj
call dodawaj
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>dl</span>, 1
mov dl, 1
<span style='color:#00f'>nop</span>
nop
call pisz
call pisz
<span style='color:#00f'>nop</span>
nop
call pisz
call pisz
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>mov</span> <span style='color:#f00'>ax</span>,4c00h
mov ax,4c00h
<span style='color:#00f'>nop</span>
nop
int 21h
<span style='color:#00f'>int</span> 21h
<span style='color:#00f'>nop</span>
nop


[[en:Assembly language]]
[[en:Assembly language]]

Wersja z 18:30, 25 sty 2014


Ten artykuł jest częścią cyklu naukowego języki komputerowe.

Języki programowania:


Inne języki komputerowe:


edytuj ten szablon
Plik:Disassembler.PNG
Przez disassemblera można nawet disassemblowac obrazki!

Szablon:Twielgachna rodzina języków programowania wymyślonych w celu utrudniania życia ludzkości. Programy zapisane w asemblerach są wręcz nieludzko długie, w związku z czym wykorzystywane są głównie przez prawdziwych hakerów i ich organy nabyte, potocznie zwane komputerami.

Hello World

ss stos
align 1,1
int zero
add tekst
.code
text tekst
wyswietl:
pop stos,viewer
view tekst
goto przypisz
goto wyswietl
.data
kielich=kradnij(kielich)
kieliszek=kielich(zdrobienie,for (wino or winko))
kufel=kubek(szklany,duży,for (piwo(jasne or ciemne) or piwko(jasne or ciemne)))
beka=znaczenie(2(kradnij(beka,drewniana)),1(beknij(głośno)))
beczka=beka(zdrobnienie,znaczenie(2))
szklanka=kradnij(szklanka))
szklaneczka=zdrobnienie(szklanka))
tekst=Hello World
txt = tekst
.code
nop
nop
nop
nop
nop
txt Hello
nop
push dx
mov tekst,dx
nop
push
open piwo
wlej kufel,piwo
pij kufel
push ax
add ax,bx
int 21h
pop dx
int 10h
newlist lista,dx
open wódka
wlej wódka,szklaneczka
pij szklaneczka
add szklaneczka,bx
add bx,ax
add dx,ax
push dx
pop bx
push cx
pop dx
pop dx
pop dx
mov bx,ax
add ax,cx
add ax,dx
int 21h
open bimber
wlej bimber,beczka
pij beczka
add ax,cx
add cx,dx
add dx,cx
add ax,dx
mov dx,cx
push cx
pop dx
pop dx
pop dx
pop cs
pop ds
pop ds
pop es
pop ds
pop es
open wino
wlej wino,kieliszek
pij kieliszek
nop
push
exec Hello
nop
push
push
push
int linie
push
nop
Lista:
(1)=:=Hello
(2)=:=World
nop
push
nop
nop
push
nop
nop
nop
nop
nop
nop
nop
nop
push
create LIST,Lista2
aint i
char znak
Przypisz:
i=znak(number)
znak-i
add Lista2(i),znak
push znak
goto przypisz
end
Lista: Lista

Przykład programowania systemu

Tak problem wygląda dla zwyczajnego człowieka:

        Wino za 2 zł
    Kiełbasa za 5 zł
 +     Fajki za 4 zł
--------------------
    W sumie:   11 zł

W asemblerze rozwiązanie tego samego problemu wygląda tak:

align 1024
  wino     dw 2   ;    1
  kiełbasa dw 5   ;    2
  fajki    dw 4   ;    3
  w_sumie  dw ?   ;    |
  dodaj    dd 0   ;    |
  ile      dw 3   ;  <-
.code
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  nop
  jmp start
 dodawaj proc near
  nop
  push ax
  nop
  sub ax,ax
  nop
  push ds
  nop
  mov ds, seg w_sumie
  nop
  push dx
  nop
  mov dx, offset w_sumie
  nop
  mov ds:dx, ax
  nop
  mov dx, offset ile
  nop
  push ecx
  nop
  mov cx, ds:dx
  nop
  int cyferka=0
  cyferka+1=
  drukuj
  lista:
  0+0
  888=888 
  mov dx, offset wino
  nop
  dec dx
  nop
  align 4096
  lista:
   nop
   inc dx
   nop
   call proc
   nop
   inc dx
   nop
  loop lista
  nop
  pop ecx
  nop
  pop dx
  nop
  pop ds
  nop
  pop ax
  nop
  ret
 dodawaj endp
 dodaj proc near
  nop
  push ecx
  nop
  xor ecx, ecx
  nop
  mov cx, ds:dx
  nop
  jmp bbb
 align 3
 aaa:
  nop
  mov bx, ds:dx
  nop
  align 65536
  dodawanie:
   nop
   inc bx
   nop
  loop dodawanie
  nop
  mov ds:dx, bx
  nop
  pop dx
  nop
  pop bx
  nop
  jmp ccc
 align 49
 bbb:
  nop
  push bx
  nop
  push dx
  nop
  mov dx, offset w_sumie
  jmp aaa
 align 107
 ccc:
  pop ecx
  nop
  ret
 endp dodaj
 pisz proc near
  nop
  push bp
  nop
  mov bp, 3
  nop
  push ax
  nop
  inc bp
  nop
  inc bp
  nop
  push bx
  nop
  inc bp
  nop
  inc ah
  nop
  inc bp
  nop
  inc ah
  nop
  inc bp
  nop
  sub bx, bx
  nop
  inc bp
  nop
  push ecx
  nop
  inc bp
  nop
  mov ecx, 1
  nop
  inc bp
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc bp
  nop
  add ecx,2
  nop
  inc bp
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc ecx
  nop
  inc ecx
  nop
  align 32768
  znak1:
   nop
   and ah, 0
   nop
   or  ah, 1
   nop
   add dl, ah
   nop
   shl ah, ah
   nop
   add dl, ah
   nop
   inc dl
   nop
  loop znak1
  nop
  xor ah, ah
  nop
  int 21h
  nop
  add ecx, bp
  nop
  dec ecx
  nop
  align 8192
  znak2:
   nop
   dec dl
   nop
   dec dl
   nop
   dec dl
   nop
   dec dl
   nop
  loop znak2
  nop
  pop ecx
  nop
  pop bx
  nop
  pop ax
  nop
  pop bp
  nop
  ret
 endp pisz
 align 2048
 start:
  nop
  nop
  nop
  nop
  nop
  nop
  call dodawaj
  nop
  mov dl, 1
  nop
  call pisz
  nop
  call pisz
  nop
  mov ax,4c00h
  nop
  int 21h
  nop