org 100h mulai: xor ax,ax xor bx,bx mov ax,3h int 10h call awal call pilih mov ah,1 int 21h cmp al,31h je pros8 cmp al,32h je pros16 cmp al,33h je exit jne mulai pros8: call menu call pilih mov ah,1 int 21h call cek8 dtob: mov ah,9 lea dx,baris int 21h ;Konversi 8Bit Desimal Ke Biner call input_16dec call proses_8hex call lagi dtoh: mov ah,9 lea dx,baris int 21h ;Konversi 8Bit Desimal Ke hexa call input_16dec call proses_8dech call lagi btod: mov ah,9 lea dx,baris int 21h ;Konversi 8Bit Biner Ke Desimal lea dx,cbin int 21h call input_8bin call proses_8bin CALL PROSES_8SIGN call lagi btoh: mov ah,9 lea dx,baris int 21h lea dx,cbin ;Konversi 8Bit Biner Ke Hexa int 21h call input_8bin call proses_8binh call lagi htod: mov ah,9 lea dx,baris int 21h ;Konversi 8Bit Hexa Ke Desimal lea dx,chex int 21h call input_8hex call proses_8bin CALL PROSES_8SIGN call lagi htob: mov ah,9 lea dx,baris int 21h ;Konversi 8Bit Hexa Ke Biner lea dx,chex int 21h call input_8hex call proses_8hex call lagi pros16: call menu call pilih mov ah,1 int 21h call cek16 dtob16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Desimal Ke Biner call input_16dec call proses_16hexbin call lagi dtoh16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Desimal Ke Biner call input_16dec CALL PROSES_16dechex call lagi btod16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Biner Ke Desimal lea dx,cbin int 21h call input_16bin call proses_16bindec btoh16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Biner Ke Hexa lea dx,cbin int 21h call input_16bin call proses_16dechex call lagi htod16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Hexa Ke Desimal lea dx,chex int 21h call input_16hex call proses_16bindec htob16: mov ah,9 lea dx,baris int 21h ;Konversi 16Bit Hexa Ke Biner lea dx,chex int 21h call input_16hex CALL proses_16hexbin1 call lagi exit: mov ah,9 lea dx,maskie int 21h lea dx,maskie1 int 21h mov ah,4ch int 21h ;Keluar ret baris db 0ah,0dh,'$' msg db 'CONVERTER SEDERHANA $' psn1 db ' 1. 8-bit $' psn2 db ' 2. 16-bit $' psn3 db ' 3. selesai $' pil db 'Masukkan Pilihan Anda : $' menu1 db ' 1. Desimal ke Biner $' menu2 db ' 2. Desimal ke Hexadesimal $' menu3 db ' 3. Biner ke Desimal $' menu4 db ' 4. Biner ke Hexadesimal $' menu5 db ' 5. Hexadesimal ke Desimal $' menu6 db ' 6. Hexadesimal ke Biner $' menu7 db ' 7. Selesai $' cdes db 'Masukkan Angka Desimal : $' hcdes db 'Hasil Konversi Biner : $' ulang db 0AH,0DH, 'Mau ulangi program (y/t) ? $' hcdes1 db 'Hasil Konversi Hexadesimal : $' cbin db 'Masukan Angka Biner : $' hcbin db 'Unsigned : $' hcbin1 db 'Hasil Konversi Hexadesimal : $' chex db 'Masukkan Hexadesimal : $' hchex db 'Hasil Konversi Desimal : $' hchex1 db 'Hasil Konversi Biner : $' SIGN DB 'Sign : $' ket db 'Hasil Konversi Desimal $' a dw ? d dw ? c db ? x db ? one dw ? z db ? P DB ? Q DB ? L DW ? M DW ? MINUSZ DB '-$' table db '0123456789ABCDEF';TABEL XLAT result db 16 dup('x'), 'b' OVER DB 'OVERFLOW (DILUAR BATAS)$' maskie db 0ah,0dh,0ah,0dh, ' AUTHOR:MASKIE $' maskie1 db 0ah,0dh,0ah,0dh, ' email:maskie06@yahoo.com $' awal proc mov ah,9 lea dx,msg int 21h lea dx,baris int 21h lea dx,psn1 int 21h lea dx,baris int 21h lea dx,psn2 int 21h lea dx,baris int 21h lea dx,psn3 int 21h ret awal endp pilih proc mov ah,9 lea dx,baris int 21h lea dx,pil int 21h ret pilih endp menu proc mov ah,9 lea dx,baris int 21h lea dx,menu1 int 21h lea dx,baris int 21h lea dx,menu2 int 21h lea dx,baris int 21h lea dx,menu3 int 21h lea dx,baris int 21h lea dx,menu4 int 21h lea dx,baris int 21h lea dx,menu5 int 21h lea dx,baris int 21h lea dx,menu6 int 21h lea dx,baris int 21h lea dx,menu7 int 21h ret menu endp cek8 proc cmp al,31h je dtob cmp al,32h je dtoh cmp al,33h je btod cmp al,34h je btoh cmp al,35h je htod cmp al,36h je htob cmp al,37h je exit jne mulai ret cek8 endp cek16 proc cmp al,31h je dtob16 cmp al,32h je dtoh16 cmp al,33h je btod16 cmp al,34h je btoh16 cmp al,35h je htod16 cmp al,36h je htob16 cmp al,37h je exit jne mulai ret cek16 endp input_16dec PROC PUSH BX PUSH CX PUSH Dx BEGIN: MOV AH,9 MOV dx,offset cdes ;Inputan 16Bit desimal bertanda dan tak bertanda INT 21h XOR BX,BX XOR CX,CX MOV AH,1 INT 21h CMP AL,'-' JE MINUS CMP AL,'+' JE PLUS JMP REPEAT2 MINUS: MOV CX,1 mov z,1 PLUS: INT 21h REPEAT2: CMP AL,'0' JNGE NOT_DIGIT CMP AL,'9' JNLE NOT_DIGIT AND AX,000Fh PUSH AX MOV AX,10 MUL BX POP BX jo overflow ADD BX,AX jc overflow MOV AH,1 INT 21h CMP AL,0Dh JNE REPEAT2 MOV AX,BX OR CX,CX JE keluar NEG AX keluar: POP DX POP CX POP BX jmp lanjuts1 RET NOT_DIGIT: MOV AH,2 MOV DL,0Dh INT 21h MOV DL,0Ah INT 21h JMP BEGIN lanjuts1: mov bx,ax ret input_16dec ENDP input_8bin proc mov cx,8 xor bx,bx mov ah,1 int 21h while8b: cmp al,0dh je end_while8b ;Inputan 8Bit Biner cmp al,31h jg mulai cmp al,30h jl mulai and al,0Fh shl bx,1 or bl,al cmp cl,1 je end_while8b int 21h loop while8b end_while8b: ret input_8bin endp input_16bin proc ;Inputan 16Bit biner mov cx,16 xor bx,bx mov ah,1 int 21h while16b: cmp al,0dh je end_while16b cmp al,31h jg mulai cmp al,30h jl mulai and al,0Fh shl bx,1 or bl,al cmp cl,1 je end_while16b int 21h loop while16b end_while16b: ret input_16bin endp input_8hex proc ;Inputan 8Bit Untuk Hexa mov cx,2 mov ah,1 int 21h while8h: cmp al,0dh je end_while8h cmp al,46h jg PERIKSA cmp al,30h jl mulai PERIKSA: CMP AL,66H JG MULAI cmp al,39h jg huruf8h and al,0Fh jmp geser8h huruf8h: sub al,37h AND AL,0FH geser8h: shl bl,4 or bl,al cmp cl,1 je end_while8h int 21h loop while8h end_while8h: ret input_8hex endp input_16hex proc mov cx,4 mov ah,1 int 21h while16h: cmp al,0dh je end_while16h cmp al,46h jg periksa1 cmp al,30h jl mulai periksa1: CMP AL,66H JG MULAI cmp al,39h jg huruf16h and al,0Fh jmp geser16h huruf16h: sub al,37h and al,0fh geser16h: shl bx,4 or bl,al cmp cl,1 je end_while16h int 21h loop while16h end_while16h: ret input_16hex endp proses_8bin proc mov ah,9 lea dx,baris int 21h lea dx,baris int 21h lea dx,ket int 21h lea dx,baris int 21h lea dx,hcbin int 21h xor dx,dx xor ax,ax mov ax,bx call print_al ret print_al proc cmp al, 0 jne print_al_r push ax mov al, '0' mov ah, 0eh int 10h pop ax ret print_al_r: pusha mov ah, 0 cmp ax, 0 je pn_done mov dl, 10 div dl call print_al_r mov al, ah add al, 30h mov ah, 0eh int 10h jmp pn_done pn_done: popa ret endp proses_8hex proc cmp bx,255d jg overflow cmp bx,-128d jl overflow mov ah,9 lea dx,baris int 21h lea dx,hchex1 int 21h xor dx,dx xor ax,ax MOV AX,BX print_al_bin proc pusha ; tampilkan hasil dalam binary mov cx, 8 mov bl, al p1: mov ah, 2 ; fungsi cetak mov dl, '0' test bl, 10000000b ; test bit pertama jz zero mov dl, '1' zero: int 21h shl bl, 1 loop p1 mov dl, 'b' int 21h ; garis baru/enter mov dl, 0Dh int 21h mov dl, 0Ah int 21h popa ret endp proses_8dech proc cmp bx,255d jg overflow cmp bx,-128d jl overflow MOV Z,AL MOV AH,9 LEA DX,BARIS INT 21H LEA DX,hcbin1 INT 21H XOR DX,DX ; jalankan alamat data tabel di bx MOV DL,Z lea bx, table mov al, dl shr al, 4 xlat ;untuk 4 bit pertama mov ah, 0eh int 10h mov al, dl and al, 0fh ;4 bit berikutnya xlat mov ah, 0eh int 10h ret proses_8binh proc MOV Z,bl MOV AH,9 LEA DX,BARIS INT 21H LEA DX,HCbin1 INT 21H XOR DX,DX ; jalankan alamat data tabel di bx MOV DL,Z lea bx, table mov al, dl shr al, 4 ;untuk 4 bit pertama xlat mov ah, 0eh int 10h mov al, dl and al, 0fh xlat mov ah, 0eh ;4 bit berikutnya int 10h ret selesai: mov ah,4ch int 21h ret proses_16hexbin1 proc MOV AH,9 LEA DX,BARIS INT 21H LEA DX,HCHEX1 INT 21H XOR AX,AX CALL convert_to_bin mov si, offset result ; set alamat buffer si. mov ah, 0eh mov cx, 17 ; cetak 16 bit plus akhiran 'b' print_me: mov al, [si] int 10h inc si loop print_me mov ah, 0 ret convert_to_bin proc near pusha lea di, result ;cetak hasil dalam binary mov cx, 16 print: mov ah, 2 ; print function. mov [di], '0' test bx, 1000_0000_0000_0000b ; test bit pertama jz zeroo mov [di], '1' zeroo: shl bx, 1 inc di loop print popa ret convert_to_bin endp proses_16hexbin proc CMP BX,32767D JG OVERFLOW CMP BX,-32768D JL OVERFLOW MOV AH,9 LEA DX,BARIS INT 21H LEA DX,HCHEX1 INT 21H XOR AX,AX CALL convert_to_bin@ mov si, offset result ; set alamat buffer si. mov ah, 0eh mov cx, 17 ; cetak 16 bit plus akhiran 'b' print_me@: mov al, [si] int 10h inc si loop print_me@ mov ah, 0 ret convert_to_bin@ proc near pusha lea di, result ;cetak hasil dalam binary mov cx, 16 print@: mov ah, 2 ; print function. mov [di], '0' test bx, 1000_0000_0000_0000b ; test bit pertama jz zeroo@ mov [di], '1' zeroo@: shl bx, 1 inc di loop print@ popa ret convert_to_bin@ endp proses_16bindec proc mov ah,9 lea dx,baris int 21h lea dx,baris int 21h lea dx,ket int 21h lea dx,baris int 21h lea dx,hcbin int 21h xor ax,ax mov ax,bx call print_ax CALL PROSES_16SIGN call lagi print_ax proc cmp ax, 0 jne print_ax_r1 push ax mov al, '0' mov ah, 0eh int 10h pop ax ret print_ax_r1: pusha mov dx, 0 cmp ax, 0 je pn_done1 mov bx, 10 div bx call print_ax_r1 mov ax, dx add al, 30h mov ah, 0eh int 10h jmp pn_done1 pn_done1: popa ret endp proses_16dechex proc cmp bx,32767d jg overflow cmp bx,-32768d jl overflow mov x,bh MOV C,BL mov ah,9 lea dx,baris int 21h lea dx,hcbin1 int 21h xor dx,dx MOV DL,x CALL ATAS ATAS PROC NEAR: lea bx, table mov al, dl shr al, 4 xlat mov ah, 0eh int 10h mov al, dl and al, 0fh xlat mov ah, 0eh int 10h mov ah, 0 MOV DL,C RET ATAS ENDP CALL ATAS ret lagi proc j: mov ah,9 LEA DX,BARIS INT 21H LEA DX,BARIS INT 21H lea dx,baris int 21h lea dx,ulang int 21h mov ah,1 int 21h cmp al,'y' je mulai cmp al,'Y' je mulai cmp al,'t' je exit cmp al,'T' je exit jne j ret lagi endp PROSES_8SIGN PROC MOV AL,BL ;untuk menghasilkan bilangan desimal bertanda 8 bit MOV Q,AL AND AL,7FH CMP AL,Q JNE PROSSIGN JMP TAMPILKAN PROSSIGN: NEG AL XOR AL,80H MOV P,AL MOV AH,9 LEA DX,BARIS INT 21H LEA DX,SIGN INT 21H LEA DX,MINUSZ INT 21H MOV AL,P JMP IKI TAMPILKAN: mov ah,9 lea dx,baris int 21h lea dx,SIGN int 21h xor dx,dx xor ax,ax mov ax,bx call print_al1 ret IKI: print_al1 proc cmp al, 0 jne print_al_r1 push ax mov al, '0' mov ah, 0eh int 10h pop ax ret print_al_r1: pusha mov ah, 0 cmp ax, 0 je pn_done2 mov dl, 10 div dl call print_al_r1 mov al, ah add al, 30h mov ah, 0eh int 10h jmp pn_done2 pn_done2: popa ret endp PROSES_16SIGN PROC MOV AX,BX MOV L,AX AND AX,7FFFH CMP AX,L JNE PROSSIGN2 JMP TAMPILKAN2 ;untuk menghasilkan bilangan desimal bertanda 16 bit PROSSIGN2: NEG AX XOR AX,8000H MOV M,AX MOV AH,9 LEA DX,BARIS INT 21H LEA DX,SIGN INT 21H LEA DX,MINUSZ INT 21H MOV AX,M JMP SKIE2 TAMPILKAN2: mov ah,9 lea dx,baris int 21h lea dx,SIGN int 21h xor ax,ax mov ax,bx call print_ax3 RET SKIE2: print_ax3 proc cmp ax, 0 jne print_ax_r13 push ax mov al, '0' mov ah, 0eh int 10h pop ax ret print_ax_r13: pusha mov dx, 0 cmp ax, 0 je pn_done13 mov bx, 10 div bx call print_ax_r13 mov ax, dx add al, 30h mov ah, 0eh int 10h jmp pn_done13 pn_done13: popa ret endp OVERFLOW: MOV AH,9 LEA DX,BARIS INT 21H LEA DX,OVER INT 21H CALL LAGI