Asembler: Różnice pomiędzy wersjami

Z Nonsensopedii, polskiej encyklopedii humoru
(Dodałem kolorowanie składni asemblera.)
(sorry kurwa, ale składnia jest składnią.)
Linia 6: Linia 6:


== Hello World ==
== Hello World ==
<source lang="asm">
{|
TITLE hello-w
||
ss stos
<span style='color:#00f'><span style='color:#f00'>ss</span></span> stos
algin 1,1
<span style='color:#00f'>align</span> 1,1
<span style='color:#00f'>int</span> zero
int zero
<span style='color:#00f'>add</span> tekst
add tekst
.code
<span style='color:#08f'>.code</span>
<span style='color:#00f'>text</span> tekst
text tekst
wyswietl:
wyswietl:
<span style='color:#00f'>pop</span> stos,viewer
pop stos,viewer
<span style='color:#00f'>view</span> tekst
view tekst
<span style='color:#00f'>goto</span> przypisz
goto przypisz
<span style='color:#00f'>goto</span> wyswietl
goto wyswietl
.data
<span style='color:#08f'>.data</span>
kielich=kradnij(kielich)
kielich=kradnij(kielich)
kieliszek=kielich(zdrobienie,for (wino or winko))
kieliszek=kielich(zdrobienie,for (wino or winko))
Linia 28: Linia 28:
szklaneczka=zdrobnienie(szklanka))
szklaneczka=zdrobnienie(szklanka))
tekst=[[Hello World]]
tekst=[[Hello World]]
<span style='color:#00f'>txt</span> = tekst
txt = tekst
.code
<span style='color:#08f'>.code</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>
<span style='color:#00f'>txt</span> Hello
txt Hello
nop
<span style='color:#00f'>nop</span>
push dx
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
mov tekst,dx
<span style='color:#00f'>mov</span> tekst,<span style='color:#f00'>dx</span>
nop
<span style='color:#00f'>nop</span>
push
<span style='color:#00f'>push</span>
<span style='color:#00f'>open</span> piwo
open piwo
<span style='color:#00f'>wlej</span> kufel,piwo
wlej kufel,piwo
<span style='color:#00f'>pij</span> kufel
pij kufel
push ax
<span style='color:#00f'>push</span> <span style='color:#f00'>ax</span>
add ax,bx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>bx</span>
int 21h
<span style='color:#00f'>int</span> 21h
pop dx
<span style='color:#00f'>pop</span> <span style='color:#f00'>dx</span>
int 10h
<span style='color:#00f'>int</span> 10h
<span style='color:#00f'>newlist</span> lista,<span style='color:#f00'>dx</span>
newlist lista,dx
<span style='color:#00f'>open</span> wódka
open wódka
<span style='color:#00f'>wlej</span> wódka,szklaneczka
wlej wódka,szklaneczka
<span style='color:#00f'>pij</span> szklaneczka
pij szklaneczka
<span style='color:#00f'>add</span> szklaneczka,<span style='color:#f00'>bx</span>
add szklaneczka,bx
add bx,ax
<span style='color:#00f'>add</span> <span style='color:#f00'>bx</span>,<span style='color:#f00'>ax</span>
add dx,ax
<span style='color:#00f'>add</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>ax</span>
push dx
<span style='color:#00f'>push</span> <span style='color:#f00'>dx</span>
pop bx
<span style='color:#00f'>pop</span> <span style='color:#f00'>bx</span>
push cx
<span style='color:#00f'>push</span> <span style='color:#f00'>cx</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'>dx</span>
mov bx,ax
<span style='color:#00f'>mov</span> <span style='color:#f00'>bx</span>,<span style='color:#f00'>ax</span>
add ax,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>cx</span>
add ax,dx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>dx</span>
int 21h
<span style='color:#00f'>int</span> 21h
<span style='color:#00f'>open</span> bimber
open bimber
<span style='color:#00f'>wlej</span> bimber,beczka
wlej bimber,beczka
<span style='color:#00f'>pij</span> beczka
pij beczka
add ax,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>cx</span>
add cx,dx
<span style='color:#00f'>add</span> <span style='color:#f00'>cx</span>,<span style='color:#f00'>dx</span>
add dx,cx
<span style='color:#00f'>add</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>cx</span>
add ax,dx
<span style='color:#00f'>add</span> <span style='color:#f00'>ax</span>,<span style='color:#f00'>dx</span>
mov dx,cx
<span style='color:#00f'>mov</span> <span style='color:#f00'>dx</span>,<span style='color:#f00'>cx</span>
push cx
<span style='color:#00f'>push</span> <span style='color:#f00'>cx</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'>dx</span>
pop cs
<span style='color:#00f'>pop</span> <span style='color:#f00'>cs</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'>ds</span>
pop es
<span style='color:#00f'>pop</span> <span style='color:#f00'>es</span>
pop ds
<span style='color:#00f'>pop</span> <span style='color:#f00'>ds</span>
pop es
<span style='color:#00f'>pop</span> <span style='color:#f00'>es</span>
<span style='color:#00f'>open</span> wino
open wino
<span style='color:#00f'>wlej</span> wino,kieliszek
wlej wino,kieliszek
<span style='color:#00f'>pij</span> kieliszek
pij kieliszek
nop
<span style='color:#00f'>nop</span>
push
<span style='color:#00f'>push</span>
<span style='color:#00f'>exec</span> Hello
exec Hello
nop
<span style='color:#00f'>nop</span>
push
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>push</span>
push
<span style='color:#00f'>push</span>
<span style='color:#00f'>int</span> linie
int linie
push
<span style='color:#00f'>push</span>
nop
<span style='color:#00f'>nop</span>
Lista:
Lista:
(1)=:=Hello
(1)=:=Hello
(2)=:=World
(2)=:=World
nop
<span style='color:#00f'>nop</span>
push
<span style='color:#00f'>push</span>
nop
<span style='color:#00f'>nop</span>
nop
<span style='color:#00f'>nop</span>
push
<span style='color:#00f'>push</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>
push
<span style='color:#00f'>push</span>
<span style='color:#00f'>create</span> LIST,Lista2
create LIST,Lista2
aint i
<span style='color:#00f'>a<span style='color:#00f'>int</span></span> i
<span style='color:#00f'>char</span> znak
char znak
Przypisz:
Przypisz:
i=znak(number)
i=znak(number)
znak-i
znak-i
<span style='color:#00f'>add</span> Lista2(i),znak
add Lista2(i),znak
<span style='color:#00f'>push</span> znak
push znak
<span style='color:#00f'>goto</span> przypisz
goto przypisz
end
<span style='color:#00f'>end</span>
Lista: Lista
Lista: Lista
</source>
|}


== Przykład programowania systemu ==
== Przykład programowania systemu ==
Linia 138: Linia 138:


W asemblerze rozwiązanie tego samego problemu wygląda tak:
W asemblerze rozwiązanie tego samego problemu wygląda tak:
<source lang="asm">

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

[[en:Assembly language]]
[[en:Assembly language]]
[[ru:Ассемблер]]
[[ru:Ассемблер]]

Wersja z 21:17, 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

 TITLE hello-w
 ss stos
 algin 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:

 .data
   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