Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,332 of 4,675    |
|    wolfgang kern to All    |
|    Re: Hex 2 Bin (1/2)    |
|    05 Apr 18 12:04:21    |
      From: nowhere@never.at              Kerr-Mudd,John posted:              after all I see some neat tricks in your code ...              > minicalc.com              > ->u100 l100       > 161D:0100 BE 80 00 mov si,0080       > 161D:0103 AC lodsb       > 161D:0104 98 cbw       > 161D:0105 91 xchg ax,cx       > 161D:0106 E8 8F 00 call 0198 ; getnum       > 161D:0109 72 4C jb 0157       > 161D:010B 95 xchg ax,bp              I'm not sure where the call returns to if only spaces or cx=0.              > 161D:010C 4E dec si       > 161D:010D AC lodsb       > 161D:010E 3C 20 cmp al,20       > 161D:0110 E1 FB loopzw 010D       > 161D:0112 74 43 jz 0157       > 161D:0114 50 push ax ; save operator       > 161D:0115 E8 80 00 call 0198 ; getnum       > 161D:0118 92 xchg ax,dx       > 161D:0119 58 pop ax       > 161D:011A 72 3B jb 0157       > testop:       > 161D:011C 98 cbw       > 161D:011D 2C 25 sub al,25              why sub 25 ? Ok I see, it makes ax=0 -> bp=0 + clear dx before DIV       and now I see how you assigned the "%" to MOD              > 161D:011F 74 3B jz 015C       > 161D:0121 3C 06 cmp al,06       > 161D:0123 74 12 jz 0137       > 161D:0125 3C 08 cmp al,08       > 161D:0127 74 13 jz 013C       > 161D:0129 3C 05 cmp al,05       > 161D:012B 74 14 jz 0141       > 161D:012D 3C 0A cmp al,0A       > 161D:012F 74 2B jz 015C       > 161D:0131 3C FE cmp al,FE       > 161D:0133 74 11 jz 0146       > 161D:0135 EB 20 jmp 0157              dual branch ? jnz and reorder can make one or two branches vanish              > addnums:       > 161D:0137 95 xchg ax,bp       > 161D:0138 01 D0 add ax,dx       > 161D:013A EB 2D jmp 0169       > subnums:       > 161D:013C 95 xchg ax,bp       > 161D:013D 29 D0 sub ax,dx       > 161D:013F EB 28 jmp 0169              ADD and SUB could be combined       subnum:        NEG ax       addnum:        xchg ..        ADD ..              > mulnums:       > 161D:0141 95 xchg ax,bp       > 161D:0142 F7 E2 mul dx       > 161D:0144 EB 23 jmp 0169       > expnums:       > 161D:0146 89 E8 mov ax,bp       > 161D:0148 51 push cx       > 161D:0149 89 D1 mov cx,dx       > 161D:014B 49 dec cx       > 161D:014C F7 E5 mul bp       > 161D:014E 09 D2 or dx,dx       > 161D:0150 75 05 jnz 0157       > 161D:0152 E2 F8 loopw 014C       > 161D:0154 59 pop cx       > 161D:0155 EB 12 jmp 0169       > prtusage:       > 161D:0157 BA D2 01 mov dx,01D2       > 161D:015A EB 37 jmp 0193       > divmodnums:       > 161D:015C 53 push bx       > 161D:015D 89 D3 mov bx,dx       > 161D:015F 99 cwd       > 161D:0160 95 xchg ax,bp       > 161D:0161 F7 F3 div bx       > 161D:0163 5B pop bx       > 161D:0164 45 inc bp       > 161D:0165 4D dec bp       > 161D:0166 75 01 jnz 0169 ; if mod prt dx       > 161D:0168 92 xchg ax,dx       > prtnum:       > 161D:0169 BF FB 01 mov di,01FB       > 161D:016C B1 68 mov cl,68       > 161D:016E 80 FB 10 cmp bl,10       > 161D:0171 74 0A jz 017D       > 161D:0173 B1 2B mov cl,2B       > 161D:0175 09 C0 or ax,ax       > 161D:0177 79 04 jns 017D       > 161D:0179 F7 D8 neg ax       > 161D:017B B1 2D mov cl,2D       > 161D:017D 31 D2 xor dx,dx       > 161D:017F F7 F3 div bx       > 161D:0181 92 xchg ax,dx       > 161D:0182 3C 0A cmp al,0A       > 161D:0184 1C 69 sbb al,69       > 161D:0186 2F das       > 161D:0187 88 05 mov [di],al       > 161D:0189 4F dec di       > 161D:018A 92 xchg ax,dx       > 161D:018B 09 C0 or ax,ax       > 161D:018D 75 EE jnz 017D       > 161D:018F 88 0D mov [di],cl       > 161D:0191 57 push di       > 161D:0192 5A pop dx       > 161D:0193 B4 09 mov ah,09       > 161D:0195 CD 21 int 21       > 161D:0197 C3 ret       >       > getnum:       > 161D:0198 AC lodsb       > 161D:0199 3C 20 cmp al,20       > 161D:019B E1 FB loopzw 0198       > 161D:019D 74 30 jz 01CF              ?? if first call: 01CF pops ax,dx,pb,ip ?? (JZ 01CE)              > 161D:019F BB 0A 00 mov bx,000A ; assume decimal       > 161D:01A2 3C 68 cmp al,68 ; 'h'       > 161D:01A4 75 03 jnz 01A9       > 161D:01A6 B3 10 mov bl,10 ; is hex       > 161D:01A8 AC lodsb       > 161D:01A9 55 push bp       > 161D:01AA 52 push dx       > 161D:01AB 3C 2D cmp al,2D ; -ve?       > 161D:01AD 9C pushfw       > 161D:01AE 74 01 jz 01B1       > 161D:01B0 4E dec si ;not minus, go back a char       > 161D:01B1 31 ED xor bp,bp       > 161D:01B3 AC lodsb       > 161D:01B4 3C 30 cmp al,30       > 161D:01B6 72 0E jb 01C6 ; end on <0       > 161D:01B8 24 4F and al,4F ; hex2bin       > 161D:01BA D4 37 aam 37       > 161D:01BC 98 cbw       > 161D:01BD 95 xchg ax,bp       > 161D:01BE F7 E3 mul bx       > 161D:01C0 72 0D jb 01CF       > 161D:01C2 01 C5 add bp,ax ; accumulate num in bp       > 161D:01C4 E2 ED loopw 01B3       > 161D:01C6 95 xchg ax,bp       > 161D:01C7 9D popfw       > 161D:01C8 75 02 jnz 01CC       > 161D:01CA F7 D8 neg ax ; if -ve       > 161D:01CC 5A pop dx       > 161D:01CD 5D pop bp       > 161D:01CE C3 ret       > errnum:       > 161D:01CF 58 pop ax ;drop saved flags, cy still set       > 161D:01D0 EB FA jmp 01CC              > db 'Usage is: calc num1 [+-*/%#] num2',cr,lf,'$'       > db '-$$$$$$'              you use the "h" as prefix while I (optionally) display it after Num.       __       wolfgang              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca