Hi everyone
i am new here
and i have problem with this code, i need algorithm all code. please help me all master of Assembly :)
program has a bug. not change AM to PM in the right time. please help me to change. thank you so much. :)
especially this : ...
check_hour proc
xor ax, ax ; kosongkan ax agar tidak divide overflow
mov al, hour_num
cmp al, 13
jl siang ; (Jump If Less Than)
;jika 13 atau lebih maka dikurang 12 untuk membuatnya menjadi 1
sub AL, 12
mov am_pm, 80
JMP pagi
siang:
;else if hour is less than or equal to 12
mov am_pm, 65
pagi:
lea SI, hour_out
mov BL, 10
div BL
add AL, 48
mov DS:[SI], AL
inc SI
add AH, 48
mov DS:[SI], AH
ret
check_hour endp
full code:
.model small
.stack 200h
.data
hour_num db ?
min_num db ?
sec_num db ?
hour_out db ' '
batas1 db ' : '
min_out db ' '
batas2 db ' : '
sec_out db ' '
spacer db ' '
am_pm db 'AM'
ender db '$'
.code
Start:
mov AX, @data ;khusus untuk program exe
mov DS, AX ;arahkan register ds ke data segmen melalui register ax
;call procedures
call get_time
call check_hour
call check_min
call check_sec
call create_box
call print_time
;Mengecek isi keyboard buffer.
mov ah, 0bh ;get input status menggunakan AL
int 21h
cmp al, 0 ; AL = 00h jika tidak ada karakter
je Start
call clear_screen
;set posisi cursor
;agar di sudut kiri atas
mov ah, 02h
mov bh, 00
mov dh, 00
mov dl, 00
int 10h
mov ax, 4c00h ; kembali ke DOS
int 21h
; * PROCEDURES*
clear_screen proc
mov cx, 0
mov dx, 7924 ; mengatur ukuran layar yg akan dihapus
mov al, 0
mov bh, 7h
mov ah, 6h
int 10h
ret
clear_screen endp
get_time proc
;clear/scroll the screen
mov ax,2c00h
int 21h
;ch = jam
;cl = menit
;dh = detik
;dl = mili detik
mov hour_num,ch
mov min_num,cl
mov sec_num,dh
ret ; return to caller.
get_time endp
check_hour proc
xor ax, ax ; kosongkan ax agar tidak divide overflow
mov al, hour_num
cmp al, 13
jl siang ; (Jump If Less Than)
;jika 13 atau lebih maka dikurang 12 untuk membuatnya menjadi 1
sub AL, 12
mov am_pm, 80
JMP pagi
siang:
;else if hour is less than or equal to 12
mov am_pm, 65
pagi:
lea SI, hour_out
mov BL, 10
div BL
add AL, 48
mov DS:[SI], AL
inc SI
add AH, 48
mov DS:[SI], AH
ret
check_hour endp
check_min proc
lea SI, min_out
xor AX, AX
mov AL, min_num
mov BL, 10
div BL
add AL, 48
mov DS:[SI], AL
inc SI
add AH, 48
mov DS:[SI], AH
ret
check_min endp
check_sec proc
lea SI, sec_out
xor AX, AX
mov AL, sec_num
mov BL, 10
div BL
add AL, 48
mov DS:[SI], AL
inc SI
add AH, 48
mov DS:[SI], AH
ret
check_sec endp
create_box proc
;set posisi cursor
mov ah, 02h
mov bh, 00 ; nomor halaman tampilan
mov dh, 08 ; nomor baris
mov dl, 21 ; nomor kolom
int 10h
;buat border ats
mov ah, 09h
mov al, '-'
mov bh, 00
mov bl, 09
mov cx, 40
int 10h
;set posisi cursor
mov ah, 02h
mov bh, 00
mov dh, 16
mov dl, 21
int 10h
;buat border bawah
mov ah, 09h
mov al, '-'
mov bh, 00
mov bl, 09
mov cx, 40
int 10h
;set posisi cursor
mov ah, 02
mov bh, 00
mov dh, 9
mov dl, 21
int 10h
;buat border kiri
mov ah, 09h
mov al, '|'
mov cx, 1
int 10h
;set posisi cursor
mov ah, 02h
mov bh, 00
mov dh, 9
mov dl, 60
int 10h
;buat border kanan
mov ah, 09h
mov al, '|'
mov cx, 1
int 10h
ret
create_box endp
print_time proc
;set posisi cursor
mov ah, 02h
mov bh, 00
mov dh, 12
mov dl, 34
int 10h
;cetak string
mov ah, 09h
lea dx, hour_out
int 21h
ret
print_time endp
end Start