flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > DOS > Displaying 16-bit Registers in Hex | 
  
| Author | 
  | 
              
| 
                  
                   fasmnewbie 01 Aug 2013, 15:33 
                  Sample usage is:
 
                  
                Code: mov bp, 16o prtReg bp ;prints in HEX The only problem is with SI. I suspect this has something to do with xor si, si instruction I used. But I already pushed and popped it properly. That doesn't happen with DI.  | 
              |||
                  
  | 
              
| 
                  
                   AsmGuru62 01 Aug 2013, 16:17 
                  SI is used to do work, yet you do "pop a" and it turns into "pop si" as per macro replacement of parameters. 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   fasmnewbie 01 Aug 2013, 16:27 
                  AsmGuru62 wrote: SI is used to do work, yet you do "pop a" and it turns into "pop si" as per macro replacement of parameters. Did you mean I aliased it? I thought that a param is supposed to be a variable or a constant and that pusha should be enough in reserving si.  | 
              |||
                  
  | 
              
| 
                  
                   fasmnewbie 01 Aug 2013, 16:53 
                  Ok I got it Guru... just some minor changes.
 
                  
                Code: org 100h hextab db '0123456789ABCDEF' macro prtReg a { local .go, .done pusha ;push a mov bx, hextab ;for XLAT mov cx, a xor si, si xchg ch, cl .go: mov dl, cl mov dh, ch ;updated and cl, 0Fh and dl, 0F0h shr dl, 4 ;Digit Translations mov al, dl xlat [bx] prtChar al mov al, cl xlat [bx] prtChar al inc si cmp si, 2 je .done ;pop a mov cl, dh ;updated ;mov cx, a jmp .go .done: prtChar 'H' popa } macro prtChar a { ;BIOS: Prints a character push ax mov ah, 0eh mov al, a int 10h pop ax } macro pquit { mov ah,0h int 16h int 20h } ;Sample usage mov si, 4 shr si, 1 prtReg si ;problem solved. Thanks to Guru  | 
              |||
                  
  | 
              
| 
                  
                   baldr 01 Aug 2013, 22:13 
                  fasmnewbie wrote: 2. Is there any trick to get the value of IP? You may add if ~ a eq al around mov al, a inside prtChar macro to avoid otherwise perfect nop in form of mov al, al. Another improvement may be using eqtype operator to merge mov ah/al, imm8 into mov ax, imm16 for literal numeric/character argument. There is (slow, rarely used, and unavailable in 64-bit mode) aam 16 instruction that can be used to split al into nibbles.  | 
              |||
                  
  | 
              
| 
                  
                   fasmnewbie 29 Oct 2013, 15:51 
                  baldr wrote: 
 Thanks for the trick and advice.  | 
              |||
                  
  | 
              
| 
                  
                   jamespond 08 Nov 2013, 16:43 
                  My "reg to text display" routine shows dl reg as text. It called two times:
 
                  
                . . table db "0123456789abcdef" . push dx mov dl,dh call hexout pop dx call hexout . . hexout: mov al, dl lea bx, table shr al, 4 xlat mov ah, 0eh int 10h mov al, dl and al, 0fh xlat mov ah, 0eh int 10h ret  | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.