;============================================================================================================================================ ; K_deck_2.asm ;Shows all the cards in the deck. [], if it is tagged ; Algorithm ;B1. X=TOP(X - symbolic link, it now points to the upper card) ;B2. If X=0 then stop. It was the last card in deck ;B31. If Tag(X)=1 Then show '[' and goto B33 ;B321. If Tag(X)=0 show rank ;B322. if Tag(X)=0 show suit. Goto B34 ;B331. Show rank ;B332. Show suit,show ']' ;B34. X<-Next(X). Goto B2 ;ŠI don't take any responsibility for the use of this program ; Zedr0n -- connection closed ;============================================================================================================================================ ;============================================================================================================================================ ; .Com declaration ;============================================================================================================================================ .model tiny .code org 100h ;============================================================================================================================================= ; Structures ;============================================================================================================================================= Card struc TAG db 0 SUIT db 1 RANK db 2 NEXT dw 0 Card ends start: ;============================================================================================================================================ ; Code segment ;============================================================================================================================================ B1: mov ah,09h mov dx, offset result int 21h mov ax,Top mov X,ax B2: cmp X,0 jz exit B31: xor ax,ax mov ah,02h mov bx,X mov al,[bx].card.tag cmp al,1 jnz B321 mov dl,'[' int 21h jmp B331 B321: ;<> xor ax,ax mov al,[bx].card.rank call ConvertRank cmp al,11 jge B322 call hexdec call output ;<> B322: mov dl,[bx].card.suit mov ah,02h add dl,2h int 21h ;<> mov ah,09h mov dx,offset crlf int 21h jmp B34 B331: ;<> xor ax,ax mov al,[bx].card.rank call ConvertRank cmp al,11 jge B332 call hexdec call output B332: ;<> mov dl,[bx].card.suit mov ah,02h add dl,2h int 21h mov dl,']' int 21h ;<> mov ah,09h mov dx,offset crlf int 21h B34: mov ax,[bx].card.next mov X,ax jmp B2 exit: xor ax,ax int 16h mov ah,9h mov dx,offset signature int 21h ret ;============================================================================================================================================= ; Convert 11->‚,12->„,13->Š,14->’ ;============================================================================================================================================= ConvertRank proc push dx push ax mov ah,02h cmp al,11 jge V jmp ex V: cmp al,12 jge D mov dl,'‚' int 21h jmp ex D: cmp al,13 jge K mov dl,'„' int 21h jmp ex K: cmp al,14 jge T mov dl,'Š' int 21h jmp ex T: mov dl,'’' int 21h ex: pop ax pop dx ret ConvertRank endp ;============================================================================================================================================= ; Convert hexadecimal in ax to decimal in dx ;============================================================================================================================================= hexdec proc mov dx,ax mov si,offset divtab ;pointer subtract values mov di,offset numbuff ;output buffer mov cx,5 ;5 digits sublop: xor al,al ;clear counter sblop: cmp dx,[si] ;number < subractor ? jb tolow ;yeah sub dx,[si] ;noo, subtract add al,1 ;incrase times subtracted jmp sblop ;subtract again tolow: add al,30h ;make ascii stosb ;store in buffer add si,2 ;next subtractor loop sublop ;do it mov al,0 ;null terminate buffer stosb mov si,offset numbuff ret divtab: ;subractor values dw 10000 dw 1000 dw 100 dw 10 dw 1 numbuff db 34 dup(0) ;number buffer hexdec endp ;============================================================================================================================================= ; Outputs buffer with ascii, where si points to buffer ;============================================================================================================================================= output proc strip: lodsb ;load byte cmp al,'0' ;any leading zeroes ? jne nozero ;noo jmp strip ;yeahh, check next nozero: dec si ;adjust that back one byte lodsb out: mov dl,al mov ah,02h int 21h lodsb cmp al,0 jnz out ; xor ah,ah ; int 16h ret output endp signature db 0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah, db " --------------------------------- ",0Dh,0Ah, db " \ Zedr0n - connection closed / ",0Dh,0Ah, db " \ 24.10.2001 / ",0Dh,0Ah, db " ----------------------------- ",0Dh,0Ah, db 0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0Dh,0Ah, db '$' second card {TAG=0,SUIT=1,RANK=9,NEXT=fourth} first card {TAG=0,SUIT=3,RANK=13,NEXT=third} third card {TAG=0,SUIT=3,RANK=6,NEXT=second} fourth card {TAG=0,SUIT=2,RANK=5,NEXT=fifth} fifth card {TAG=0,SUIT=3,RANK=12,NEXT=sixth} sixth card {TAG=0,SUIT=4,RANK=14,NEXT=0} Top dw first X dw ? crlf db 0Dh,0Ah,'$' result db " Cards in deck:",0Dh,0Ah,"$" end start