global _start _start: %macro accept 2 mov rax,0 mov rdi,0 mov rsi,%1 mov rdx,%2 syscall %endm %macro disp 2 mov rax,1 mov rdi,1 mov rsi,%1 mov rdx,%2 syscall %endm ;hex to bcd disp msg1,len1 accept num,2 call convert1 mov [num1],al accept num,3 call convert1 mov [num2],al mov ah,[num1] mov al,[num2] mov rsi,arr1 a1: mov dx,0000h mov bx,[rsi] div bx mov [rem],dx push rsi call display1 pop rsi inc rsi inc rsi mov ax,[rem] dec byte[cnt1] jnz a1 ;exit mov rax,60 mov rdi,0 syscall convert1: mov rsi,num mov al,[rsi] cmp al,39h jbe l1 sub al,07h l1: sub al,30h rol al,04h mov bl,al inc rsi mov al,[rsi] cmp al,39h jbe l2 sub al,07h l2: sub al,30h add al,bl ret convert2: mov rsi,num mov al,[rsi] sub al,30h ret display1: add al,30h mov [t1],al disp t1,1 ret section .data arr1 dw 2710h,03E8h,0064h,000Ah,0001h cnt1 db 05 msg1 db "BCD equivalent:",0ah len1 equ $-msg1 section .bss num resb 10 num1 resb 10 num2 resb 10 t1 resb 10 rem resb 10
To embed this project on your website, copy the following code and paste it into your website's HTML: