Jump to content

assembler program in debug

- - - - -

  • Please log in to reply
12 replies to this topic

#1
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
:c-thumbdown:

need help on a small assembler program. I have no clue how to really write in assembly im in a class ahead and the first program is the only assembly one and i havent taken assembly yet so i really need some help understanding it.


cpsc240= 57 * 13 mod 23 (print quotient=xx & remiander= XX)
for i = 1 to 10 print "OpSys" and i

I have to write it in the cmd's debug program.
So far i tried the second one i can now print OpSys 1 and thats about it i got no clue how to do a loop or make an integer i and add to it.

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
What do you have so far (speaking of code)?

#3
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
well so far i tried the second one
and i just made it print OpSys 1

mov ax,0200
mov bx,004f
int 21
mov bx,0070
int 21
mov bx,0053
int 21
mov bx,0079
int 21
mov bx,0073
int 21
mov bx,0020
int 21
mov bx,0031
int 21

#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
You can also use loops.

#5
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
You could make a separate block of code, that you can call, that prints to the screen "0pSys ":
print_0pSys: 

  lea bx, string_1 

  lp1: 

    mov al, [bx] 

    cmp al, 0 

    jz lp1s 

    mov dl, al 

    mov ah, 2 

    int 0x21 

    inc bx 

    jmp lp1 

  lp1s: 

  ret 


#6
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
You could also use loops in that manner for the loop that goes 1 through 10, that you mentioned.

#7
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
im slowly learning it, i know i need a loop and a condition where the loop ends after i = 10 but i dont really know the commands for it

#8
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
i also have to write it in cmd debug

#9
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
You might need to learn about some instructions:
MUL Intel Pentium Instruction Set Reference - MUL - Unsigned Multiply
IMUL Intel Pentium Instruction Set Reference - IMUL - Signed Multiply
DIV Intel Pentium Instruction Set Reference - DIV - Unsigned Divide
IDIV Intel Pentium Instruction Set Reference - IDIV - Signed Divide
ADD Intel Pentium Instruction Set Reference - ADD - Add
SUB Intel Pentium Instruction Set Reference - SUB - Subtract
INC Intel Pentium Instruction Set Reference - INC - Increment by 1
DEC Intel Pentium Instruction Set Reference - DEC - Decrement by 1

You might at least want to learn IMUL and IDIV, and maybe MUL and DIV (multiplication and division instructions), since that's what you have to do in that program; unless you already know those, of course.

I don't know about debug, though.

#10
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
yeah thats whats making it hard for me is writing it in the debug program

#11
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,251 posts
  • Location:C:\Countries\US
The things I mostly did were making a program for NASM assembler with
ORG 0x100 
at the top of the program assembly source file and assemble it directly, in flat-form binary format, to a .com file and run that either from command prompt or DOS-BOX. I don't really know the difference between debug and what I was doing.

#12
kdj1881

kdj1881

    Newbie

  • Members
  • Pip
  • 6 posts
yeah its like the same in debug u write out the program and save it to a .com file and open it through cmd i just think some of the wording is different




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users