Hello, never before on the assembler code. But now it is necessary. There is such a code:

masm model small .stack 100h .data a equ 3 b equ 4 c equ 6 CT db ? .code stt:mov ax,@data mov ds,ax mov al, a whil:mov CT, al cmp al, b jnc repa inc al and al,0fh jmp whil repa:dec al and al,0fh mov CT, al cmp al, c jc repa jz repa mov ax,4c00h int 21h end stt 

In this program that is written above, you need to make changes

 begin CT:=a; While Con_1 do Opr_1; Repeat Opr_2 Until Con_2 End. 

I have.

 Con_1 это СТ < b Opr_1 это CT:=CT+1 Con_2 CT>=c Opr_2 CT:=CT-1 
  • " need to change operators " - what? If you need to implement some kind of algorithm, then describe it with normal words, and not through encryption. And remove meaningless comments like "defining a data segment", "comparing with a parameter", etc. from the code. Because of this garbage, the code cannot be read at all. - PinkTux
  • There is a program in it instead of the operators that are written in While to replace them with Con_1 and Opr_1 for Repeat also, only operators number 2 - Dmitry Berezhnoy
  • And what are Con_1, Opr_1, Con_2 and Opr_2 - should we come up with ourselves? - PinkTux
  • Con_1 is CT <b Opr_1 is CT: = CT + 1 Con_2 CT> = c Opr_2 CT: = CT-1 - Dmitry Berezhnoy
  • Thanks for the example .. The problem is simply this, until yesterday I didn’t see the assembler ... only Java .. And then they give me this code, so that I would change it ... the operators are written in the question. While (CT <b) {..ST ++}, and the same for repeat - Dmitry Berezhnoy

1 answer 1

I did not understand anything in your cipher, but just in case an example. Implementing cycles with pre- and post-conditions on an assembler is very simple, use creatively:

 ; ---------------------------------- section .text global main ; ---------------------------------- main: xor edx, edx mov eax, 4 ; while( eax > 0 ) { ; edx++; ; } ; ; оно же ; ; While eax > 0 do edx++, eax-- loop1: or eax, eax jz next1 inc edx dec eax jmp loop1 next1: ; do ; { ; edx++; ; eax++; ; } while( eax < 10 ); ; ; оно же ; ; Repeat eax++, edx++ Until eax < 10 loop2: inc eax inc edx cmp eax, 10 jl loop2 ret ; ---------------------------------- 
  • And the example was excellent with high-level comments - Dmitry Berezhnoy
  • Thank you. I'll try to figure out something ... And what is in my jc , jz and repa code - Dmitry Berezhnoy
  • one
    jl , jz - conditional transitions (transitions to the specified label that are performed when certain conditions are met - in this case L ess and Z ero, ie, the result of the comparison is "less", and the result of the operation is 0, respectively). A conditional transition jc also happens, but you do not need it yet. repa - the name of the label to which the transition. - insolor
  • one
    Sorry, but with such questions you first read the assembly language primer. Or - to the exchange of freelancers, look for a performer. - PinkTux
  • one
    Change, I think, no one is against :) - PinkTux