News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

my DecIntToStr.

Started by ArtemESC, September 17, 2006, 01:53:56 PM

Previous topic - Next topic

ArtemESC

Please, help me optimise this...

;this macros get length of string
;es: [di] - address of string
GetStrLen macro len
local L1
local L2
  push di
  and  len, 0h
L1: 
  cmp  byte ptr es: [di], 0h
  je   L2
  inc  di
  inc  len
L2:     
  pop  di
endm


;this macros inverse string
;es: [di] - address of string
InverseStr  macro
local L   
  push ax
  push di
  push si
  GetStrLen si
  dec  si
  add  si, di
L: 
  mov  ax, es: [di]
  xchg ax, es: [si]
  mov  es: [di], ax
  dec  si
  inc  di
  cmp  di, si
  jb   L
  pop  si
  pop  di
  pop  ax
endm
               
                         
;tis macros convert decimal number to string
;es: [di] - address of string
DecIntToStr macro Num
local L
  push dx
  push ax
  push di
L: 
  xor  dx, dx
  mov  ax, Num
  mov  bx, 10
  div  bx
  add  dx, '0'
  mov  byte ptr es: [di], dl
  inc  di
  cmp  ax, 0
  jne  L
  InverseStr
  pop  di
  pop  ax
  pop  dx
endm