Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone help me take a 16bit code and make a 32bit code this is a assembly la

ID: 3885839 • Letter: C

Question

Can anyone help me take a 16bit code and make a 32bit code this is a assembly language project. 16bit code below. Can I get explaination on what is happening.

title gcd03 ; find gcd of two numbers

include irvine16.inc

;_________________________________________________________-

.data

num1 dw 0000h

num2 dw 0001h

string1 db 'enter the smaller number = ','$'

string2 db 'enter the larger number = ','$'

result db 'gcd is = ','$'

gcd dw 0002h

;____________________________________________________________

.code

k11main proc far

mov ax,@data

mov ds,ax

mov es,ax

call b11clrview

lea di,string1

lea si,string2

mov dh,05

mov dl,11

call b12cursor

mov ah,09h

lea dx,string1

int 21h

call readint

mov num2,ax ;smaller number

mov dh,07

mov dl,11

call b12cursor

mov ah,09

lea dx,string2

int 21h

call readint

mov num1,ax ;have a cmp of num1 > num2

mov bx,num2

cmp ax,bx

jae lupe1

xchg ax,bx

lupe1:

mov dx,0000h div bx

cmp dx,0000h

jz endoflupe1

mov gcd,dx

mov ax,bx

mov bx,dx

jmp lupe1 endoflupe1:

mov dh,11

mov dl,17

call b12cursor

lea dx,result

mov ah,09h

int 21h

mov ax,gcd

call writeint

mov dh,22

mov dl,11

call b12cursor

mov ax,4c00h

int 21h

k11main endp

;__________________________________________________________

b11clrview proc

pusha

mov ah,06h ;clear screen

mov al,00h ;full screen

mov bh,74h ;page 157

mov cx,0000h ;starting row;column

mov dx,314fh ;ending row column

int 10h

popa ret b11clrview endp

;_________________________________________________________

;cursor coordinates are placed in dx before calling procedure

b12cursor

proc

pusha

mov ah,02h ;set cursor

mov bh,00h ;page number zer0

int 10h

popa ret b12cursor endp

;________________________________________________________

b10screen

proc near

pusha ;preserve general registers

mov ah,08h ;request get current

int 10h ;attribute in ah

mov bh,ah ;

move it to bh

mov ax,0600h ;scroll whole screen

mov cx,0000 ;upper left location

mov dx,314fh ;lower right location

int 10h

mov ax,0610h ;create a 16-line window

mov bh,16h ;blue b/g , brwn f/g

mov cx,0418h ;upper left corner 04:24

mov dx,1336h ;lower corner 19:54

int 10h

popa ;restore general registers ret ;return to caller

b10screen endp

end k11main

Explanation / Answer

/*GCD of 2 numbers in 32 bit with explanation*/
DATA SEGMENT
NUM1 DW 000AH
NUM2 DW 0004H
GCD DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA ;Load the Data to AX.
MOV DS,AX ;Move the Data AX to DS.
MOV AX,NUM1 ;Move the first number to AX.
MOV BX,NUM2 ;Move the second number to BX.
UP: CMP AX,BX ;Compare the two numbers.
JE EXIT ;If equal, go to EXIT label.
JB EXCG ;If first number is below than second,
;go to EXCG label.
UP1: MOV DX,0H ;Initialize the DX.
DIV BX ;Divide the first number by second number.
CMP DX,0 ;Compare remainder is zero or not.
JE EXIT ;If zero, jump to EXIT label.
MOV AX,DX ;If non-zero, move remainder to AX.
JMP UP ;Jump to UP label.
EXCG:XCHG AX,BX ;Exchange the remainder and quotient.
JMP UP1 ;Jump to UP1.
EXIT:MOV GCD,BX ;Store the result in GCD.
MOV AH,4CH
INT 21H
CODE ENDS
END START
      

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote