0

First of all, thank you for your interest and help in my topic. Do any of you know how to do it? We wrote the code in class together with the lecturer, but I do not know if it is correct for the 8086 processor. I am a beginner and i was start learning assembler and I apologize if I give any big mistakes.

%include "asm.mac"
global ToDec


SUB ToDec, number, podstawa
      %define result ebx
      mov edi,decoder
      mov esi,number
      xor result,result
      or ecx,-1
.go
      xor eax,eax
      lodsb
      call instr, edi, eax
      and al,al
      jz .quit
      dec eax
      push eax

      mov eax,result
      mul dword base
      pop ebx
      add eax,ebx
      mov result,eax
      loop .go

.quit
      mov eax,result
ENDSUB


SUB instr, searchString, CharToFind
      %define result edx
      xor result,result
      mov ebx,CharToFind
      mov esi,searchString
      or  ecx,-1
.go:
      lodsb
      and al,al
      jz .notf
      cmp al,bl
      loopne .go
;found
      sub esi,searchString
      mov result,esi
.notf
      mov eax,result
ENDSUB




segment .data use32
decoder db "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",0
  • 1
    That looks like NASM syntax. emu8086 doesn't handle `%include` directives, and certainly not 32-bit registers like EAX. Also `mul dword base` isn't valid: `base` without `[]` is the address, not the value, but there is no immediate form of `mul`. – Peter Cordes Nov 25 '20 at 13:19
  • 1
    Also, if you don't want a loop counter, just use `jmp` instead of wasting ECX as a counter and using the slow `loop` instruction! I also don't see the point of all that storing to memory inside the loop. The total result should be able to stay in a register, like in [NASM Assembly convert input to integer?](https://stackoverflow.com/a/49548057) (32-bit NASM code). Normally you'd just branch on the value range to decide whether to subtract `'0'` or `'A'`, but yes a string-search could work if you did it without overwriting the registers you're using for the outer loop. – Peter Cordes Nov 25 '20 at 13:21

0 Answers0