Advertisement
Guest User

Asembler v1 suma_cyfr w zapisie

a guest
Oct 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .text
  2. global _start
  3. _start:
  4.     mov ax, 1234        ;ax = 1234
  5.     mov bx, 10          ;bx = 10
  6.     mov cx, 0           ;cx = 0
  7. _loop:              
  8.     cmp ax, bx          ;compare ax == bx
  9.     jl _end             ;jump if less _end -> end condition
  10.     push dx             ;push dx to the stack  
  11.     call _div_and_save  ;function call to  _div_and_save
  12.     pop dx              ;pop dx from the stack
  13.     jmp _loop           ;jump to _loop
  14. _div_and_save:
  15.     mov dx, 0           ;dx = 0
  16.     div bx              ;ax = ax / bx (10) and dx = ax % bx
  17.     add cx, dx          ;cx = cx + dx
  18.     ret                 ;return from function
  19. _end:                  
  20.     add cx, ax          ;cx = cx + ax
  21.     printReg cx        
  22.     return0             ;return 0;
  23. section .data
  24. HexDig  db '0', '1', '2', '3'
  25.     db '4', '5', '6', '7'
  26.     db '8', '9', 'A', 'B'
  27.     db 'C', 'D', 'E', 'F'
  28. msg db '12 = 0000', 0xa
  29. len     equ $ - msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement