.comment-link {margin-left:.6em;}

Ikatan Cendikiawan Patah Hati

One for All... All for One!

Dilbert Pearls Before Swine

Sunday, March 19

kuis assembly dono

; ------
; kuis2.asm
; 0104920292 - 4pct
; #01.940623.940623.13.$01
; ------

PAGE 59,132

kuis2 segment
assume cs:kuis2,ds:kuis2
org 100h

jmp start

author db 13,10,'*** Demo String Putar-putar - '
db '(w)0104920292 ***',10
db 13,10,'Input String : $'
crlf db 13,10,'$'
outstr db 13, 'Output String : $'
quitstr db 13,10,10,'*** Done ***',13,10,'$'

inp_rec db 26 ; input max 25 char
len_inp db ? ; var penampung panjang input
inpstr db 27 dup ('$') ; var penampung string putar-putar

push cs
pop es ; seg.es = seg.cs

mov ax,3
int 10h ; cls

lea dx,author ; cetak nama
call printstr

mov ah,0ah ; read string ke inpstr
lea dx,inp_rec
int 21h

mov cx,2020h ; kursor hilang
call chg_curs

lea dx,crlf ; writeln
call printstr

lea si,inpstr
call rollstr ; putar string dengan
; dari awal inpstr sampai '$'
lea dx,outstr
call printstr

lea dx,inpstr ; cetak string terputar
call printstr

call keypress
cmp al,0 ; if keypressed then quit
jne short quit
jmp main_loop

lea dx,quitstr
call printstr

mov cx,09h ; kursor muncul
call chg_curs

mov ax,4c00h ; back to dos
int 21h

;--- procs

rollstr proc near
xor cx,cx
mov cl,len_inp
or cl,cl ; quit if cl=0
jz @psquit

dec cl
add si,cx
mov al,byte ptr [si]
mov tmp_ch,al ; tampung huruf paling kanan
mov bl,byte ptr [si-1]
mov byte ptr [si],bl ; move string ke kanan
dec si ; sebanyak satu langkah
call delayer
loop @llop

mov al,tmp_ch
mov byte ptr [si],al
tmp_ch db ? ; variabel penampung
rollstr endp ; huruf paling kanan

printstr proc near
push ax
mov ah,9
int 21h
pop ax
printstr endp

chg_curs proc near
push ax
mov ah,1
int 10h
pop ax
chg_curs endp

keypress proc near ; function keypressed
mov ah,6 ; keypressed := al <> 0
mov dl,0ffh
xor al,al
int 21h
keypress endp

delayer proc near
push cx
mov cx,0ffffh
loop @looop
pop cx
delayer endp

kuis2 ends
end command

; --- eof---

and nowadays instead of using the code above, we are talking about writing codes for running on top of virtual machine on the server...

useless education? ;P


Post a Comment

Links to this post:

Create a Link

<< Home