M
M
Maria2020-12-13 21:09:07
assembler
Maria, 2020-12-13 21:09:07

I can not solve the lab in assembler?

5fd655d6556fe041954745.jpeg
Topic: "Programming branching algorithms in Assembler".
I wrote a division with a remainder to the first function y1, I don’t understand how to branch from the condition if this condition does not satisfy.

mov al,x
        cmp al,a
        jg sled1
        mov bl,a
        jmp sled2
        
sled1:  mov ah,1
        int 21h
        
        mov al,x
        test bh,4
        div bh
        mov bl,ah
        
sled2:  mov y1,bl

Help with the first function y1, and then I will figure it out by myself.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2020-12-13
@jcmvbkbc

mov al,x
cmp al,a
jg sled1
mov bl,a
...

how to branch from a condition if that condition does not satisfy.

If the condition is not satisfied, the instruction jg sled1does not branch and you simply execute the instruction following it -- mov bl, a. The branches and transitions in your code look correct.

M
Maria, 2020-12-15
@Masha116

It turned out something like this, it seems to even work and correctly fulfill the conditions when substituting numbers. Maybe someone will come in handy, I'm attaching the code.
I'll take it in for a check this week and report back.

usl1:   cmp al,a
        jg @true1
        mov al,a
        jmp short @Y1
        
@true1: mov al,x
        mov bh,4
        div bh
        mov bl,ah
        mov al,bl
        
@Y1:    mov y1,al

usl2:   mov ah,0
        mov al,x
        mov bl,a
        div bl
        mov al,bl
        cmp al,3
        jg @true2
        mov al,x
        jmp short @Y2

@true2: mov al,a
        mov bl,x
        mul bl
        mov al,bl
        

@Y2:    mov y2,al 
        mov al,y1
        add al,y2
        mov y,al

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question